Browse Source

ec: compare strictly against null

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
dc3d9aec65
  1. 13
      src/ec.js

13
src/ec.js

@ -67,19 +67,14 @@ function ECPointFp(curve,x,y,z) {
// Projective coordinates: either zinv == null or z * zinv == 1 // Projective coordinates: either zinv == null or z * zinv == 1
// z and zinv are just BigIntegers, not fieldElements // z and zinv are just BigIntegers, not fieldElements
if (z == null) { this.z = (z == undefined) ? BigInteger.ONE : z
this.z = BigInteger.ONE
} else {
this.z = z
}
this.zinv = null this.zinv = null
//TODO: compression flag //TODO: compression flag
} }
function pointFpGetX() { function pointFpGetX() {
if (this.zinv == null) { if (this.zinv === null) {
this.zinv = this.z.modInverse(this.curve.q) this.zinv = this.z.modInverse(this.curve.q)
} }
@ -87,7 +82,7 @@ function pointFpGetX() {
} }
function pointFpGetY() { function pointFpGetY() {
if (this.zinv == null) { if (this.zinv === null) {
this.zinv = this.z.modInverse(this.curve.q) this.zinv = this.z.modInverse(this.curve.q)
} }
@ -109,7 +104,7 @@ function pointFpEquals(other) {
} }
function pointFpIsInfinity() { function pointFpIsInfinity() {
if ((this.x == null) && (this.y == null)) return true if ((this.x === null) && (this.y === null)) return true
return this.z.signum() === 0 && this.y.toBigInteger().signum() !== 0 return this.z.signum() === 0 && this.y.toBigInteger().signum() !== 0
} }

Loading…
Cancel
Save