Pass null
instead of undefined
on .verify
This commit is contained in:
parent
177c10433d
commit
0101427024
|
@ -110,7 +110,7 @@ eccrypto.encrypt(publicKeyA, Buffer("msg to a")).then(function(encrypted) {
|
||||||
|
|
||||||
eccrypto - JavaScript Elliptic curve cryptography library
|
eccrypto - JavaScript Elliptic curve cryptography library
|
||||||
|
|
||||||
Written in 2014 by Kagami Hiiragi <kagami@genshiken.org>
|
Written in 2014-2015 by Kagami Hiiragi <kagami@genshiken.org>
|
||||||
|
|
||||||
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
|
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ exports.verify = function(publicKey, msg, sig) {
|
||||||
assert(msg.length > 0, "Message should not be empty");
|
assert(msg.length > 0, "Message should not be empty");
|
||||||
assert(msg.length <= 32, "Message is too long");
|
assert(msg.length <= 32, "Message is too long");
|
||||||
if (ec.verify(msg, sig, publicKey)) {
|
if (ec.verify(msg, sig, publicKey)) {
|
||||||
resolve();
|
resolve(null);
|
||||||
} else {
|
} else {
|
||||||
reject(new Error("Bad signature"));
|
reject(new Error("Bad signature"));
|
||||||
}
|
}
|
||||||
|
|
6
index.js
6
index.js
|
@ -82,15 +82,15 @@ exports.sign = function(privateKey, msg) {
|
||||||
* @param {Buffer} publicKey - A 65-byte public key
|
* @param {Buffer} publicKey - A 65-byte public key
|
||||||
* @param {Buffer} msg - The message being verified
|
* @param {Buffer} msg - The message being verified
|
||||||
* @param {Buffer} sig - The signature
|
* @param {Buffer} sig - The signature
|
||||||
* @return {Promise.<undefined>} A promise that resolves on correct
|
* @return {Promise.<null>} A promise that resolves on correct signature
|
||||||
* signature and rejects on bad key or signature.
|
* and rejects on bad key or signature.
|
||||||
*/
|
*/
|
||||||
exports.verify = function(publicKey, msg, sig) {
|
exports.verify = function(publicKey, msg, sig) {
|
||||||
return new promise(function(resolve, reject) {
|
return new promise(function(resolve, reject) {
|
||||||
assert(msg.length > 0, "Message should not be empty");
|
assert(msg.length > 0, "Message should not be empty");
|
||||||
assert(msg.length <= 32, "Message is too long");
|
assert(msg.length <= 32, "Message is too long");
|
||||||
if (secp256k1.verify(publicKey, msg, sig) === 1) {
|
if (secp256k1.verify(publicKey, msg, sig) === 1) {
|
||||||
resolve();
|
resolve(null);
|
||||||
} else {
|
} else {
|
||||||
reject(new Error("Bad signature"));
|
reject(new Error("Bad signature"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user