Misplaced Pages

HEAAN

Article snapshot taken from[REDACTED] with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
HEAAN
Developer(s)Cryptography LAB in Seoul National University
Initial releaseMay 15, 2016; 8 years ago (2016-05-15)
Repository
Written inC++
TypeHomomorphic encryption
LicenseCC 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). The first version of HEAAN was published on GitHub on 15 May 2016, and later a new version of HEAAN with a bootstrapping algorithm was released. Currently, the latest regular version is version 1.1 and the latest pre-release version is 2.1.

CKKS plaintext space

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 C n / 2 {\displaystyle \mathbb {C} ^{n/2}} for some power-of-two integer n {\displaystyle n} . To deal with the complex plaintext vector efficiently, Cheon et al. proposed plaintext encoding/decoding methods which exploits a ring isomorphism ϕ : R [ X ] / ( X n + 1 ) C n / 2 {\displaystyle \phi :\mathbb {R} /(X^{n}+1)\rightarrow \mathbb {C} ^{n/2}} .

Encoding method

Given a plaintext vector z = ( z 1 , z 2 , . . . , z n / 2 ) C n / 2 {\displaystyle {\vec {z}}=(z_{1},z_{2},...,z_{n/2})\in \mathbb {C} ^{n/2}} and a scaling factor Δ > 1 {\displaystyle \Delta >1} , the plaintext vector is encoded as a polynomial m ( X ) R := Z [ X ] / ( X n + 1 ) {\displaystyle m(X)\in R:=\mathbb {Z} /(X^{n}+1)} by computing m ( X ) = Δ ϕ 1 ( z ) R {\displaystyle m(X)=\lfloor \Delta \cdot \phi ^{-1}({\vec {z}})\rceil \in R} where {\displaystyle \lfloor \cdot \rceil } denotes the coefficient-wise rounding function.

Decoding method

Given a message polynomial m ( X ) R {\displaystyle m(X)\in R} and a scaling factor Δ > 1 {\displaystyle \Delta >1} , the message polynomial is decoded to a complex vector z C n / 2 {\displaystyle {\vec {z}}\in \mathbb {C} ^{n/2}} by computing z = Δ 1 ϕ ( m ( X ) ) C n / 2 {\displaystyle {\vec {z}}=\Delta ^{-1}\cdot \phi (m(X))\in \mathbb {C} ^{n/2}} .

Here the scaling factor Δ > 1 {\displaystyle \Delta >1} enables us to control the encoding/decoding error which is occurred by the rounding process. Namely, one can obtain the approximate equation Dcd ( Ecd ( z ; Δ ) ; Δ ) z {\displaystyle {\text{Dcd}}({\text{Ecd}}({\vec {z}};\Delta );\Delta )\approx {\vec {z}}} by controlling Δ {\displaystyle \Delta } where Ecd {\displaystyle {\text{Ecd}}} and Dcd {\displaystyle {\text{Dcd}}} denote the encoding and decoding algorithm, respectively.

From the ring-isomorphic property of the mapping ϕ : R [ X ] / ( X n + 1 ) C n / 2 {\displaystyle \phi :\mathbb {R} /(X^{n}+1)\rightarrow \mathbb {C} ^{n/2}} , for m 1 = Ecd ( z 1 ; Δ ) {\displaystyle m_{1}={\text{Ecd}}({\vec {z}}_{1};\Delta )} and m 2 = Ecd ( z 2 ; Δ ) {\displaystyle m_{2}={\text{Ecd}}({\vec {z}}_{2};\Delta )} , the following hold:

  • Dcd ( m 1 + m 2 ; Δ ) z 1 + z 2 {\displaystyle {\text{Dcd}}(m_{1}+m_{2};\Delta )\approx {\vec {z}}_{1}+{\vec {z}}_{2}} ,
  • Dcd ( m 1 m 2 ; Δ ) z 1 z 2 {\displaystyle {\text{Dcd}}(m_{1}\cdot m_{2};\Delta )\approx {\vec {z}}_{1}\circ {\vec {z}}_{2}} ,

