diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-09-28 18:05:16 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-09-28 18:05:16 +0400 |
commit | f4f32676b75a63a20c8234d782a386ebb8e6d520 (patch) | |
tree | 3d35751970eff6f7d8a3ce59f52035f5755cb156 /core/src/main/java/org/bouncycastle/math | |
parent | ba977669039e136cfd9ba56f99d87b1abbef0646 (diff) |
An F2m point with X == 0 is its own additive inverse
Diffstat (limited to 'core/src/main/java/org/bouncycastle/math')
-rw-r--r-- | core/src/main/java/org/bouncycastle/math/ec/ECPoint.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/src/main/java/org/bouncycastle/math/ec/ECPoint.java b/core/src/main/java/org/bouncycastle/math/ec/ECPoint.java index 121f4f44..2529bf71 100644 --- a/core/src/main/java/org/bouncycastle/math/ec/ECPoint.java +++ b/core/src/main/java/org/bouncycastle/math/ec/ECPoint.java @@ -1388,22 +1388,28 @@ public abstract class ECPoint return this; } - ECFieldElement X = this.x, Y = this.y; + ECFieldElement X = this.x; + if (X.isZero()) + { + return this; + } switch (getCurveCoordinateSystem()) { case ECCurve.COORD_AFFINE: { + ECFieldElement Y = this.y; return new ECPoint.F2m(curve, X, Y.add(X), withCompression); } case ECCurve.COORD_LAMBDA_AFFINE: { - return new ECPoint.F2m(curve, X, Y.addOne(), withCompression); + ECFieldElement L = this.y; + return new ECPoint.F2m(curve, X, L.addOne(), withCompression); } case ECCurve.COORD_LAMBDA_PROJECTIVE: { - // Y is actually Lambda (X + Y/X) here - ECFieldElement L = Y, Z = this.zs[0]; + // L is actually Lambda (X + Y/X) here + ECFieldElement L = this.y, Z = this.zs[0]; return new ECPoint.F2m(curve, X, L.add(Z), new ECFieldElement[]{ Z }, withCompression); } default: |