Fixup curve25519 module
Rename methods on the curve25519 interface to be a bit more high level. Cleanup emscripten wrapper class, wrap long lines and such. Also add a grunt task alias for building the emscripten compiled curve implementation.
This commit is contained in:
parent
a1a528ccdd
commit
2f58ea5f3a
6 changed files with 74 additions and 51 deletions
|
@ -83,7 +83,7 @@
|
|||
throw new Error("Invalid private key");
|
||||
}
|
||||
|
||||
return curve25519().privToPub(privKey).then(function(raw_keys) {
|
||||
return curve25519().keyPair(privKey).then(function(raw_keys) {
|
||||
// prepend version byte
|
||||
var origPub = new Uint8Array(raw_keys.pubKey);
|
||||
var pub = new Uint8Array(33);
|
||||
|
@ -101,7 +101,7 @@
|
|||
if (pubKey === undefined || pubKey.byteLength != 32)
|
||||
throw new Error("Invalid public key");
|
||||
|
||||
return curve25519().ECDHE(pubKey, privKey);
|
||||
return curve25519().sharedSecret(pubKey, privKey);
|
||||
},
|
||||
Ed25519Sign: function(privKey, message) {
|
||||
if (privKey === undefined || privKey.byteLength != 32)
|
||||
|
@ -110,7 +110,7 @@
|
|||
if (message === undefined)
|
||||
throw new Error("Invalid message");
|
||||
|
||||
return curve25519().Ed25519Sign(privKey, message);
|
||||
return curve25519().sign(privKey, message);
|
||||
},
|
||||
Ed25519Verify: function(pubKey, msg, sig) {
|
||||
pubKey = validatePubKeyFormat(pubKey);
|
||||
|
@ -124,7 +124,7 @@
|
|||
if (sig === undefined || sig.byteLength != 64)
|
||||
throw new Error("Invalid signature");
|
||||
|
||||
return curve25519().Ed25519Verify(pubKey, msg, sig);
|
||||
return curve25519().verify(pubKey, msg, sig);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue