From cee55871207a3dd10f001ce89bfc91e86a51b4e3 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 5 Mar 2023 10:44:39 -0600 Subject: [PATCH] add unit test for primefield infinite loop --- tests/Unit/Math/PrimeFieldTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/Unit/Math/PrimeFieldTest.php diff --git a/tests/Unit/Math/PrimeFieldTest.php b/tests/Unit/Math/PrimeFieldTest.php new file mode 100644 index 00000000..24ecfabd --- /dev/null +++ b/tests/Unit/Math/PrimeFieldTest.php @@ -0,0 +1,23 @@ +expectException('UnexpectedValueException'); + + $a = new BigInteger('65', 10); + $p = new BigInteger('126', 10); // 126 isn't a prime + + $num = new PrimeField($p); + $num2 = $num->newInteger($a); + + echo $num2->squareRoot(); + } +}