ArticleslgStudy

computer science

HEAAN

HEAAN is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand HEAAN rather than just read about it. In short: 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.

Key takeaways

  • HEAAN belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect HEAAN to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of HEAAN from memory before moving on to harder problems.

Reference excerpt

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 arithmetic over complex numbers (hence, real numbers). More precisely, the plaintext space of the CKKS scheme is ℂn/2 for some power-of-two integer n. To deal with the complex plaintext vector efficiently, Cheon et al. proposed plaintext encoding/decoding methods which exploit a ring isomorphism ϕ:ℝ[X]/(Xn+1)→ℂn/2.

Encoding method With a plaintext vector z→=(z1,z2,...,zn/2)∈ℂn/2 and a scaling factor Δ>1, the plaintext vector is encoded as a polynomial m(X)∈R:=ℤ[X]/(Xn+1) by computing m(X)=⌊Δ⋅ϕ−1(z→)⌉∈R where ⌊⋅⌉ denotes the coefficient-wise rounding function.

Decoding method Given a message polynomial m(X)∈R and a scaling factor Δ>1, the message polynomial is decoded to a complex vector z→∈ℂn/2 by computing z→=Δ−1⋅ϕ(m(X))∈ℂn/2. Here the scaling factor Δ>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→ by controlling Δ where Ecd and Dcd denote the encoding and decoding algorithm, respectively. From the ring-isomorphic property of the mapping ϕ:ℝ[X]/(Xn+1)→ℂn/2, for m1=Ecd(z→1;Δ) and m2=Ecd(z→2;Δ), the following hold:

Dcd(m1+m2;Δ)≈z→1+z→2, Dcd(m1⋅m2;Δ)≈z→1∘z→2, where ∘ 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 Δ 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, let Rq:=R/qR be the quotient ring of R modulo q. Let χs, χr and χe be distributions over R which output polynomials with small coefficients. These distributions, the initial modulus Q, and the ring dimension n are predetermined before the key generation phase.

Key generation The key generation algorithm is following:

Sample a secret polynomial s←χs. Sample a (resp. a′) uniform randomly from RQ (resp. RPQ), and e,e′←χe. Output a secret key sk←(1,s)∈RQ2, a public key pk←(b=−a⋅s+e,a)∈RQ2, and an evaluation key evk←(b′=−a′⋅s+e′+P⋅s2,a′)∈RPQ2.

Encryption The encryption algorithm is following:

Sample an ephemeral secret polynomial r←χr. For a given message polynomial m∈R, output a ciphertext ct←(c0=r⋅b+e0+m,c1=r⋅a+e1)∈RQ2.

Decryption The decryption algorithm is following:

For a given ciphertext ct∈Rq2, output a message m′←⟨ct,sk⟩ (mod q). The decryption outputs an approximate value of the original message, i.e., Dec(sk,Enc(pk,m))≈m, and the approximation error is determined by the choice of distributions χs,χe,χ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 ct and ct′ in Rq2, output ctadd←ct+ct′∈Rq2. The correctness holds as Dec(sk,ctadd)≈Dec(sk,ct)+Dec(sk,ct′).

Homomorphic multiplication The homomorphic multiplication algorithm is following:

Given two ciphertext ct=(c0,c1) and ct′=(c0′,c1′) in Rq2, compute (d0,d1,d2)=(c0c0′,c0c1′+c1c0′,c1c1′) (mod q). Output ctmult←(d0,d1)+⌊P−1⋅d2⋅evk⌉∈Rq2. 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. 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 ct∈Rq2 and a new modulus q′<q, output a rescaled ciphertext ctrs←⌊(q′/q)⋅ct⌉∈Rq′2. The total procedure of the CKKS scheme is as following: Each plaintext vector z→ which consists of complex (or real) numbers is firstly encoded as a polynomial m(X)∈R by the encoding method, and then encrypted as a ciphertext ct∈Rq2. After several homomorphic operations, the resulting ciphertext is decrypted as a polynomial m′(X)∈R and then decoded as a plaintext vector 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 Rq was accelerated by utilizing fast Fourier transform (FFT)-optimized number theoretic transform (NTT) implementation.

References

Worked examples

Example 1 — a first encounter with HEAAN

Start with the simplest possible case. Write down what HEAAN claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to HEAAN before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about HEAAN ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of HEAAN

In research
HEAAN appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses HEAAN in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
HEAAN is common in secondary-school and first-year university syllabi. It links to neighbouring topics Cryptographic primitives, Homomorphic encryption, Lattice-based cryptography, so understanding it makes those chapters shorter.
In everyday life
Look for HEAAN outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “HEAAN” →

How to study HEAAN in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what HEAAN means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain HEAAN out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is HEAAN in simple terms?

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 versio…

Why does HEAAN matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study HEAAN?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on HEAAN.

Tags

  • Cryptographic primitives
  • Homomorphic encryption
  • Lattice-based cryptography
  • Public-key cryptography

Keep exploring