Kyber crystal [here]

Member-only story

Baby Kyber Part 1: Generating the Private and Public Keys

Juggling With Polynomials in Python

Prof Bill Buchanan OBE FRSE
5 min readApr 23, 2023

--

I did my first lattice cryptography lecture on Friday, and it was fun to present some of the basics of Post Quantum Cryptography (PQC). As part of this, I outlined the usage of Kyber for key exchange/public key encryption, and Dilithium for digital signatures. So, let’s take a toy example to illustrate the basic principles of Kyber. In the first part of this article we will look at the basics, and see how we use polynomial values to represent our data values.

Polynomials

In polynomial representation, we can take a data value of 1101 and represent it in polynomial powers:

x³+1.x²+0x+1 = x³+x²+1

We can then multiply, divide, add and subtract polynomial values. If you remember from school, for (2x²+1) times (x+1) we get:

(2x²+1).(x+1) = 2x³+2x²+x+1

The (mod p) operation

Obviously, if we are multiplying polynomials, the coefficients of the powers could become large, so we perform a (mod q) operation on them. Let’s take a q value of 17 and let’s say we have:

a=2x⁴+3x³+10x+3

b=3x⁵+14x³+10x+4

--

--

Prof Bill Buchanan OBE FRSE
Prof Bill Buchanan OBE FRSE

Written by Prof Bill Buchanan OBE FRSE

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.

No responses yet