Baby Kyber Part 2: Encryption and Decryption
In the first part of this article, I showed how to generate a Kyber key pair:
Now, we will encrypt and decrypt. We will encrypt with the public key (A,t), and decrypt with the private key (s). In Kyber we modify the normal LWE (Learning With Errors) approach and use MLWE (Module Learning With Errors). With MLWE we use vectors of polynomials.
Adding errors
The first thing we need to do is to create three randomized small polynomial vectors (e_1, e_2 and r) — this must not be repeated in any future communication. In our simple example, we will use:
Converting the messaging into a polynomial
In order to process our message, we need to convert it into a polynomial. This is achieved by converting each into a coefficient. Thus “1101” becomes:
x³+x+1
Our message must then be scaled so that we have relatively large coefficients. As we have q=17, we have a halfway point of q/2, and then upscale to get a factor of 9. Our message…