An overview of the scheme (Cheon-Kim-Kim-Song) that enables approximate arithmetic on encrypted real numbers.
BFV and BGV schemes work perfectly with integers, giving exact results. But most machine learning and data analysis operate on real numbers. CKKS, introduced by Cheon, Kim, Kim, and Song (2016), is designed for approximate arithmetic on encrypted real and complex numbers.
Before CKKS, consider a simple LWE-style encryption (integers with noise) to build intuition:
\[ q = 97, \quad s = 17, \quad e = \text{small noise term (e.g., ±1)} \]
Encryption: \[ Enc(m) = (a, b = (a \cdot s + m + e) \bmod q) \]
Decryption: \[ Dec(a,b) = (b - a\cdot s) \bmod q \approx m \]
Noise grows with operations; CKKS handles this carefully for real numbers.
CKKS encodes real numbers as scaled integers using a scale factor \(\Delta\):
\[ \text{Encode}(x) = \lfloor x \cdot \Delta \rceil \]
This integer is then encrypted; the “noise” becomes part of the approximation.
Multiplication grows both the scale and the noise. CKKS uses rescaling to divide the ciphertext by \(\Delta\) and keep results in a manageable range:
\[ c' \xrightarrow{\text{rescale}} c'' \approx \frac{c'}{\Delta} \]
To understand why this is necessary, it's crucial to look at the two distinct types of noise in CKKS.
In CKKS, "noise" comes from two sources, unlike base LWE/RLWE schemes [2]:
Like standard LWE/RLWE encryption, CKKS ciphertexts include a small random noise \(e_1\) to ensure semantic security [2]:
\[\text{Enc}(\tilde{x}) = \big(a, \; b = (a \cdot s + \tilde{x} + e_1) \bmod q\big)\]
This noise grows as you perform additions and multiplications.
CKKS encodes real numbers as integers using a scale factor \(\Delta\) [4]:
\[ \tilde{x} = \text{Round}(x \cdot \Delta) \]
This means the encoded value can be seen as the "true" scaled value plus a small rounding error, \(e_2\):
\[ \tilde{x} = (x \cdot \Delta) + e_2 \]
Here, \(e_2\) is the rounding error. Unlike \(e_1\), it is not cryptographic; it represents the inherent approximation from scaling real numbers.
Think of CKKS ciphertexts as "fuzzy" numbers [4]:
✅ CKKS embraces the noise: the cryptographic noise e1 ensures security, while the encoding error e2 defines the unavoidable approximation. Controlled rescaling and scale management allow arithmetic on real numbers with predictable approximation.
CKKS papers and libraries don't use a single formula, but a noise model to track growth [4]. The primary goal is to ensure the final noise is smaller than the desired precision after decoding.
CKKS allows packing thousands of numbers into one ciphertext. Operations on ciphertexts apply to all packed numbers simultaneously:
\[ C_{vec} = \text{Encrypt}([x_1, x_2, \dots, x_N]) \]
Encoding \(x=1.5\), \(y=2.25\) with scale \(\Delta=1000\):
This diagram shows the full lifecycle of data using the values from above.
Try encrypting real numbers using CKKS-like approximate arithmetic: