A Deep Dive into BGV, BFV, and CKKS: Modern Fully Homomorphic Encryption Schemes
Fully Homomorphic Encryption (FHE) represents one of the most significant achievements in modern cryptography, enabling computation on encrypted data without decryption. This post provides a comprehensive technical analysis of three dominant FHE schemes: BGV (Brakerski-Gentry-Vaikuntanathan), BFV (Brakerski-Fan-Vercauteren), and CKKS (Cheon-Kim-Kim-Song). Weβll explore their mathematical foundations using consistent notation and compare their approaches to critical challenges in homomorphic computation.
Mathematical Notations and Concepts
We use the following consistent notation to describe the BGV, BFV, and CKKS schemes.
Core Mathematical Structures
| Symbol | Definition |
|---|---|
| Integers, Real numbers, and Complex numbers | |
| Integers modulo , i.e., | |
| Polynomial ring (degree , coeff. mod ) | |
| Polynomial degree (power of 2, e.g., to ) | |
| Sampling from a distribution (e.g., ) | |
| Rounding to nearest integer, Floor function | |
| Infinity norm (maximum absolute value of coefficients) |
Cryptographic Variables & Operations
| Symbol | Meaning | Notes |
|---|---|---|
| Secret key | Polynomial in (often small/binary) | |
| Public key, Evaluation key | , used for relinearization | |
| Ciphertext | Pair of polynomials | |
| Plaintext message | Encoded data as a polynomial | |
| Error, Error dist. | Small noise drawn from Discrete Gaussian | |
| Ephemeral key | Small random polynomial used in encryption | |
| Modulo reduction | Coefficient-wise reduction into |
Scheme Parameters
| Symbol | Description | Context |
|---|---|---|
| Ciphertext / Plaintext modulus | is large, is small (BGV/BFV) | |
| Scaling factor | (BFV) or precision scale (CKKS) | |
| Multiplicative depth | Number of levels allowed in the circuit | |
| Relinearization bases | Base or large factor for key switching | |
| Complex vector | Input data vector for CKKS | |
| Noise std. dev, Security param | typically bits |
The Foundation: Ring Learning With Errors (RLWE)
All three schemes build upon the Ring Learning With Errors (RLWE) problem, which provides their cryptographic security. Letβs establish our common notation:
- where is a power of 2 (typically 2048, 4096, or 8192)
- for modulus
- for plaintext modulus
- denotes the error distribution (typically discrete Gaussian)
The RLWE problem asks: given many pairs where is secret and , it is computationally hard to recover .
Common Framework
Despite their differences, BGV, BFV, and CKKS share a common structure. Letβs define the core operations using unified notation:
Key Generation
All three schemes generate keys similarly:
Secret Key Generation:
Public Key Generation: where uniformly random and .
Evaluation Key Generation (for relinearization): where is a large integer used for key switching.
Basic Ciphertext Structure
A fresh ciphertext encrypting message has the form:
The invariant maintained is: where is small noise.
Message Encoding and SIMD Batching
A crucial aspect of modern FHE implementation is SIMD (Single Instruction, Multiple Data) packing. Instead of encrypting a single number into a massive polynomial (which is inefficient), we βpackβ a vector of messages into a single polynomial.
BGV and BFV: Integer Batching (CRT Packing)
For BGV and BFV, the plaintext space is the ring . If we choose the plaintext modulus to be a prime such that , the polynomial factors completely into linear terms in .
By the Chinese Remainder Theorem (CRT), there is an isomorphism:
Encoding: Given a vector of integers , we construct a unique polynomial such that: This is efficiently computed using a Number Theoretic Transform (NTT).
Decoding: Evaluate the decrypted polynomial at the roots to recover the vector .
Homomorphic SIMD: Addition/Multiplication of polynomials corresponds to component-wise operations on the vectors: .
CKKS: Complex Batching (Canonical Embedding)
CKKS works with vectors of complex numbers . It utilizes the Canonical Embedding .
Encoding: Given a vector :
- Expand to a conjugate-symmetric vector in .
- Apply the inverse Canonical Embedding (essentially an inverse FFT) to map the vector to a polynomial with real coefficients.
- Scale the coefficients by and round to the nearest integers to get .
Decoding:
- Scale down the coefficients of the decrypted polynomial by .
- Apply the Canonical Embedding (FFT) to recover the vector of values.
This mapping allows performing approximate arithmetic on complex slots simultaneously.
BGV: Encoding in Least Significant Bits
The BGV scheme encodes messages in the least significant bits of ciphertext coefficients, employing modulus switching to manage noise growth.
BGV Encryption
Given plaintext :
- Sample (small polynomial)
- Sample
- Compute:
- Return
BGV Decryption
The decryption is correct if the noise .
BGV Homomorphic Operations
Addition:
Multiplication:
-
Compute tensor product: where:
-
Relinearization reduces back to degree 2 (covered below)
BGV Modulus Switching
After operations, reduce modulus from to :
This scales down both the ciphertext and noise proportionally.
BFV: Encoding in Most Significant Bits
BFV encodes messages in the most significant bits, using a different multiplication strategy.
BFV Encryption
Given plaintext :
- Sample (ternary polynomial)
- Sample
- Compute: where
- Return
BFV Decryption
BFV Homomorphic Operations
Addition: Same as BGV
Multiplication:
-
Compute intermediate values in (without mod ):
-
Scale and round:
-
Apply relinearization to reduce from 3 to 2 components
CKKS: Approximate Arithmetic for Real Numbers
CKKS fundamentally differs by supporting approximate arithmetic on complex/real numbers.
CKKS Encoding
CKKS uses a special encoding that maps vectors of complex numbers to polynomials:
This uses the canonical embedding via primitive -th roots of unity.
CKKS Encryption
Given encoded message at scale :
- Sample
- Sample
- Compute:
- Return at level
CKKS Decryption and Decoding
- Decrypt:
- Decode:
The result approximates the original vector within some error bound.
CKKS Homomorphic Operations
Addition: Standard component-wise addition (same scale required)
Multiplication:
- Multiply as in BGV/BFV to get
- Relinearize to
- Rescale (unique to CKKS): where is a prime in the modulus chain
The rescaling step is crucial: it reduces both the scale (from to ) and the modulus (from to ).
Relinearization: Converting Degree-3 to Degree-2 Ciphertexts
After multiplication, all schemes produce degree-3 ciphertexts that must be reduced:
Key Switching Technique
Given where the invariant is :
-
Decompose into base- digits:
-
Use evaluation key components:
The result maintains the same message but with slightly increased noise.
Noise Management Strategies
The three schemes employ distinct approaches to noise management:
BGV: Modulus Switching
- Actively reduces noise after each level
- Maintains constant noise magnitude
- Requires careful parameter ladder:
BFV: Scale-Invariant Approach
- Keeps modulus fixed throughout computation
- Noise grows but remains manageable through careful analysis
- Simpler parameter selection than BGV
CKKS: Rescaling
- Naturally reduces noise through rescaling after multiplication
- Trades precision for noise reduction
- Allows deeper circuits than exact schemes for approximate computation
Parameter Selection
Key parameters affect security, correctness, and performance:
Common Parameters
- Polynomial degree : Higher values increase security and capacity but slow operations
- Modulus bit-length: Balances security and noise budget
- Standard deviation of error distribution: Affects security and correctness
Scheme-Specific Considerations
BGV:
- Modulus chain: where each
- Typically requires depth of circuit
BFV:
- Single large modulus: depending on and depth
- Plaintext modulus often prime for better noise tolerance
CKKS:
- Scale for good precision
- Special primes for rescaling in modulus chain
- Can handle deeper circuits due to approximate nature
Practical Performance Comparison
Computational Efficiency
- Addition: All schemes have similar performance ( operations)
- Multiplication: BFV slightly slower due to scaling step; CKKS benefits from rescaling
- Bootstrapping: BGV/BFV require complex exact bootstrapping; CKKS has simpler approximate bootstrapping
Use Case Suitability
BGV: Best for:
- Integer arithmetic with known depth
- Applications requiring exact computation
- Scenarios where modulus switching overhead is acceptable
BFV: Best for:
- Integer arithmetic with simpler parameter selection
- Batched operations on binary or small integer data
- Applications where fixed modulus simplifies implementation
CKKS: Best for:
- Machine learning and statistical computations
- Signal processing and scientific computing
- Deep circuits where approximation is acceptable
Security Considerations
All three schemes base security on RLWE hardness, but parameters must be chosen carefully:
Current recommendations (128-bit security):
- bits
- bits
- bits
Implementation Considerations
Library Support
Popular libraries implement these schemes with optimizations:
- SEAL (Microsoft): BFV and CKKS
- HElib (IBM): BGV and CKKS
- PALISADE/OpenFHE: All three schemes
- TenSEAL: Python wrapper focusing on CKKS for ML
Optimization Techniques
- NTT/FFT acceleration: Polynomial multiplication in
- RNS representation: For large moduli in BGV/BFV
- Batching: SIMD operations on packed plaintexts
- Key compression: Reduce evaluation key size
Future Directions
Recent research (2024-2025) focuses on:
- Bootstrapping improvements: Faster refresh procedures
- Compiler tools: Automatic parameter selection and circuit optimization
- Hardware acceleration: FPGA/ASIC implementations
- Standardization: Homomorphic Encryption Standard ongoing work
Conclusion
BGV, BFV, and CKKS each offer unique advantages for different homomorphic encryption applications. BGV provides fine-grained noise control through modulus switching, BFV simplifies implementation with fixed modulus, and CKKS enables efficient approximate arithmetic for real-world numerical computations. Understanding their mathematical foundations and trade-offs is crucial for selecting the appropriate scheme for specific applications.
The consistent mathematical framework presented here demonstrates that despite surface-level differences, these schemes share fundamental principles rooted in RLWE hardness. As FHE continues to mature, we can expect further optimizations and potentially new schemes that combine the best features of existing approaches.
References and Further Reading
For those interested in diving deeper into the mathematical foundations and recent developments: