HEAAN (Homomorphic Encryption for Arithmetic of Approximate Numbers) — CKKS

Some time, soon, we need to do two things:

HEAAN (Homomorphic Encryption for Arithmetic of Approximate Numbers) — CKKS

Some time, soon, we need to do two things:

  1. Switch off our main public key methods, as RSA (prime number factorization), ElGamal (discrete logs) and ECC (elliptic curve) will be cracked by quantum computers.
  2. We need to start to operate on encrypted values. This will involve the usage of homomorphic encryption (HE). With this we could two values of a and b, and where we encrypt them with public key to give Epk(a) and Epk(b). Next we can add them to get Epk(a+b), and where we now apply a secret key (sk) to find a+b.

HEAAN (Homomorphic Encryption for Arithmetic of Approximate Numbers) defines a homomorphic encryption library proposed by Cheon, Kim, Kim and Song (CKKS) in 2016 [here]:

The CKKS method uses approximate arithmetics over complex numbers. As a previous electronic engineer, I recognise a complex number with a real part (x) and an imaginary part (y).We thus get x + jy (note that in other areas, apart from electrical engineering, it would be defined with x+iy). HEAAN can be used for homomorphic addition and multiplication, along with rescaling, and uses a RLWE method [here].

In the following we will convert ASCII characters to their equivalent integer value (such as 97 for an ‘a’) and convert this into a complex number (97+i97). We will generate a key pair, with a public key (pk) and a private key (sk). Here is the code with the Lattigo library [here]:

A sample run is [here]:

HEAAN parameters : logN = 10, logQ = 30, levels = 8 (270 bits), logPrecision = 13, logScale = 30, sigma = 3.190000 
Input: qwerty
Cipher: &{[0xc00012b4c0 0xc00012b4e0] 0xc0000962c0 30 0xc00012b500 true false}
qwerty

Now let’s do a homomophic addition:

For a scalar multiply of an encrypted value:

If you are interested, here is some of the background around the operations: