diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-24 15:17:40 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-24 15:17:40 +0700 |
commit | 03a8f8b86524664d2d61076a5f81ebe402c404ff (patch) | |
tree | 0696c6b5a21d46e9ad2bd5e150e4c43214eb78c9 /crypto/src/math/ec/ECCurve.cs | |
parent | Optimization in ModReduce (diff) | |
download | BouncyCastle.NET-ed25519-03a8f8b86524664d2d61076a5f81ebe402c404ff.tar.xz |
Implementation of homogeneous coordinates for Fp
Various changes to point methods to deal with non-affine points Changes in client code and tests to apply point normalization
Diffstat (limited to 'crypto/src/math/ec/ECCurve.cs')
-rw-r--r-- | crypto/src/math/ec/ECCurve.cs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/crypto/src/math/ec/ECCurve.cs b/crypto/src/math/ec/ECCurve.cs index 38daa719c..d369cb2b7 100644 --- a/crypto/src/math/ec/ECCurve.cs +++ b/crypto/src/math/ec/ECCurve.cs @@ -99,6 +99,8 @@ namespace Org.BouncyCastle.Math.EC protected abstract ECCurve CloneCurve(); + protected internal abstract ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, bool withCompression); + protected virtual ECMultiplier CreateDefaultMultiplier() { return new WNafMultiplier(); @@ -145,7 +147,7 @@ namespace Org.BouncyCastle.Math.EC // TODO Default behaviour could be improved if the two curves have the same coordinate system by copying any Z coordinates. p = p.Normalize(); - return CreatePoint(p.X.ToBigInteger(), p.Y.ToBigInteger(), p.IsCompressed); + return CreatePoint(p.XCoord.ToBigInteger(), p.YCoord.ToBigInteger(), p.IsCompressed); } /** @@ -375,6 +377,20 @@ namespace Org.BouncyCastle.Math.EC return new FpCurve(m_q, m_r, m_a, m_b); } + public override bool SupportsCoordinateSystem(int coord) + { + switch (coord) + { + case COORD_AFFINE: + case COORD_HOMOGENEOUS: + //case COORD_JACOBIAN: + //case COORD_JACOBIAN_MODIFIED: + return true; + default: + return false; + } + } + public virtual BigInteger Q { get { return m_q; } @@ -395,6 +411,11 @@ namespace Org.BouncyCastle.Math.EC return new FpFieldElement(this.m_q, this.m_r, x); } + protected internal override ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, bool withCompression) + { + return new FpPoint(this, x, y, withCompression); + } + public override ECPoint CreatePoint( BigInteger X1, BigInteger Y1, @@ -710,6 +731,11 @@ namespace Org.BouncyCastle.Math.EC return base.CreateDefaultMultiplier(); } + protected internal override ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, bool withCompression) + { + return new F2mPoint(this, x, y, withCompression); + } + public override ECPoint Infinity { get { return m_infinity; } |