parent
53d878da8e
commit
69745567ff
|
@ -78,7 +78,7 @@ var getPublic = exports.getPublic = function(privateKey) {
|
||||||
exports.sign = function(privateKey, msg) {
|
exports.sign = function(privateKey, msg) {
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
assert(privateKey.length === 32, "Bad private key");
|
assert(privateKey.length === 32, "Bad private key");
|
||||||
resolve(new Buffer(ec.sign(msg, privateKey).toDER()));
|
resolve(new Buffer(ec.sign(msg, privateKey, {canonical: true}).toDER()));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
1
test.js
1
test.js
|
@ -89,6 +89,7 @@ describe("ECDSA", function() {
|
||||||
it("should allow to sign and verify messages less than 32 bytes", function() {
|
it("should allow to sign and verify messages less than 32 bytes", function() {
|
||||||
return eccrypto.sign(privateKey, shortMsg).then(function(sig) {
|
return eccrypto.sign(privateKey, shortMsg).then(function(sig) {
|
||||||
expect(Buffer.isBuffer(sig)).to.be.true;
|
expect(Buffer.isBuffer(sig)).to.be.true;
|
||||||
|
expect(sig.toString("hex")).to.equal("304402204737396b697e5a3400e3aedd203d8be89879f97708647252bd0c17752ff4c8f302201d52ef234de82ce0719679fa220334c83b80e21b8505a781d32d94a27d9310aa");
|
||||||
return eccrypto.verify(publicKey, shortMsg, sig);
|
return eccrypto.verify(publicKey, shortMsg, sig);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user