tests: add tests for ecdsa.verify
This commit is contained in:
parent
98bc1685b3
commit
10630873eb
3 changed files with 24 additions and 20 deletions
src
16
src/ecdsa.js
16
src/ecdsa.js
|
@ -76,14 +76,6 @@ function sign(curve, hash, d) {
|
|||
return new ECSignature(r, s)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
function verifyRaw(curve, e, signature, Q) {
|
||||
var n = curve.n
|
||||
var G = curve.G
|
||||
|
@ -114,6 +106,14 @@ 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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue