public void Symbol_BigValue_Test() { // secp256k1 prime BigInteger prime = BigInteger.Parse("115792089237316195423570985008687907853269984665640564039457584007908834671663"); Random rnd = new Random(); byte[] ba = new byte[32]; rnd.NextBytes(ba); BigInteger n = ba.ToBigInt(true, true); BigInteger ls = BigInteger.ModPow(n, (prime - 1) / 2, prime); int expected = (ls == prime - 1) ? -1 : (int)ls; int actual = Legendre.Symbol(n, prime); Assert.Equal(expected, actual); }
public void Symbol_ExceptionTest() { Assert.Throws <ArithmeticException>(() => Legendre.Symbol(2, 1)); }
public void SymbolTest(BigInteger n, BigInteger p, int expected) { int actual = Legendre.Symbol(n, p); Assert.Equal(expected, actual); }