summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/math/ec/ECFieldElement.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/src/math/ec/ECFieldElement.cs b/crypto/src/math/ec/ECFieldElement.cs
index c2754ada8..22cd1e0e8 100644
--- a/crypto/src/math/ec/ECFieldElement.cs
+++ b/crypto/src/math/ec/ECFieldElement.cs
@@ -11,6 +11,7 @@ namespace Org.BouncyCastle.Math.EC
         public abstract string FieldName { get; }
         public abstract int FieldSize { get; }
         public abstract ECFieldElement Add(ECFieldElement b);
+        public abstract ECFieldElement AddOne();
         public abstract ECFieldElement Subtract(ECFieldElement b);
         public abstract ECFieldElement Multiply(ECFieldElement b);
         public abstract ECFieldElement Divide(ECFieldElement b);
@@ -146,6 +147,16 @@ namespace Org.BouncyCastle.Math.EC
             return new FpFieldElement(q, r, ModAdd(x, b.ToBigInteger()));
         }
 
+        public override ECFieldElement AddOne()
+        {
+            BigInteger x2 = x.Add(BigInteger.One);
+            if (x2.CompareTo(q) == 0)
+            {
+                x2 = BigInteger.Zero;
+            }
+            return new FpFieldElement(q, r, x2);
+        }
+
         public override ECFieldElement Subtract(
             ECFieldElement b)
         {
@@ -1104,6 +1115,11 @@ namespace Org.BouncyCastle.Math.EC
             return new F2mFieldElement(m, ks, iarrClone);
         }
 
+        public override ECFieldElement AddOne()
+        {
+            return new F2mFieldElement(m, ks, x.AddOne());
+        }
+
         public override ECFieldElement Subtract(
             ECFieldElement b)
         {