HEAAN

From HandWiki - Reading time: 6 min

HEAAN
Developer(s)Cryptography LAB in Seoul National University
Initial releaseMay 15, 2016; 8 years ago (2016-05-15)
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).[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.[4][verification needed]

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

Encoding method

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

Decoding method

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

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

From the ring-isomorphic property of the mapping [math]\displaystyle{ \phi: \mathbb{R}[X]/(X^n+1) \rightarrow \mathbb{C}^{n/2} }[/math], for [math]\displaystyle{ m_1 = \text{Ecd}(\vec z_1;\Delta) }[/math] and [math]\displaystyle{ m_2 = \text{Ecd}(\vec z_2;\Delta) }[/math], the following hold:

  • [math]\displaystyle{ \text{Dcd}(m_1 + m_2;\Delta) \approx \vec z_1 + \vec z_2 }[/math],
  • [math]\displaystyle{ \text{Dcd}(m_1\cdot m_2;\Delta) \approx \vec z_1 \circ \vec z_2 }[/math],

where [math]\displaystyle{ \circ }[/math] 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 [math]\displaystyle{ \Delta }[/math] 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 [math]\displaystyle{ q }[/math], let [math]\displaystyle{ R_q := R/qR }[/math] be the quotient ring of [math]\displaystyle{ R }[/math] modulo [math]\displaystyle{ q }[/math]. Let [math]\displaystyle{ \chi_s }[/math], [math]\displaystyle{ \chi_r }[/math] and [math]\displaystyle{ \chi_e }[/math] be distributions over [math]\displaystyle{ R }[/math] which output polynomials with small coefficients. These distributions, the initial modulus [math]\displaystyle{ Q }[/math], and the ring dimension [math]\displaystyle{ n }[/math] are predetermined before the key generation phase.

Key generation

The key generation algorithm is following:

  • Sample a secret polynomial [math]\displaystyle{ s \leftarrow \chi_s }[/math].
  • Sample [math]\displaystyle{ a }[/math] (resp. [math]\displaystyle{ a' }[/math]) uniform randomly from [math]\displaystyle{ R_Q }[/math] (resp. [math]\displaystyle{ R_{PQ} }[/math]), and [math]\displaystyle{ e,e' \leftarrow \chi_e }[/math].
  • Output a secret key [math]\displaystyle{ sk \leftarrow (1, s)\in R_Q^2 }[/math], a public key [math]\displaystyle{ pk \leftarrow (b = -a \cdot s + e, a) \in R_Q^2 }[/math], and an evaluation key [math]\displaystyle{ evk \leftarrow (b' = -a' \cdot s + e' + P\cdot s^2, a') \in R_{PQ}^2 }[/math].

Encryption

The encryption algorithm is following:

  • Sample an ephemeral secret polynomial [math]\displaystyle{ r \leftarrow \chi_r }[/math].
  • For a given message polynomial [math]\displaystyle{ m \in R }[/math], output a ciphertext [math]\displaystyle{ ct \leftarrow (c_0 = r\cdot b + e_0 + m, c_1 = r\cdot a + e_1) \in R_Q^2 }[/math].

Decryption

The decryption algorithm is following:

  • For a given ciphertext [math]\displaystyle{ ct \in R_q^2 }[/math], output a message [math]\displaystyle{ m' \leftarrow \langle ct, sk \rangle }[/math] [math]\displaystyle{ (\text{mod } q) }[/math].

The decryption outputs an approximate value of the original message, i.e., [math]\displaystyle{ \text{Dec}(sk, \text{Enc}(pk, m)) \approx m }[/math], and the approximation error is determined by the choice of distributions [math]\displaystyle{ \chi_s, \chi_e, \chi_r }[/math]. 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 [math]\displaystyle{ ct }[/math] and [math]\displaystyle{ ct' }[/math] in [math]\displaystyle{ R_q^2 }[/math], output [math]\displaystyle{ ct_{\text{add}} \leftarrow ct + ct' \in R_q^2 }[/math].

The correctness holds as [math]\displaystyle{ \text{Dec}(sk, ct_\text{add}) \approx \text{Dec}(sk, ct) + \text{Dec}(sk, ct') }[/math].

Homomorphic multiplication

The homomorphic multiplication algorithm is following:

  • Given two ciphertext [math]\displaystyle{ ct =(c_0, c_1) }[/math] and [math]\displaystyle{ ct' =(c_0', c_1') }[/math] in [math]\displaystyle{ R_q^2 }[/math], compute [math]\displaystyle{ (d_0, d_1, d_2) = (c_0c_0', c_0c_1'+c_1c_0', c_1c_1') }[/math] [math]\displaystyle{ (\text{mod } q) }[/math]. Output [math]\displaystyle{ ct_{\text{mult}} \leftarrow (d_0, d_1) + \lfloor P^{-1}\cdot d_2 \cdot evk \rceil \in R_q^2 }[/math].

The correctness holds as [math]\displaystyle{ \text{Dec}(sk, ct_\text{mult}) \approx \text{Dec}(sk, ct) \cdot \text{Dec}(sk, ct') }[/math].

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.[5] 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 [math]\displaystyle{ ct \in R_q^2 }[/math] and a new modulus [math]\displaystyle{ q' \lt q }[/math], output a rescaled ciphertext [math]\displaystyle{ ct_{\text{rs}}\leftarrow \lfloor (q'/q)\cdot ct\rceil \in R_{q'}^2 }[/math].

The total procedure of the CKKS scheme is as following: Each plaintext vector [math]\displaystyle{ \vec z }[/math] which consists of complex (or real) numbers is firstly encoded as a polynomial [math]\displaystyle{ m(X) \in R }[/math] by the encoding method, and then encrypted as a ciphertext [math]\displaystyle{ ct \in R_q^2 }[/math]. After several homomorphic operations, the resulting ciphertext is decrypted as a polynomial [math]\displaystyle{ m'(X) \in R }[/math] and then decoded as a plaintext vector [math]\displaystyle{ \vec z' }[/math] 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.[6]

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 [math]\displaystyle{ R_q }[/math] 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". ASIACRYPT 2017. Springer, Cham. pp. 409–437. doi:10.1007/978-3-319-70694-8_15. 
  2. Andrey Kim; Kyoohyung Han. "An approximate HE library HEAAN". https://github.com/snucrypto/HEAAN. 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. snucrypto/HEAAN, Cryptography LAB in Seoul National University, 2021-07-19, https://github.com/snucrypto/HEAAN, retrieved 2021-07-20 
  5. Z. Brakerski, C. Gentry, and V. Vaikuntanathan. Fully Homomorphic Encryption without Bootstrapping. In ITCS 2012
  6. Martin Albrecht. Security Estimates for the Learning with Errors Problem, https://bitbucket.org/malb/lwe-estimator





Licensed under CC BY-SA 3.0 | Source: https://handwiki.org/wiki/Software:HEAAN
17 views | Status: cached on August 14 2024 17:40:40
↧ Download this article as ZWI file
Encyclosphere.org EncycloReader is supported by the EncyclosphereKSF