ecdsa: avoid 2-line if statements
This commit is contained in:
parent
225cee8522
commit
e073ee3d46
1 changed files with 4 additions and 8 deletions
12
src/ecdsa.js
12
src/ecdsa.js
|
@ -75,25 +75,21 @@ function deterministicGenerateK (curve, hash, d, checkSig) {
|
|||
}
|
||||
|
||||
function sign (curve, hash, d) {
|
||||
var r, s
|
||||
|
||||
var e = BigInteger.fromBuffer(hash)
|
||||
var n = curve.n
|
||||
var G = curve.G
|
||||
|
||||
var r, s
|
||||
deterministicGenerateK(curve, hash, d, function (k) {
|
||||
var Q = G.multiply(k)
|
||||
|
||||
if (curve.isInfinity(Q))
|
||||
return false
|
||||
if (curve.isInfinity(Q)) return false
|
||||
|
||||
r = Q.affineX.mod(n)
|
||||
if (r.signum() === 0)
|
||||
return false
|
||||
if (r.signum() === 0) return false
|
||||
|
||||
s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n)
|
||||
if (s.signum() === 0)
|
||||
return false
|
||||
if (s.signum() === 0) return false
|
||||
|
||||
return true
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue