summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/pqc/crypto/bike/BikeEngine.cs13
-rw-r--r--crypto/src/pqc/crypto/bike/BikeRing.cs7
2 files changed, 5 insertions, 15 deletions
diff --git a/crypto/src/pqc/crypto/bike/BikeEngine.cs b/crypto/src/pqc/crypto/bike/BikeEngine.cs
index a6371b726..e50546b75 100644
--- a/crypto/src/pqc/crypto/bike/BikeEngine.cs
+++ b/crypto/src/pqc/crypto/bike/BikeEngine.cs
@@ -270,7 +270,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
             bikeRing.DecodeBytes(h0, h0Element);
             ulong[] sElement = bikeRing.Create();
             bikeRing.Multiply(c0Element, h0Element, sElement);
-            return Transpose(bikeRing.EncodeBits(sElement));
+            return bikeRing.EncodeBitsTransposed(sElement);
         }
 
         private byte[] BGFDecoder(byte[] s, int[] h0Compact, int[] h1Compact)
@@ -308,17 +308,6 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
             return null;
         }
 
-        private byte[] Transpose(byte[] input)
-        {
-            byte[] output = new byte[r];
-            output[0] = input[0];
-            for (int i = 1; i < r; i++)
-            {
-                output[i] = input[r - i];
-            }
-            return output;
-        }
-
         private void BFIter(byte[] s, byte[] e, int T, int[] h0Compact, int[] h1Compact, int[] h0CompactCol,
             int[] h1CompactCol, uint[] black, uint[] gray, byte[] ctrs)
         {
diff --git a/crypto/src/pqc/crypto/bike/BikeRing.cs b/crypto/src/pqc/crypto/bike/BikeRing.cs
index ea023e004..7455fac06 100644
--- a/crypto/src/pqc/crypto/bike/BikeRing.cs
+++ b/crypto/src/pqc/crypto/bike/BikeRing.cs
@@ -82,12 +82,13 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
             Debug.Assert((z[Size - 1] >> partialBits) == 0UL);
         }
 
-        internal byte[] EncodeBits(ulong[] x)
+        internal byte[] EncodeBitsTransposed(ulong[] x)
         {
             byte[] bs = new byte[m_bits];
-            for (int i = 0; i < m_bits; ++i)
+            bs[0] = (byte)(x[0] & 1UL);
+            for (int i = 1; i < m_bits; ++i)
             {
-                bs[i] = (byte)((x[i >> 6] >> (i & 63)) & 1UL);
+                bs[m_bits - i] = (byte)((x[i >> 6] >> (i & 63)) & 1UL);
             }
             return bs;
         }