summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/pqc/crypto/bike/BikeEngine.cs1
-rw-r--r--crypto/src/pqc/crypto/bike/BikeKeyPairGenerator.cs20
-rw-r--r--crypto/src/pqc/crypto/bike/BikeRing.cs28
3 files changed, 20 insertions, 29 deletions
diff --git a/crypto/src/pqc/crypto/bike/BikeEngine.cs b/crypto/src/pqc/crypto/bike/BikeEngine.cs
index 56c60f90a..f7c126c66 100644
--- a/crypto/src/pqc/crypto/bike/BikeEngine.cs
+++ b/crypto/src/pqc/crypto/bike/BikeEngine.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Diagnostics;
+
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
 using Org.BouncyCastle.Security;
diff --git a/crypto/src/pqc/crypto/bike/BikeKeyPairGenerator.cs b/crypto/src/pqc/crypto/bike/BikeKeyPairGenerator.cs
index 5636458fd..f621306bc 100644
--- a/crypto/src/pqc/crypto/bike/BikeKeyPairGenerator.cs
+++ b/crypto/src/pqc/crypto/bike/BikeKeyPairGenerator.cs
@@ -12,22 +12,22 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
         private int r;
 
         // the row weight
-        private int w;
+        //private int w;
 
         // Hamming weight of h0, h1
-        private int hw;
+        //private int hw;
 
         // the error weight
-        private int t;
+        //private int t;
 
         //the shared secret size
         private int l;
 
         // number of iterations in BGF decoder
-        private int nbIter;
+        //private int nbIter;
 
         // tau
-        private int tau;
+        //private int tau;
         private int L_BYTE;
         private int R_BYTE;
 
@@ -40,12 +40,12 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
 
             // get parameters
             this.r = this.bikeKeyGenerationParameters.Parameters.R;
-            this.w = this.bikeKeyGenerationParameters.Parameters.W;
+            //this.w = this.bikeKeyGenerationParameters.Parameters.W;
             this.l = this.bikeKeyGenerationParameters.Parameters.L;
-            this.t = this.bikeKeyGenerationParameters.Parameters.T;
-            this.nbIter = this.bikeKeyGenerationParameters.Parameters.NbIter;
-            this.tau = this.bikeKeyGenerationParameters.Parameters.Tau;
-            this.hw = w / 2;
+            //this.t = this.bikeKeyGenerationParameters.Parameters.T;
+            //this.nbIter = this.bikeKeyGenerationParameters.Parameters.NbIter;
+            //this.tau = this.bikeKeyGenerationParameters.Parameters.Tau;
+            //this.hw = w / 2;
             this.L_BYTE = l / 8;
             this.R_BYTE = (r + 7) / 8;
         }
diff --git a/crypto/src/pqc/crypto/bike/BikeRing.cs b/crypto/src/pqc/crypto/bike/BikeRing.cs
index 9d317fa4b..a519595af 100644
--- a/crypto/src/pqc/crypto/bike/BikeRing.cs
+++ b/crypto/src/pqc/crypto/bike/BikeRing.cs
@@ -56,23 +56,6 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
             return new ulong[SizeExt];
         }
 
-        internal ulong[] DecodeBits(byte[] bs)
-        {
-            if (bs.Length > m_bits)
-                throw new ArgumentException();
-
-            ulong[] z = Create();
-            for (int i = 0; i < bs.Length; ++i)
-            {
-                ulong bit = bs[i];
-                if ((bit >> 1) != 0UL)
-                    throw new ArgumentException();
-
-                z[i >> 6] |= bit << (i & 63);
-            }
-            return z;
-        }
-
         internal void DecodeBytes(byte[] bs, ulong[] z)
         {
             int partialBits = m_bits & 63;
@@ -80,7 +63,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
             byte[] last = new byte[8];
             Array.Copy(bs, (Size - 1) << 3, last, 0, (partialBits + 7) >> 3);
             z[Size - 1] = Pack.LE_To_UInt64(last);
-            Debug.Assert((z[Size - 1] >> partialBits) == 0);
+            Debug.Assert((z[Size - 1] >> partialBits) == 0UL);
         }
 
         internal byte[] EncodeBits(ulong[] x)
@@ -96,7 +79,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
         internal void EncodeBytes(ulong[] x, byte[] bs)
         {
             int partialBits = m_bits & 63;
-            Debug.Assert((x[Size - 1] >> partialBits) == 0);
+            Debug.Assert((x[Size - 1] >> partialBits) == 0UL);
             Pack.UInt64_To_LE(x, 0, Size - 1, bs, 0);
             byte[] last = new byte[8];
             Pack.UInt64_To_LE(x[Size - 1], last);
@@ -189,6 +172,13 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
 
         internal void SquareN(ulong[] x, int n, ulong[] z)
         {
+            /*
+             * TODO In these polynomial rings, 'squareN' for some 'n' is equivalent to a fixed permutation of the
+             * coefficients. For 'squareN' with 'n' above some cutoff value, this permutation could be precomputed
+             * and then applied in place of explicit squaring for that 'n'. This is particularly relevant to the
+             * calls generated by 'inv'.
+             */
+
             Debug.Assert(n > 0);
 
             ulong[] tt = CreateExt();