diff options
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() |