Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Ed25519 #268

Open
kot-begemot opened this issue Jan 27, 2022 · 0 comments
Open

Problem with Ed25519 #268

kot-begemot opened this issue Jan 27, 2022 · 0 comments

Comments

@kot-begemot
Copy link

kot-begemot commented Jan 27, 2022

I wonder if I am doing everything correctly, but I can't quite get why I am keep receiving different points for ed25519 depending on the way I am multiplying points by scalar. I compared same setup it with secp256k1 curve of this lib and got exactly same points. Can someone explain if this me that that is missing something or this is some kind of bug. I haven't tried to verify this results with any other lib yet. Here is my code and the result output:

const BN = require('bn.js');
const _elliptic = require('elliptic');

let curve, x1, x2, x3;

const s1 = 5;
const s2 = 7;

curve = _elliptic.curves.secp256k1.curve;

x1 = curve.g.mul(new BN(s1 * s2)).x.toString();
x2 = curve.g.mul(new BN(s1)).mul(new BN(s2)).x.toString();
x3 = curve.g.mul(new BN(s2)).mul(new BN(s1)).x.toString();

console.log('Secp256k1');
console.log('x1', x1);
console.log('x2', x2);
console.log('x3', x3);

if ( x1 !== x2 || x2 !== x3 ) throw "Secp256k1 is not working";

curve = _elliptic.curves.ed25519.curve;

x1 = curve.g.mul(new BN(s1 * s2)).x.toString();
x2 = curve.g.mul(new BN(s1)).mul(new BN(s2)).x.toString();
x3 = curve.g.mul(new BN(s2)).mul(new BN(s1)).x.toString();

console.log('Ed25519');
console.log('x1', x1);
console.log('x2', x2);
console.log('x3', x3);

if ( x1 !== x2 || x2 !== x3 ) throw "Ed25519 is not working";

Output

Secp256k1
x1 43584328072464330665967763306297595761508151294385275883849271528835646125177
x2 43584328072464330665967763306297595761508151294385275883849271528835646125177
x3 43584328072464330665967763306297595761508151294385275883849271528835646125177
Ed25519
x1 55273943480971088995773479464066134207989308286022701864858601428259859655314
x2 51135981228776515221048757123224307152351546728503975207995010098383940295622
x3 22416939968309503026374457194513247018475167317131809640455674209551101296110

/home/elliptic.js:33
if ( x1 !== x2 || x2 !== x3 ) throw "Ed25519 is not working";
                              ^
Ed25519 is not working
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant