| Title: | BFV, BGV, CKKS Schema for Fully Homomorphic Encryption |
|---|---|
| Description: | Implements the Brakerski-Fan-Vercauteren (BFV, 2012) <https://eprint.iacr.org/2012/144>, Brakerski-Gentry-Vaikuntanathan (BGV, 2014) <doi:10.1145/2633600>, and Cheon-Kim-Kim-Song (CKKS, 2016) <https://eprint.iacr.org/2016/421.pdf> schema for Fully Homomorphic Encryption. The included vignettes demonstrate the encryption procedures. |
| Authors: | Bastiaan Quast [aut, cre] (ORCID: <https://orcid.org/0000-0002-2951-3577>) |
| Maintainer: | Bastiaan Quast <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.9.0 |
| Built: | 2026-06-05 10:03:24 UTC |
| Source: | https://github.com/bquast/homomorphicencryption |
BFV encryption
BFV_encrypt(m, pk)BFV_encrypt(m, pk)
m |
message |
pk |
public key |
polynomial
Brakerski / Fan-Vercauteren
BFV_KeyGen(d = 4, q = 424242)BFV_KeyGen(d = 4, q = 424242)
d |
the d input |
q |
the q input |
polynomial
d = 4 n = 2^d p = (n/2)-1 q = 424242 GenPolyMod(n)d = 4 n = 2^d p = (n/2)-1 q = 424242 GenPolyMod(n)
Compute basis coordinates
compute_basis_coordinates(sigma_R_basis, z)compute_basis_coordinates(sigma_R_basis, z)
sigma_R_basis |
sigma_R_basis |
z |
z |
basis coordinates
Coordinate-wise random rounding
coordinate_wise_random_rounding(coordinates)coordinate_wise_random_rounding(coordinates)
coordinates |
coordinates |
rounded coordinates
Decode
decode(xi, M, scale, p)decode(xi, M, scale, p)
xi |
xi |
M |
M |
scale |
scale |
p |
p |
decoded xi
Encode
encode(xi, M, scale, z)encode(xi, M, scale, z)
xi |
xi |
M |
M |
scale |
scale |
z |
z |
encode polynomial
Encrypt Polynomial Message Part 0
EncryptPoly0(m, pk0, u, e1, p, pm, q)EncryptPoly0(m, pk0, u, e1, p, pm, q)
m |
message |
pk0 |
public key part 0 |
u |
u |
e1 |
e1 |
p |
p |
pm |
pm |
q |
q |
polynomial which contains the message in ciphertext
Encrypt Polynomial Message Part 1
EncryptPoly1(pk1, u, e2, pm, q)EncryptPoly1(pk1, u, e2, pm, q)
pk1 |
public key part 1 |
u |
u |
e2 |
e2 |
pm |
pm |
q |
q |
polynomial which contains the message in ciphertext
Generate a
GenA(n, q)GenA(n, q)
n |
the order |
q |
the ciphermod of coefficients |
polynomial of order x^^n with coefficients 0,..,q
n = 16 q = 7 GenA(n, q)n = 16 q = 7 GenA(n, q)
Generate a
GenError(n)GenError(n)
n |
the order |
polynomial of order x^^n with discrete Gaussian distribution, bounded (not strictly true) by -n,n
n = 16 GenError(n)n = 16 GenError(n)
Generate the Evaluation Key
GenEvalKey0(a, s, e)GenEvalKey0(a, s, e)
a |
a |
s |
s |
e |
e |
polynomial
Generate the Public Key
GenPubKey(a, n, e, pm, q)GenPubKey(a, n, e, pm, q)
a |
a |
n |
n |
e |
e |
pm |
pm |
q |
q |
list with the two polynomials that form the public key
Generate part 0 of the Public Key
GenPubKey0(a, s, e, pm, q)GenPubKey0(a, s, e, pm, q)
a |
a |
s |
s |
e |
e |
pm |
pm |
q |
q |
polynomial
Generate part 1 of the Public Key
GenPubKey1(a)GenPubKey1(a)
a |
a |
polynomial
Generate Secret key
GenSecretKey(n)GenSecretKey(n)
n |
the order |
polynomial of order x^^n with coefficients (-1,-,1)
n = 16 GenSecretKey(n)n = 16 GenSecretKey(n)
Generate u
GenU(n)GenU(n)
n |
the order |
polynomial of order x^^n-1 with coefficients (-1,-,1)
n = 16 GenUn = 16 GenU
Pi function
pi_function(M, z)pi_function(M, z)
M |
M |
z |
z |
Pi of M
Pi inverse function
pi_inverse(z)pi_inverse(z)
z |
z |
inverse of z
Round coordinates
round_coordinates(coordinates)round_coordinates(coordinates)
coordinates |
coordinates |
rounded coordinates
Sigma
sigma_function(xi, M, p)sigma_function(xi, M, p)
xi |
xi |
M |
M |
p |
p |
sigma of xi
Sigma inverse
sigma_inverse(xi, M, b)sigma_inverse(xi, M, b)
xi |
xi |
M |
M |
b |
b |
sigma inverse of xi
Sigma discretization
sigma_R_discretization(xi, M, z)sigma_R_discretization(xi, M, z)
xi |
xi |
M |
M |
z |
z |
sigma R discretization
Vandermonde
vandermonde(xi, M)vandermonde(xi, M)
xi |
xi |
M |
M |
The Vandermonde matrix