From 42e7197c46a7371e9e39d613772fa1d072b7cf74 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Wed, 4 Jun 2014 16:06:30 +1000 Subject: [PATCH] ec: define on use --- src/ec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ec.js b/src/ec.js index 47cdb49..5e37f32 100644 --- a/src/ec.js +++ b/src/ec.js @@ -95,11 +95,13 @@ function pointFpEquals(other) { if (other.isInfinity()) return this.isInfinity() // u = Y2 * Z1 - Y1 * Z2 - u = other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q) + var u = other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q) + if (u.signum() !== 0) return false // v = X2 * Z1 - X1 * Z2 - v = other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q) + var v = other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q) + return v.signum() === 0 }