summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/sec/SecT131Field.cs
diff options
context:
space:
mode:
authorJeffrey Stedfast <jeff@xamarin.com>2015-10-11 10:26:27 -0400
committerJeffrey Stedfast <jeff@xamarin.com>2015-10-11 10:26:27 -0400
commitb2e562d4efdc221d10b08e9cba782057225ffc0e (patch)
treee1b19aa33900ae6070f2b89b2e6b0e46bd97d2b2 /crypto/src/math/ec/custom/sec/SecT131Field.cs
parentUpdated MimeKit.BouncyCastle.nuspec (diff)
parentPort of recent ISO trailer updates from Java (diff)
downloadBouncyCastle.NET-ed25519-b2e562d4efdc221d10b08e9cba782057225ffc0e.tar.xz
Merge branch 'master' into vs2010
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecT131Field.cs')
-rw-r--r--crypto/src/math/ec/custom/sec/SecT131Field.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecT131Field.cs b/crypto/src/math/ec/custom/sec/SecT131Field.cs
index 6a1d2a960..47f97078c 100644
--- a/crypto/src/math/ec/custom/sec/SecT131Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecT131Field.cs
@@ -40,6 +40,35 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return z;
         }
 
+        public static void Invert(ulong[] x, ulong[] z)
+        {
+            if (Nat192.IsZero64(x))
+                throw new InvalidOperationException();
+
+            // Itoh-Tsujii inversion
+
+            ulong[] t0 = Nat192.Create64();
+            ulong[] t1 = Nat192.Create64();
+
+            Square(x, t0);
+            Multiply(t0, x, t0);
+            SquareN(t0, 2, t1);
+            Multiply(t1, t0, t1);
+            SquareN(t1, 4, t0);
+            Multiply(t0, t1, t0);
+            SquareN(t0, 8, t1);
+            Multiply(t1, t0, t1);
+            SquareN(t1, 16, t0);
+            Multiply(t0, t1, t0);
+            SquareN(t0, 32, t1);
+            Multiply(t1, t0, t1);
+            Square(t1, t1);
+            Multiply(t1, x, t1);
+            SquareN(t1, 65, t0);
+            Multiply(t0, t1, t0);
+            Square(t0, z);
+        }
+
         public static void Multiply(ulong[] x, ulong[] y, ulong[] z)
         {
             ulong[] tt = Nat192.CreateExt64();