where {\displaystyle \circ } denotes the Hadamard product of the same-length vectors. These properties guarantee the approximate correctness of the computations in the encoded state when the scaling factor Δ {\displaystyle \Delta } is chosen appropriately.

Algorithms

The CKKS scheme basically consists of those algorithms: key Generation, encryption, decryption, homomorphic addition and multiplication, and rescaling. For a positive integer q {\displaystyle q} , let R q := R / q R {\displaystyle R_{q}:=R/qR} be the quotient ring of R {\displaystyle R} modulo q {\displaystyle q} . Let χ s {\displaystyle \chi _{s}} , χ r {\displaystyle \chi _{r}} and χ e {\displaystyle \chi _{e}} be distributions over R {\displaystyle R} which output polynomials with small coefficients. These distributions, the initial modulus Q {\displaystyle Q} , and the ring dimension n {\displaystyle n} are predetermined before the key generation phase.

Key generation

The key generation algorithm is following:

  • Sample a secret polynomial s χ s {\displaystyle s\leftarrow \chi _{s}} .
  • Sample a {\displaystyle a} (resp. a {\displaystyle a'} ) uniform randomly from R Q {\displaystyle R_{Q}} (resp. R P Q {\displaystyle R_{PQ}} ), and e , e χ e {\displaystyle e,e'\leftarrow \chi _{e}} .
  • Output a secret key s k ( 1 , s ) R Q 2 {\displaystyle sk\leftarrow (1,s)\in R_{Q}^{2}} , a public key p k ( b = a s + e , a ) R Q 2 {\displaystyle pk\leftarrow (b=-a\cdot s+e,a)\in R_{Q}^{2}} , and an evaluation key e v k ( b = a s + e + P s 2 , a ) R P Q 2 {\displaystyle evk\leftarrow (b'=-a'\cdot s+e'+P\cdot s^{2},a')\in R_{PQ}^{2}} .

Encryption

The encryption algorithm is following:

  • Sample an ephemeral secret polynomial r χ r {\displaystyle r\leftarrow \chi _{r}} .
  • For a given message polynomial m R {\displaystyle m\in R} , output a ciphertext c t ( c 0 = r b + e 0 + m , c 1 = r a + e 1 ) R Q 2 {\displaystyle ct\leftarrow (c_{0}=r\cdot b+e_{0}+m,c_{1}=r\cdot a+e_{1})\in R_{Q}^{2}} .

Decryption

The decryption algorithm is following:

  • For a given ciphertext c t R q 2 {\displaystyle ct\in R_{q}^{2}} , output a message m c t , s k {\displaystyle m'\leftarrow \langle ct,sk\rangle } ( mod  q ) {\displaystyle ({\text{mod }}q)} .

The decryption outputs an approximate value of the original message, i.e., Dec ( s k , Enc ( p k , m ) ) m {\displaystyle {\text{Dec}}(sk,{\text{Enc}}(pk,m))\approx m} , and the approximation error is determined by the choice of distributions χ s , χ e , χ r {\displaystyle \chi _{s},\chi _{e},\chi _{r}} . When considering homomorphic operations, the evaluation errors are also included in the approximation error. Basic homomorphic operations, addition and multiplication, are done as follows.

Homomorphic addition

The homomorphic addition algorithm is following:

  • Given two ciphertexts c t {\displaystyle ct} and c t {\displaystyle ct'} in R q 2 {\displaystyle R_{q}^{2}} , output c t add c t + c t R q 2 {\displaystyle ct_{\text{add}}\leftarrow ct+ct'\in R_{q}^{2}} .

The correctness holds as Dec ( s k , c t add ) Dec ( s k , c t ) + Dec ( s k , c t ) {\displaystyle {\text{Dec}}(sk,ct_{\text{add}})\approx {\text{Dec}}(sk,ct)+{\text{Dec}}(sk,ct')} .

Homomorphic multiplication

The homomorphic multiplication algorithm is following:

  • Given two ciphertext c t = ( c 0 , c 1 ) {\displaystyle ct=(c_{0},c_{1})} and c t = ( c 0 , c 1 ) {\displaystyle ct'=(c_{0}',c_{1}')} in R q 2 {\displaystyle R_{q}^{2}} , compute ( d 0 , d 1 , d 2 ) = ( c 0 c 0 , c 0 c 1 + c 1 c 0 , c 1 c 1 ) {\displaystyle (d_{0},d_{1},d_{2})=(c_{0}c_{0}',c_{0}c_{1}'+c_{1}c_{0}',c_{1}c_{1}')} ( mod  q ) {\displaystyle ({\text{mod }}q)} . Output c t mult ( d 0 , d 1 ) + P 1 d 2 e v k R q 2 {\displaystyle ct_{\text{mult}}\leftarrow (d_{0},d_{1})+\lfloor P^{-1}\cdot d_{2}\cdot evk\rceil \in R_{q}^{2}} .

The correctness holds as Dec ( s k , c t mult ) Dec ( s k , c t ) Dec ( s k , c t ) {\displaystyle {\text{Dec}}(sk,ct_{\text{mult}})\approx {\text{Dec}}(sk,ct)\cdot {\text{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. 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.

Rescaling

The rescaling algorithm is following:

  • Given a ciphertext c t R q 2 {\displaystyle ct\in R_{q}^{2}} and a new modulus q < q {\displaystyle q'<q} , output a rescaled ciphertext c t rs ( q / q ) c t R q 2 {\displaystyle ct_{\text{rs}}\leftarrow \lfloor (q'/q)\cdot ct\rceil \in R_{q'}^{2}} .

The total procedure of the CKKS scheme is as following: Each plaintext vector z {\displaystyle {\vec {z}}} which consists of complex (or real) numbers is firstly encoded as a polynomial m ( X ) R {\displaystyle m(X)\in R} by the encoding method, and then encrypted as a ciphertext c t R q 2 {\displaystyle ct\in R_{q}^{2}} . After several homomorphic operations, the resulting ciphertext is decrypted as a polynomial m ( X ) R {\displaystyle m'(X)\in R} and then decoded as a plaintext vector z {\displaystyle {\vec {z}}'} which is the final output.

Security

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.

Library

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 R q {\displaystyle R_{q}} was accelerated by utilizing fast Fourier transform (FFT)-optimized number theoretic transform (NTT) implementation.

References

  1. Cheon, Jung Hee; Kim, Andrey; Kim, Miran; Song, Yongsoo (2017). "Homomorphic encryption for arithmetic of approximate numbers". Takagi T., Peyrin T. (eds) Advances in Cryptology – ASIACRYPT 2017. ASIACRYPT 2017. Springer, Cham. pp. 409–437. doi:10.1007/978-3-319-70694-8_15.
  2. Andrey Kim; Kyoohyung Han; Miran Kim; Yongsoo Song. "An approximate HE library HEAAN". GitHub. Retrieved 15 May 2016.
  3. Jung Hee Cheon, Kyoohyung Han, Andrey Kim, Miran Kim and Yongsoo Song. Bootstrapping for Approximate Homomorphic Encryption. In EUROCRYPT 2018(springer).
  4. "Release HEAAN with BOOTSTRAPPING · snucrypto/HEAAN". GitHub. Retrieved 2024-12-10.
  5. Release HEAAN with Faster Multiplication · snucrypto/HEAAN, Cryptography LAB in Seoul National University, Sep 5, 2018, retrieved 2024-12-10
  6. Z. Brakerski, C. Gentry, and V. Vaikuntanathan. Fully Homomorphic Encryption without Bootstrapping. In ITCS 2012
  7. Martin Albrecht. Security Estimates for the Learning with Errors Problem, https://bitbucket.org/malb/lwe-estimator
Categories:
HEAAN Add topic