diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-26 14:59:53 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-26 14:59:53 +0700 |
commit | a16317d05fdd83e875e5fd744e1efd32c04bdf3f (patch) | |
tree | ec40b380a0c6c3cb9da8eff65282fe7fa0b2657e /crypto | |
parent | Port of jacobian/-modified coordinates from Java (diff) | |
download | BouncyCastle.NET-ed25519-a16317d05fdd83e875e5fd744e1efd32c04bdf3f.tar.xz |
Refactor DecompressPoint
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/math/ec/ECCurve.cs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/crypto/src/math/ec/ECCurve.cs b/crypto/src/math/ec/ECCurve.cs index 4b58d7626..fb12f0475 100644 --- a/crypto/src/math/ec/ECCurve.cs +++ b/crypto/src/math/ec/ECCurve.cs @@ -442,12 +442,10 @@ namespace Org.BouncyCastle.Math.EC return base.ImportPoint(p); } - protected override ECPoint DecompressPoint( - int yTilde, - BigInteger X1) + protected override ECPoint DecompressPoint(int yTilde, BigInteger X1) { ECFieldElement x = FromBigInteger(X1); - ECFieldElement alpha = x.Multiply(x.Square().Add(m_a)).Add(m_b); + ECFieldElement alpha = x.Square().Add(m_a).Multiply(x).Add(m_b); ECFieldElement beta = alpha.Sqrt(); // @@ -457,10 +455,7 @@ namespace Org.BouncyCastle.Math.EC if (beta == null) throw new ArithmeticException("Invalid point compression"); - BigInteger betaValue = beta.ToBigInteger(); - int bit0 = betaValue.TestBit(0) ? 1 : 0; - - if (bit0 != yTilde) + if (beta.TestBitZero() != (yTilde == 1)) { // Use the other root beta = beta.Negate(); |