From e073ee3d46dc49b3a5c1b8b17a500b3596eb21fa Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 10 Apr 2015 11:07:08 +1000 Subject: [PATCH] ecdsa: avoid 2-line if statements --- src/ecdsa.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ecdsa.js b/src/ecdsa.js index c88add3..89d4d0d 100644 --- a/src/ecdsa.js +++ b/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 })