private void InvertFq() { // Verify an example from the NTRU tutorial IntegerPolynomial a = new IntegerPolynomial(new int[] { -1, 1, 1, 0, -1, 0, 1, 0, 0, 1, -1 }); IntegerPolynomial b = a.InvertFq(32); AssertEqualsMod(new int[] { 5, 9, 6, 16, 4, 15, 16, 22, 20, 18, 30 }, b.Coeffs, 32); VerifyInverse(a, b, 32); // test 3 random polynomials int numInvertible = 0; while (numInvertible < 3) { a = (IntegerPolynomial)PolynomialGeneratorForTesting.generateRandom(853); b = a.InvertFq(2048); if (b != null) { numInvertible++; VerifyInverse(a, b, 2048); } } // test a non-invertible polynomial a = new IntegerPolynomial(new int[] { -1, 0, 1, 1, 0, 0, -1, 0, -1, 0, 1 }); b = a.InvertFq(32); if (b != null) throw new Exception("IntegerPolynomialTest InvertFq test failed!"); }