diff options
Diffstat (limited to 'crypto/src/pqc/crypto/bike/BikeRing.cs')
-rw-r--r-- | crypto/src/pqc/crypto/bike/BikeRing.cs | 28 |
1 files changed, 9 insertions, 19 deletions
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(); |