pkg: update bcrypto.
This commit is contained in:
parent
1cf34273b3
commit
bd76939f4c
@ -142,36 +142,32 @@ class BIP150 extends EventEmitter {
|
||||
this.emit('auth');
|
||||
}
|
||||
|
||||
const sig = secp256k1.sign(msg, this.privateKey);
|
||||
|
||||
// authreply
|
||||
return secp256k1.fromDER(sig);
|
||||
return secp256k1.sign(msg, this.privateKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a received reply signature.
|
||||
* Returns an authpropose hash.
|
||||
* @param {Buffer} data
|
||||
* @param {Buffer} sig
|
||||
* @returns {Buffer}
|
||||
* @throws on auth failure
|
||||
*/
|
||||
|
||||
reply(data) {
|
||||
reply(sig) {
|
||||
const type = this.outbound ? 'i' : 'r';
|
||||
|
||||
assert(this.challengeSent, 'Unsolicited reply.');
|
||||
assert(!this.replyReceived, 'Peer replied twice.');
|
||||
this.replyReceived = true;
|
||||
|
||||
if (data.equals(common.ZERO_SIG))
|
||||
if (sig.equals(common.ZERO_SIG))
|
||||
throw new Error('Auth failure.');
|
||||
|
||||
if (!this.peerIdentity)
|
||||
return random.randomBytes(32);
|
||||
|
||||
const sig = secp256k1.toDER(data);
|
||||
const msg = this.hash(this.output.sid, type, this.peerIdentity);
|
||||
|
||||
const result = secp256k1.verify(msg, sig, this.peerIdentity);
|
||||
|
||||
if (!result)
|
||||
|
||||
@ -2105,7 +2105,7 @@ class RPC extends RPCBase {
|
||||
const msg = Buffer.from(MAGIC_STRING + str, 'utf8');
|
||||
const hash = hash256.digest(msg);
|
||||
|
||||
const key = secp256k1.recover(hash, sig, 0, true);
|
||||
const key = secp256k1.recoverDER(hash, sig, 0, true);
|
||||
|
||||
if (!key)
|
||||
return false;
|
||||
|
||||
@ -678,7 +678,7 @@ class KeyRing {
|
||||
|
||||
sign(msg) {
|
||||
assert(this.privateKey, 'Cannot sign without private key.');
|
||||
return secp256k1.sign(msg, this.privateKey);
|
||||
return secp256k1.signDER(msg, this.privateKey);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -689,7 +689,7 @@ class KeyRing {
|
||||
*/
|
||||
|
||||
verify(msg, sig) {
|
||||
return secp256k1.verify(msg, sig, this.publicKey);
|
||||
return secp256k1.verifyDER(msg, sig, this.publicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -710,7 +710,7 @@ class TX {
|
||||
const type = sig[sig.length - 1];
|
||||
const hash = this.signatureHash(index, prev, value, type, version);
|
||||
|
||||
return secp256k1.verify(hash, sig.slice(0, -1), key);
|
||||
return secp256k1.verifyDER(hash, sig.slice(0, -1), key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -734,7 +734,7 @@ class TX {
|
||||
version = 0;
|
||||
|
||||
const hash = this.signatureHash(index, prev, value, type, version);
|
||||
const sig = secp256k1.sign(hash, key);
|
||||
const sig = secp256k1.signDER(hash, key);
|
||||
const bw = bio.write(sig.length + 1);
|
||||
|
||||
bw.writeBytes(sig);
|
||||
|
||||
@ -497,7 +497,7 @@ exports.isLowDER = function isLowDER(sig) {
|
||||
if (!exports.isSignatureEncoding(sig))
|
||||
return false;
|
||||
|
||||
return secp256k1.isLowS(sig.slice(0, -1));
|
||||
return secp256k1.isLowDER(sig.slice(0, -1));
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -3453,7 +3453,7 @@ function validateSignature(sig, flags) {
|
||||
*/
|
||||
|
||||
function checksig(msg, sig, key) {
|
||||
return secp256k1.verify(msg, sig.slice(0, -1), key);
|
||||
return secp256k1.verifyDER(msg, sig.slice(0, -1), key);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -100,14 +100,14 @@ class SigCache {
|
||||
|
||||
verify(msg, sig, key) {
|
||||
if (this.size === 0)
|
||||
return secp256k1.verify(msg, sig, key);
|
||||
return secp256k1.verifyDER(msg, sig, key);
|
||||
|
||||
const hash = msg.toString('hex');
|
||||
|
||||
if (this.has(hash, sig, key))
|
||||
return true;
|
||||
|
||||
const result = secp256k1.verify(msg, sig, key);
|
||||
const result = secp256k1.verifyDER(msg, sig, key);
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
@ -142,7 +142,7 @@ jobs.signInput = function signInput(tx, index, coin, ring, type) {
|
||||
*/
|
||||
|
||||
jobs.ecVerify = function ecVerify(msg, sig, key) {
|
||||
const result = secp256k1.verify(msg, sig, key);
|
||||
const result = secp256k1.verifyDER(msg, sig, key);
|
||||
return new packets.ECVerifyResultPacket(result);
|
||||
};
|
||||
|
||||
@ -156,7 +156,7 @@ jobs.ecVerify = function ecVerify(msg, sig, key) {
|
||||
*/
|
||||
|
||||
jobs.ecSign = function ecSign(msg, key) {
|
||||
const sig = secp256k1.sign(msg, key);
|
||||
const sig = secp256k1.signDER(msg, key);
|
||||
return new packets.ECSignResultPacket(sig);
|
||||
};
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
"dependencies": {
|
||||
"bcfg": "~0.0.1",
|
||||
"bclient": "~0.0.1",
|
||||
"bcrypto": "~0.0.2",
|
||||
"bcrypto": "~0.1.0",
|
||||
"bdb": "~0.0.2",
|
||||
"bdns": "~0.0.1",
|
||||
"bevent": "~0.0.1",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user