Skip to content

Commit

Permalink
ecdsa: use signum() over compareTo
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed May 24, 2014
1 parent 37d5147 commit bd1a08b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ecdsa.js
Expand Up @@ -64,15 +64,16 @@ function verifyRaw(ecparams, e, r, s, Q) {
var n = ecparams.getN()
var G = ecparams.getG()

if (r.compareTo(BigInteger.ONE) < 0 || r.compareTo(n) >= 0) {
if (r.signum() === 0 || r.compareTo(n) >= 0) {
return false
}

if (s.compareTo(BigInteger.ONE) < 0 || s.compareTo(n) >= 0) {
if (s.signum() === 0 || s.compareTo(n) >= 0) {
return false
}

var c = s.modInverse(n)

var u1 = e.multiply(c).mod(n)
var u2 = r.multiply(c).mod(n)

Expand Down

0 comments on commit bd1a08b

Please sign in to comment.