Skip to content

Commit

Permalink
Add unique key pair test for ed25519.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed May 6, 2023
1 parent 2bb97af commit 8d221c9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/unit/ed25519.js
Expand Up @@ -30,7 +30,21 @@ var UTIL = require('../../lib/util');
ASSERT.equal(privateKey, b64PrivateKey);
ASSERT.equal(publicKey, b64PublicKey);
});

it('should generate a unique key pair for each seed', function() {
let _pwd = 'password';
let md = SHA256.create();
md.update(_pwd, 'utf8');
let seed = md.digest().getBytes();
let kp = ED25519.generateKeyPair({seed: seed});

md = SHA256.create();
md.update(_pwd + '!', 'utf8'); // << different password
let seed2 = md.digest().getBytes();
let kp2 = ED25519.generateKeyPair({ seed: seed2 });
ASSERT.notEqual(seed, seed2);
ASSERT.notEqual(kp.privateKey, kp2.privateKey);
ASSERT.notEqual(kp.publicKey, kp2.publicKey);
});
it('should get a public key from a private key', function() {
var privateKey = db64(b64PrivateKey);
var publicKey = ED25519.publicKeyFromPrivateKey({
Expand Down

0 comments on commit 8d221c9

Please sign in to comment.