Skip to content

7h4nd5RG0d/Baby-Kyber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Baby-Kyber

Baby Kyber implementation

Intro:

Baby Kyber is the scaled down version of Kyber, meaing that the security paramters are smaller than the originally intended Kyber.

Explanation of the Code:

https://github.com/7h4nd5RG0d/Baby-Kyber/blob/main/baby_kyber.py

1)Initialisation:

The code will ask you for the coeefecient modulus(q) as well as the polynomial modulus(pmod).
image

2)Key Generation:

You will be prompted for the private key(s),error vector(e) and the initial matrix 'A' as input parameters.
image
From this we will compute t=A*s+e. image
Here the private key consists of (s) and the public key consists of (A,t)
The security of Kyber is dependent on the problem of solving for s,when A,t are given.

3)Encryption:

You will be prompted first for three inputs, namely the randomizer polynomial(r),the error vector(e1) and he error polynomial(e2).
image
Then message is taken as input.
image
The message is first converted to its polynomial representation followed by multiplication by [q/2] so that we are able to decrypt it.
It then computes ,the polynomial vector(u)=(A')*r + e1 where A' denotes the transpose of A.
It is followed by the calculation of v=(t')*r + e2 + m. image
The ciphertext consists of (u,v)

4)Decryption:

Here first it computes mn=v - (s')*u which when simplified results in mn=(e')*r + e2 + m + (s')*e1
image
From the above equation we can make an observation that he coeffecients of mn are either close to (0,q) or q/2 as a result of multiplication by q/2 during encryption.
This gives an interesting decryption scheme.
We decrypt the coefficient as '1' if it close to q/2 and as '0' if it is more close to 0 or q.
image

Ouput:

Case 1: Default meaning pmod=x^4+1

Therefore there are only 16 possible characters that can be encrypted as after that we get many to one encryption making it impossible to decrypt.
Here the code only allows 0-9 as input to avoid it.
image

Case 2: using pmod with degree 5.

Therefore we have 32 possible characters during encryption.
Here the code will only allow a-z as a constraint.

About

Baby Kyber implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages