dchest / tweetnacl-js

Port of TweetNaCl cryptographic library to JavaScript
https://tweetnacl.js.org
The Unlicense
1.77k stars 293 forks source link

Multiplying by inverse scalar to get back original point. #156

Closed borisreitman closed 5 years ago

borisreitman commented 5 years ago

In X25519, I would like to multiply a point P by scalar s, using the scalarMultiply() function. Then, I would like to multiply the resulting point by the scalar s_inverse, in order to recover the original point. However, that is not working for me, I'm not getting back the original point.

I'm computing the inverse in the modular field Z_{8q} where q equals 2^252 + 27742317777372353535851937790883648493.

Attached is the full code illustrating the problem. To run it, change the extension to .html. Also download the BigInteger.js and nacl.js dependencies from the URLs listed, and place it in the same folder.

test_inverse.html.txt

dchest commented 5 years ago

I think the proper forum for this question is https://crypto.stackexchange.com, not a bug tracker for implementation.