Skip to content

Commit 4c030be

Browse files
committed
ecdsa: remove unused verifyRaw
1 parent a221bd1 commit 4c030be

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

src/ecdsa.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function sign (curve, hash, d) {
104104
return new ECSignature(r, s)
105105
}
106106

107-
function verifyRaw (curve, e, signature, Q) {
107+
function verify (curve, hash, signature, Q) {
108108
var n = curve.n
109109
var G = curve.G
110110

@@ -115,6 +115,10 @@ function verifyRaw (curve, e, signature, Q) {
115115
if (r.signum() <= 0 || r.compareTo(n) >= 0) return false
116116
if (s.signum() <= 0 || s.compareTo(n) >= 0) return false
117117

118+
// 1.4.2 H = Hash(M), already done by the user
119+
// 1.4.3 e = H
120+
var e = BigInteger.fromBuffer(hash)
121+
118122
// Compute s^-1
119123
var sInv = s.modInverse(n)
120124

@@ -140,14 +144,6 @@ function verifyRaw (curve, e, signature, Q) {
140144
return v.equals(r)
141145
}
142146

143-
function verify (curve, hash, signature, Q) {
144-
// 1.4.2 H = Hash(M), already done by the user
145-
// 1.4.3 e = H
146-
var e = BigInteger.fromBuffer(hash)
147-
148-
return verifyRaw(curve, e, signature, Q)
149-
}
150-
151147
/**
152148
* Recover a public key from a signature.
153149
*
@@ -227,6 +223,5 @@ module.exports = {
227223
deterministicGenerateK: deterministicGenerateK,
228224
recoverPubKey: recoverPubKey,
229225
sign: sign,
230-
verify: verify,
231-
verifyRaw: verifyRaw
226+
verify: verify
232227
}

test/ecdsa.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -158,30 +158,26 @@ describe('ecdsa', function () {
158158
})
159159
})
160160

161-
describe('verify/verifyRaw', function () {
161+
describe('verify', function () {
162162
fixtures.valid.ecdsa.forEach(function (f) {
163163
it('verifies a valid signature for "' + f.message + '"', function () {
164164
var d = BigInteger.fromHex(f.d)
165165
var H = crypto.sha256(f.message)
166-
var e = BigInteger.fromBuffer(H)
167166
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
168167
var Q = curve.G.multiply(d)
169168

170169
assert(ecdsa.verify(curve, H, signature, Q))
171-
assert(ecdsa.verifyRaw(curve, e, signature, Q))
172170
})
173171
})
174172

175-
fixtures.invalid.verifyRaw.forEach(function (f) {
173+
fixtures.invalid.verify.forEach(function (f) {
176174
it('fails to verify with ' + f.description, function () {
177175
var H = crypto.sha256(f.message)
178-
var e = BigInteger.fromBuffer(H)
179176
var d = BigInteger.fromHex(f.d)
180177
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
181178
var Q = curve.G.multiply(d)
182179

183180
assert.equal(ecdsa.verify(curve, H, signature, Q), false)
184-
assert.equal(ecdsa.verifyRaw(curve, e, signature, Q), false)
185181
})
186182
})
187183
})

test/fixtures/ecdsa.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
"i": 4
219219
}
220220
],
221-
"verifyRaw": [
221+
"verify": [
222222
{
223223
"description": "The wrong signature",
224224
"d": "01",

0 commit comments

Comments
 (0)