BenchmarksStack Ranking
APIsPricingDocsWhite PaperTokenBlogAboutSecurity Demo
Log InGet API Key
FHE · 5 min read

FHE Key Management:
Best Practices for Production Systems

How to securely manage FHE keys in production environments.

~42µs
Per Auth
2.17M/s
Throughput
128-bit
Security
32
Users/Batch

FHE key management is critical for security. The encryption is only as strong as the protection of your keys. In a system processing 1.595 million authentications per second with BFV fully homomorphic encryption, a single leaked secret key compromises every ciphertext ever encrypted under it. This guide covers best practices for managing FHE keys in production — essential for any organization looking to compute on encrypted data at scale.

FHE Key Types

FHE systems use several key types:

Key Size Reality

FHE keys are large. A BFV secret key at N=4096 is a few kilobytes, but evaluation keys (Galois + relinearization) can reach tens of megabytes depending on the decomposition base and moduli count. In H33's production configuration -- a single 56-bit modulus with t=65537 -- Galois keys for all required rotations consume roughly 12 MB. Plan storage, caching, and network transmission accordingly.

Secret Key Protection

The secret key is the crown jewel. Unlike symmetric encryption, where a leaked key exposes past messages, a leaked FHE secret key also lets an attacker evaluate arbitrary computations on existing ciphertexts and read the results. Protect it with:

// Never do this
const secretKey = "abc123...";  // Hardcoded key

// Better: Load from secure storage
const secretKey = await hsm.getKey('fhe-secret-key');
// Or from a cloud vault with IAM-scoped access
const secretKey = await keyVault.getSecret('fhe-secret-key');

In H33's production stack, the BFV secret key is stored in NTT form (forward NTT applied at keygen). This means even internal memory dumps would expose a transformed representation, not the raw polynomial coefficients. Defense in depth starts at the representation level.

Key Generation

Proper key generation is essential:

Parameter Selection Matters

Key generation is inseparable from parameter selection. In BFV, the polynomial degree N, ciphertext modulus Q, and plaintext modulus t jointly determine security level, noise budget, and performance. H33 uses N=4096 with a single 56-bit modulus and t=65537, tuned for the biometric_fast() tier. This configuration delivers 128-bit security while keeping the per-authentication latency at ~42 microseconds -- fast enough to sustain 1.595 million auths per second across 96 Graviton4 workers.

ParameterValueImpact
N (ring degree)4096128-bit security, 32 SIMD slots (4096 / 128 dims)
Q (ciphertext modulus)56-bit single primeMinimal NTT cost, one modulus in RNS chain
t (plaintext modulus)65537CRT batching enabled (t = 1 mod 2N)
Noise distributionCentered binomial (CBD)Batch-sampled: 1 RNG call per 10 coefficients

Choosing parameters that are too aggressive shrinks the noise budget and causes decryption failures. Choosing parameters that are too conservative wastes compute. There is no substitute for benchmarking your specific workload with your specific hardware.

Key Rotation

Regular key rotation limits exposure from potential compromise:

Homomorphic Re-encryption

FHE supports a technique called key-switching, where a ciphertext encrypted under key A is transformed into a ciphertext encrypted under key B -- without decrypting. This enables seamless key rotation in production: new ciphertexts use the new key, and existing ciphertexts are re-encrypted in the background. The re-encryption requires a special key-switching key (KSK) generated from both the old and new secret keys, which must itself be protected and destroyed after the rotation window closes.

Evaluation Key Distribution

Evaluation keys must reach the computing party:

In high-throughput systems, evaluation key transmission is a real bottleneck. A full set of Galois keys for BFV at N=4096 can exceed 10 MB. H33 addresses this by pre-computing and caching public-key material in NTT form at enrollment time -- the pk0 component is stored in NTT form, eliminating a clone and forward NTT on every encrypt call. For ZKP proof caching, an in-process DashMap achieves 0.085-microsecond lookups, removing any network overhead entirely.

Multi-Party Scenarios

When multiple parties are involved:

Threshold Decryption

In threshold FHE, the secret key is split into n shares using a technique like Shamir's Secret Sharing. Decryption requires at least k of n shares, so no single party ever holds the complete key. H33's CollectiveAuthority uses this model for biometric batch verification: 32 users are packed into a single BFV ciphertext via SIMD batching, and partial decryption shares from multiple authorities are combined with combine_crt. This approach ensures that even the authentication infrastructure itself cannot unilaterally decrypt user biometric templates.

Backup and Recovery

Key loss means data loss. Plan for recovery:

Post-Quantum Key Protection

BFV's lattice-based hardness assumptions already provide post-quantum security for the FHE layer, but key management infrastructure must match. Wrapping FHE secret keys with RSA or ECDH for transport defeats the purpose -- a quantum adversary breaks the wrapper and extracts the key. H33 uses Dilithium signatures for key attestation and Kyber (ML-KEM) for key encapsulation during distribution. Every key artifact in the pipeline -- generation, distribution, rotation, and destruction -- is protected by post-quantum primitives end to end.

Common Mistake

Do not protect lattice-based FHE keys with classical key-wrapping algorithms. If your threat model includes quantum adversaries (and it should), the entire key lifecycle must use post-quantum cryptography. A single classical link in the chain makes the whole system vulnerable to harvest-now-decrypt-later attacks.

Proper FHE key management ensures your encrypted data remains both secure and accessible. The gap between a theoretically sound FHE deployment and a production-grade one is almost entirely in key lifecycle management -- generation, storage, rotation, distribution, and destruction. Invest in robust key infrastructure from the start, benchmark your parameters against real hardware, and never assume that the cryptographic hardness of the scheme compensates for weak operational practices around the keys themselves.

Ready to Go Quantum-Secure?

Start protecting your users with post-quantum authentication today. 1,000 free auths, no credit card required.

Get Free API Key →

Build With Post-Quantum Security

Enterprise-grade FHE, ZKP, and post-quantum cryptography. One API call. Sub-millisecond latency.

Get Free API Key → Read the Docs
Free tier · 10,000 API calls/month · No credit card required
Verify It Yourself