|
|
@ -104,7 +104,7 @@ function sign (curve, hash, d) { |
|
|
|
return new ECSignature(r, s) |
|
|
|
} |
|
|
|
|
|
|
|
function verifyRaw (curve, e, signature, Q) { |
|
|
|
function verify (curve, hash, signature, Q) { |
|
|
|
var n = curve.n |
|
|
|
var G = curve.G |
|
|
|
|
|
|
@ -115,6 +115,10 @@ function verifyRaw (curve, e, signature, Q) { |
|
|
|
if (r.signum() <= 0 || r.compareTo(n) >= 0) return false |
|
|
|
if (s.signum() <= 0 || s.compareTo(n) >= 0) return false |
|
|
|
|
|
|
|
// 1.4.2 H = Hash(M), already done by the user
|
|
|
|
// 1.4.3 e = H
|
|
|
|
var e = BigInteger.fromBuffer(hash) |
|
|
|
|
|
|
|
// Compute s^-1
|
|
|
|
var sInv = s.modInverse(n) |
|
|
|
|
|
|
@ -140,14 +144,6 @@ function verifyRaw (curve, e, signature, Q) { |
|
|
|
return v.equals(r) |
|
|
|
} |
|
|
|
|
|
|
|
function verify (curve, hash, signature, Q) { |
|
|
|
// 1.4.2 H = Hash(M), already done by the user
|
|
|
|
// 1.4.3 e = H
|
|
|
|
var e = BigInteger.fromBuffer(hash) |
|
|
|
|
|
|
|
return verifyRaw(curve, e, signature, Q) |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Recover a public key from a signature. |
|
|
|
* |
|
|
@ -227,6 +223,5 @@ module.exports = { |
|
|
|
deterministicGenerateK: deterministicGenerateK, |
|
|
|
recoverPubKey: recoverPubKey, |
|
|
|
sign: sign, |
|
|
|
verify: verify, |
|
|
|
verifyRaw: verifyRaw |
|
|
|
verify: verify |
|
|
|
} |
|
|
|