Git Product home page Git Product logo

crystals-kyber-javascript's People

Contributors

antontutoveanu avatar jplomas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crystals-kyber-javascript's Issues

KeyGen512 is not defined on browser

I have a problem on the client side and can't seem to use the package. I am using Qwik and whenever i import the library i get this error

image

Encrypt function: convert kr to kr_str should be an Array of 64 bytes intead of 32 bytes

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.

Using shared secret - aes - how?

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?

Undeclared variable prevents webpack bundling

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...

How to change paramters

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

Possible variable-time division when decapsulating

These bits of code are used in compressing a polynomial ring element into a (secret) message:

t = (((uint16(a2[8 * i + j]) << 1) + uint16(paramsQ / 2)) / uint16(paramsQ)) & 1;

t = (((uint16(a2[8 * i + j]) << 1) + uint16(paramsQ / 2)) / uint16(paramsQ)) & 1;

t = (((uint16(a2[8 * i + j]) << 1) + uint16(paramsQ / 2)) / uint16(paramsQ)) & 1;

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

Getting stuck while creating keys

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.