summary refs log tree commit diff
path: root/crypto/src/math
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-28 10:15:14 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-28 10:15:14 +0700
commit58f42b0ee783704cb8d2ce3b22a053f8c4f0daa8 (patch)
treeeb7fcbdaf10650e10cc9299b43e67d7d321e97f9 /crypto/src/math
parentPort from Java order/cofactor for all curves (diff)
downloadBouncyCastle.NET-ed25519-58f42b0ee783704cb8d2ce3b22a053f8c4f0daa8.tar.xz
Port point-detaching stuff from Java
Diffstat (limited to 'crypto/src/math')
-rw-r--r--crypto/src/math/ec/ECPoint.cs17
-rw-r--r--crypto/src/math/ec/custom/sec/SecP256K1Point.cs5
-rw-r--r--crypto/src/math/ec/custom/sec/SecP256R1Point.cs5
3 files changed, 27 insertions, 0 deletions
diff --git a/crypto/src/math/ec/ECPoint.cs b/crypto/src/math/ec/ECPoint.cs
index 8f0168e27..89bd788ae 100644
--- a/crypto/src/math/ec/ECPoint.cs
+++ b/crypto/src/math/ec/ECPoint.cs
@@ -66,11 +66,18 @@ namespace Org.BouncyCastle.Math.EC
             this.m_withCompression = withCompression;
         }
 
+        public ECPoint GetDetachedPoint()
+        {
+            return Normalize().Detach();
+        }
+
         public virtual ECCurve Curve
         {
             get { return m_curve; }
         }
 
+        protected abstract ECPoint Detach();
+
         protected virtual int CurveCoordinateSystem
         {
             get
@@ -513,6 +520,11 @@ namespace Org.BouncyCastle.Math.EC
         {
         }
 
+        protected override ECPoint Detach()
+        {
+            return new FpPoint(null, AffineXCoord, AffineYCoord);
+        }
+
         protected internal override bool CompressionYTilde
         {
             get { return this.AffineYCoord.TestBitZero(); }
@@ -1174,6 +1186,11 @@ namespace Org.BouncyCastle.Math.EC
         {
         }
 
+        protected override ECPoint Detach()
+        {
+            return new F2mPoint(null, AffineXCoord, AffineYCoord);
+        }
+
         public override ECFieldElement YCoord
         {
             get
diff --git a/crypto/src/math/ec/custom/sec/SecP256K1Point.cs b/crypto/src/math/ec/custom/sec/SecP256K1Point.cs
index 548db535c..d981911a6 100644
--- a/crypto/src/math/ec/custom/sec/SecP256K1Point.cs
+++ b/crypto/src/math/ec/custom/sec/SecP256K1Point.cs
@@ -50,6 +50,11 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         {
         }
 
+        protected override ECPoint Detach()
+        {
+            return new SecP256K1Point(null, AffineXCoord, AffineYCoord);
+        }
+
         protected internal override bool CompressionYTilde
         {
             get { return this.AffineYCoord.TestBitZero(); }
diff --git a/crypto/src/math/ec/custom/sec/SecP256R1Point.cs b/crypto/src/math/ec/custom/sec/SecP256R1Point.cs
index 11e79678f..be54e0dda 100644
--- a/crypto/src/math/ec/custom/sec/SecP256R1Point.cs
+++ b/crypto/src/math/ec/custom/sec/SecP256R1Point.cs
@@ -49,6 +49,11 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
         {
         }
 
+        protected override ECPoint Detach()
+        {
+            return new SecP256R1Point(null, AffineXCoord, AffineYCoord);
+        }
+
         protected internal override bool CompressionYTilde
         {
             get { return this.AffineYCoord.TestBitZero(); }