Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/gpu/t_nvidia_fp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ proc main() =
# P224,
BN254_Nogami,
BN254_Snarks,
Edwards25519,
# Edwards25519, # TODO - reactivate once Crandall accel is implemented on Nvidia #557
Bandersnatch,
Pallas,
Vesta,
Expand Down
21 changes: 20 additions & 1 deletion tests/math_fields/t_finite_fields_mulsquare.nim
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,26 @@ suite "Random Modular Squaring is consistent with Modular Multiplication" & " ["
for _ in 0 ..< Iters:
random_long01Seq(Vesta)

suite "Modular multiplication - bugs highlighted by property-based testing":
test "Edwards25519 - 32-bit Crandall prime acceleration":
block:
# Nvidia backend copied Crandall as-is without converting out of Montgomery domain.
var a, b: Fp[Edwards25519]
a.fromHex"0x007ffffff6825fff001ff67ff0a5fffffda0000000002567e00024d00000001f"
b.fromHex"0x7ffffffffecfc00000800097ffd200010088007fffffffffe007ffba97fed24d"

var r_mul, r_expected: Fp[Edwards25519]
r_expected.fromHex"0x271c295b1362f23fb414095b7c8385068685645b554289b99085b28cd43fd034"

r_mul.prod(a, b)

doAssert bool(r_mul == r_expected), block:
"\n" &
"a: " & a.toHex & "\n" &
"b: " & b.toHex & "\n" &
"result: " & r_mul.toHex & "\n" &
"expected: " & r_expected.toHex & "\n"

suite "Modular squaring - bugs highlighted by property-based testing":
test "a² == (-a)² on for Fp[2^127 - 1] - #61":
var a{.noInit.}: Fp[Mersenne127]
Expand Down Expand Up @@ -321,7 +341,6 @@ suite "Modular squaring - bugs highlighted by property-based testing":
bool(a2mul == expected)
bool(a2sqr == expected)


proc random_sumprod(Name: static Algebra, N: static int) =
template sumprod_test(random_instancer: untyped) =
block:
Expand Down
Loading