summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/djb
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/math/ec/custom/djb')
-rw-r--r--crypto/src/math/ec/custom/djb/Curve25519.cs27
-rw-r--r--crypto/src/math/ec/custom/djb/Curve25519Point.cs15
2 files changed, 3 insertions, 39 deletions
diff --git a/crypto/src/math/ec/custom/djb/Curve25519.cs b/crypto/src/math/ec/custom/djb/Curve25519.cs

index 3dbdac051..712b68f29 100644 --- a/crypto/src/math/ec/custom/djb/Curve25519.cs +++ b/crypto/src/math/ec/custom/djb/Curve25519.cs
@@ -1,13 +1,12 @@ using System; using Org.BouncyCastle.Math.EC.Custom.Sec; -using Org.BouncyCastle.Math.Field; using Org.BouncyCastle.Utilities.Encoders; namespace Org.BouncyCastle.Math.EC.Custom.Djb { internal class Curve25519 - : ECCurve + : AbstractFpCurve { public static readonly BigInteger q = Nat256.ToBigInteger(Curve25519Field.P); @@ -16,7 +15,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Djb protected readonly Curve25519Point m_infinity; public Curve25519() - : base(FiniteFields.GetPrimeField(q)) + : base(q) { this.m_infinity = new Curve25519Point(this, null, null); @@ -74,27 +73,5 @@ namespace Org.BouncyCastle.Math.EC.Custom.Djb { return new Curve25519Point(this, x, y, zs, withCompression); } - - protected override ECPoint DecompressPoint(int yTilde, BigInteger X1) - { - ECFieldElement x = FromBigInteger(X1); - ECFieldElement alpha = x.Square().Add(A).Multiply(x).Add(B); - ECFieldElement beta = alpha.Sqrt(); - - // - // if we can't find a sqrt we haven't got a point on the - // curve - run! - // - if (beta == null) - throw new ArithmeticException("Invalid point compression"); - - if (beta.TestBitZero() != (yTilde == 1)) - { - // Use the other root - beta = beta.Negate(); - } - - return new Curve25519Point(this, x, beta, true); - } } } diff --git a/crypto/src/math/ec/custom/djb/Curve25519Point.cs b/crypto/src/math/ec/custom/djb/Curve25519Point.cs
index f3da59d16..bfec1d11d 100644 --- a/crypto/src/math/ec/custom/djb/Curve25519Point.cs +++ b/crypto/src/math/ec/custom/djb/Curve25519Point.cs
@@ -5,7 +5,7 @@ using Org.BouncyCastle.Math.EC.Custom.Sec; namespace Org.BouncyCastle.Math.EC.Custom.Djb { internal class Curve25519Point - : ECPointBase + : AbstractFpPoint { /** * Create a point which encodes with point compression. @@ -48,11 +48,6 @@ namespace Org.BouncyCastle.Math.EC.Custom.Djb return new Curve25519Point(null, AffineXCoord, AffineYCoord); } - protected internal override bool CompressionYTilde - { - get { return this.AffineYCoord.TestBitZero(); } - } - public override ECFieldElement GetZCoord(int index) { if (index == 1) @@ -224,14 +219,6 @@ namespace Org.BouncyCastle.Math.EC.Custom.Djb return TwiceJacobianModified(false).Add(this); } - public override ECPoint Subtract(ECPoint b) - { - if (b.IsInfinity) - return this; - - return Add(b.Negate()); - } - public override ECPoint Negate() { if (IsInfinity)