diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-09-29 08:51:20 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-09-29 08:51:20 +0400 |
commit | 3bc589c293b980b9fe54dff158e3abea5392c414 (patch) | |
tree | cf97bfbda0b458acf07695f977592004dd02fa62 /core/src/main/java/org/bouncycastle/math | |
parent | 8259ceab74961cb6ca7c657c527db670896d6334 (diff) |
getYCoord for lambda-projective coords needs to consider Z
Diffstat (limited to 'core/src/main/java/org/bouncycastle/math')
-rw-r--r-- | core/src/main/java/org/bouncycastle/math/ec/ECPoint.java | 26 |
1 files changed, 24 insertions, 2 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 3a6faf30..eb970173 100644 --- a/core/src/main/java/org/bouncycastle/math/ec/ECPoint.java +++ b/core/src/main/java/org/bouncycastle/math/ec/ECPoint.java @@ -1117,15 +1117,37 @@ public abstract class ECPoint public ECFieldElement getYCoord() { - switch (getCurveCoordinateSystem()) + int coord = getCurveCoordinateSystem(); + + switch (coord) { case ECCurve.COORD_LAMBDA_AFFINE: case ECCurve.COORD_LAMBDA_PROJECTIVE: + { + // TODO The X == 0 stuff needs further thought + if (isInfinity() || x.isZero()) + { + return y; + } + // Y is actually Lambda (X + Y/X) here; convert to affine value on the fly - return (isInfinity() || x.isZero()) ? y : y.subtract(x).multiply(x); + ECFieldElement X = x, L = y; + ECFieldElement Y = L.subtract(X).multiply(X); + if (ECCurve.COORD_LAMBDA_PROJECTIVE == coord) + { + ECFieldElement Z = zs[0]; + if (Z.bitLength() != 1) + { + Y = Y.divide(Z); + } + } + return Y; + } default: + { return y; } + } } protected boolean getCompressionYTilde() |