HEAAN | |
Developer: | Cryptography LAB in Seoul National University |
Programming Language: | C++ |
Genre: | Homomorphic encryption |
License: | CC BY-NC 3.0 |
HEAAN (Homomorphic Encryption for Arithmetic of Approximate Numbers) is an open source homomorphic encryption (HE) library which implements an approximate HE scheme proposed by Cheon, Kim, Kim and Song (CKKS).[1] The first version of HEAAN was published on GitHub[2] on 15 May 2016, and later a new version of HEAAN with a bootstrapping algorithm[3] was released.Currently, the latest version is Version 2.1.
Unlike other HE schemes, the CKKS scheme supports approximate arithmetics over complex numbers (hence, real numbers). More precisely, the plaintext space of the CKKS scheme is
Cn/2
n
\phi:R[X]/(Xn+1) → Cn/2
Given a plaintext vector
\vecz=(z1,z2,...,zn/2)\inCn/2
\Delta>1
m(X)\inR:=Z[X]/(Xn+1)
m(X)=\lfloor\Delta ⋅ \phi-1(\vecz)\rceil\inR
\lfloor ⋅ \rceil
Given a message polynomial
m(X)\inR
\Delta>1
\vecz\inCn/2
\vecz=\Delta-1 ⋅ \phi(m(X))\inCn/2
Here the scaling factor
\Delta>1
Dcd(Ecd(\vecz;\Delta);\Delta) ≈ \vecz
\Delta
Ecd
Dcd
From the ring-isomorphic property of the mapping
\phi:R[X]/(Xn+1) → Cn/2
m1=Ecd(\vecz1;\Delta)
m2=Ecd(\vecz2;\Delta)
Dcd(m1+m2;\Delta) ≈ \vecz1+\vecz2
Dcd(m1 ⋅ m2;\Delta) ≈ \vecz1\circ\vecz2
where
\circ
\Delta
The CKKS scheme basically consists of those algorithms: key Generation, encryption, decryption, homomorphic addition and multiplication, and rescaling. For a positive integer
q
Rq:=R/qR
R
q
\chis
\chir
\chie
R
Q
n
The key generation algorithm is following:
s\leftarrow\chis
a
a'
RQ
RPQ
e,e'\leftarrow\chie
sk\leftarrow(1,s)\in
2 | |
R | |
Q |
pk\leftarrow(b=-a ⋅ s+e,a)\in
2 | |
R | |
Q |
evk\leftarrow(b'=-a' ⋅ s+e'+P ⋅ s2,a')\in
2 | |
R | |
PQ |
The encryption algorithm is following:
r\leftarrow\chir
m\inR
ct\leftarrow(c0=r ⋅ b+e0+m,c1=r ⋅ a+e1)\in
2 | |
R | |
Q |
The decryption algorithm is following:
ct\in
2 | |
R | |
q |
m'\leftarrow\langlect,sk\rangle
(modq)
The decryption outputs an approximate value of the original message, i.e.,
Dec(sk,Enc(pk,m)) ≈ m
\chis,\chie,\chir
The homomorphic addition algorithm is following:
ct
ct'
2 | |
R | |
q |
ctadd\leftarrowct+ct'\in
2 | |
R | |
q |
The correctness holds as
Dec(sk,ctadd) ≈ Dec(sk,ct)+Dec(sk,ct')
The homomorphic multiplication algorithm is following:
ct=(c0,c1)
ct'=(c0',c1')
2 | |
R | |
q |
(d0,d1,d2)=(c0c0',c0c1'+c1c0',c1c1')
(modq)
ctmult\leftarrow(d0,d1)+\lfloorP-1 ⋅ d2 ⋅ evk\rceil\in
2 | |
R | |
q |
The correctness holds as
Dec(sk,ctmult) ≈ Dec(sk,ct) ⋅ Dec(sk,ct')
Note that the approximation error (on the message) exponentially grows up on the number of homomorphic multiplications. To overcome this problem, most of HE schemes usually use a modulus-switching technique which was introduced by Brakerski, Gentry and Vaikuntanathan.[4] In case of HEAAN, the modulus-switching procedure is called rescaling. The Rescaling algorithm is very simple compared to Brakerski-Gentry-Vaikuntanathan's original algorithm.Applying the rescaling algorithm after a homomomorphic multiplication, the approximation error grows linearly, not exponentially.
The rescaling algorithm is following:
ct\in
2 | |
R | |
q |
q'<q
ctrs\leftarrow\lfloor(q'/q) ⋅ ct\rceil\in
2 | |
R | |
q' |
The total procedure of the CKKS scheme is as following: Each plaintext vector
\vecz
m(X)\inR
ct\in
2 | |
R | |
q |
m'(X)\inR
\vecz'
The IND-CPA security of the CKKS scheme is based on the hardness assumption of the ring learning with errors (RLWE) problem, the ring variant of very promising lattice-based hard problem Learning with errors (LWE).Currently the best known attacks for RLWE over a power-of-two cyclotomic ring are general LWE attacks such as dual attack and primal attack.The bit security of the CKKS scheme based on known attacks was estimated by Albrecht's LWE estimator.[5]
Version 1.0, 1.1 and 2.1 have been released so far. Version 1.0 is the first implementation of the CKKS scheme without bootstrapping.In the second version, the bootstrapping algorithm was attached so that users are able to address large-scale homomorphic computations.In Version 2.1, currently the latest version, the multiplication of ring elements in
Rq