antontutoveanu / crystals-kyber-javascript Goto Github PK
View Code? Open in Web Editor NEWJavaScript implementation of CRYSTALS-KYBER (version 3) post-quantum key exchange algorithm.
License: MIT License
JavaScript implementation of CRYSTALS-KYBER (version 3) post-quantum key exchange algorithm.
License: MIT License
Hi and thanks for your great work! I would like to contribute to improve your code.
I see these lines in the code:
let kr_str = hash3.digest('hex');
// convert hex string to array
let kr = new Array(32);
for (i = 0; i < 64; i++) {
kr[i] = hexToDec(kr_str[2 * i] + kr_str[2 * i + 1]);
}
let kr1 = kr.slice(0, 32);
let kr2 = kr.slice(32, 64);
But because you are adding 64 bytes to the kr array, it should be created as
let kr = new Array(64);
In fact, you can get the digest value directly in bytes instead of getting it as a hex string, saving the conversion in the hash function from bytes to hex string and also the conversion from hex string to bytes in your code:
let kr = hash3.digest();
// console.log('kr length = ', kr.length); // <- it prints 64
let kr1 = kr.slice(0, 32);
let kr2 = kr.slice(32, 64);
Best,
Fernando.
Hello, I am testing using Kyber, but I have a couple of questions, in the diagram shown what I understand is the following:
The server creates the key pair using K768_KeyGen();
The pk is sent to the client and it generates a shared secret and a cipher text.
The cipher text is transmitted to the server so that it decrypts using the private key and obtains the shared secret.
Client and Server have the shared secret.
Then the AES 256 algorithm is mentioned, how would it be applied if this algorithm generates two leads, if this algorithm uses a key and an iv for encryption and decryption?
When bundled with webpack:
Uncaught ReferenceError: outputlen is not defined at indcpaGenMatrix (webpack-internal:///./node_modules/crystals-kyber/kyber768.js:651)
PR on the way...
I am trying to change the paramters to Kyber 1024, but I have been unsuccesful, where is the paramaters located so i know what to replace and stuff. Or maybe you have a version for kyber 1024
These bits of code are used in compressing a polynomial ring element into a (secret) message:
crystals-kyber-javascript/kyber512.js
Line 461 in 289aa07
crystals-kyber-javascript/kyber768.js
Line 461 in 289aa07
crystals-kyber-javascript/kyber1024.js
Line 460 in 289aa07
To do so, they perform a division by Q that might not necessarily compile to a multiplication instruction: looking at the output of some C compilers using https://godbolt.org/z/sKn3TKKGq and https://godbolt.org/z/8GqKoTfYh for example, a division instruction is emitted even when -O3 is specified. Should a division instruction be emitted, its execution time would likely be variable and leak information about its secret input.
We reported a similar issue in the CRYSTALS-Kyber reference implementation; you may want to use their fix: pq-crystals/kyber@dda29cc
I was trying to test the following code:
import {K768_KeyGen, K768_Encrypt, K768_Decrypt} from 'crystals-kyber';
let pk_sk = K768_KeyGen();
it just got stuck at k768_KeyGen()
I dig around at found that "ntt" function is where it just stops.
Can you help?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.