Skip to content

Commit

Permalink
Add test case for #30 - Euler's criterion doesn't return 1 for a square
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Jun 20, 2020
1 parent 0400187 commit 988f6b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/t_finite_fields_powinv.nim
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,13 @@ proc main() =
testRandomInv BLS12_461
testRandomInv BN462

suite "Bug highlighted by property-based testing" & " [" & $WordBitwidth & "-bit mode]":
test "#30 - Euler's Criterion should be 1 for square on FKM12_447":
var a: Fp[FKM12_447]
# square of "0x406e5e74ee09c84fa0c59f2db3ac814a4937e2f57ecd3c0af4265e04598d643c5b772a6549a2d9b825445c34b8ba100fe8d912e61cfda43d"
a.fromHex("0x1e6511b2bfabd7d32d8df7492c66df29ade7fdb21bb0d8f6cacfccb05e45a812a27cd087e1bbb2d202ee29f75a021a6a68d990a2a5e73410")

a.powUnsafeExponent(FKM12_447.getPrimeMinus1div2_BE())
check: bool a.isOne()

main()
7 changes: 7 additions & 0 deletions tests/t_finite_fields_sqrt.nim
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,11 @@ proc main() =
randomSqrtCheck_p3mod4 BLS12_461
randomSqrtCheck_p3mod4 BN462

suite "Modular square root - 32-bit bugs highlighted by property-based testing " & " [" & $WordBitwidth & "-bit mode]":
test "FKM12_447 - #30":
var a: Fp[FKM12_447]
a.fromHex("0x406e5e74ee09c84fa0c59f2db3ac814a4937e2f57ecd3c0af4265e04598d643c5b772a6549a2d9b825445c34b8ba100fe8d912e61cfda43d")
a.square()
check: bool a.isSquare()

main()

0 comments on commit 988f6b3

Please sign in to comment.