mirror of
https://github.com/codex-storage/constantine.git
synced 2025-02-05 15:33:55 +00:00
Fix #131, inversion tests didn't take into account that the RNG can produce a 0 input and so a.inv can be different from 1
This commit is contained in:
parent
7e97cd4ac5
commit
75493dfb5b
@ -257,25 +257,25 @@ proc main() =
|
||||
let a = rng.random_unsafe(Fp[curve])
|
||||
aInv.inv(a)
|
||||
r.prod(a, aInv)
|
||||
check: bool r.isOne()
|
||||
check: bool r.isOne() or (a.isZero() and r.isZero())
|
||||
r.prod(aInv, a)
|
||||
check: bool r.isOne()
|
||||
check: bool r.isOne() or (a.isZero() and r.isZero())
|
||||
|
||||
for _ in 0 ..< Iters:
|
||||
let a = rng.randomHighHammingWeight(Fp[curve])
|
||||
aInv.inv(a)
|
||||
r.prod(a, aInv)
|
||||
check: bool r.isOne()
|
||||
check: bool r.isOne() or (a.isZero() and r.isZero())
|
||||
r.prod(aInv, a)
|
||||
check: bool r.isOne()
|
||||
check: bool r.isOne() or (a.isZero() and r.isZero())
|
||||
|
||||
for _ in 0 ..< Iters:
|
||||
let a = rng.random_long01Seq(Fp[curve])
|
||||
aInv.inv(a)
|
||||
r.prod(a, aInv)
|
||||
check: bool r.isOne()
|
||||
check: bool r.isOne() or (a.isZero() and r.isZero())
|
||||
r.prod(aInv, a)
|
||||
check: bool r.isOne()
|
||||
check: bool r.isOne() or (a.isZero() and r.isZero())
|
||||
|
||||
testRandomInv P224
|
||||
testRandomInv BN254_Nogami
|
||||
|
Loading…
x
Reference in New Issue
Block a user