bench isSquare

This commit is contained in:
Mamy Ratsimbazafy 2022-08-07 19:50:28 +02:00
parent f35257d947
commit 74a23244d2
No known key found for this signature in database
GPG Key ID: 6227262F49BE273A
3 changed files with 7 additions and 0 deletions

View File

@ -128,6 +128,11 @@ proc invBench*(T: typedesc, iters: int) =
bench("Inversion (constant-time)", T, iters): bench("Inversion (constant-time)", T, iters):
r.inv(x) r.inv(x)
proc isSquareBench*(T: typedesc, iters: int) =
let x = rng.random_unsafe(T)
bench("isSquare (constant-time)", T, iters):
let qrt = x.isSquare()
proc sqrtBench*(T: typedesc, iters: int) = proc sqrtBench*(T: typedesc, iters: int) =
let x = rng.random_unsafe(T) let x = rng.random_unsafe(T)

View File

@ -59,6 +59,7 @@ proc main() =
toFieldBench(Fp[curve], Iters) toFieldBench(Fp[curve], Iters)
smallSeparator() smallSeparator()
invBench(Fp[curve], ExponentIters) invBench(Fp[curve], ExponentIters)
isSquareBench(Fp[curve], ExponentIters)
sqrtBench(Fp[curve], ExponentIters) sqrtBench(Fp[curve], ExponentIters)
sqrtRatioBench(Fp[curve], ExponentIters) sqrtRatioBench(Fp[curve], ExponentIters)
# Exponentiation by a "secret" of size ~the curve order # Exponentiation by a "secret" of size ~the curve order

View File

@ -50,6 +50,7 @@ proc main() =
sqrUnrBench(Fp2[curve], Iters) sqrUnrBench(Fp2[curve], Iters)
smallSeparator() smallSeparator()
invBench(Fp2[curve], InvIters) invBench(Fp2[curve], InvIters)
isSquareBench(Fp2[curve], InvIters)
sqrtBench(Fp2[curve], InvIters) sqrtBench(Fp2[curve], InvIters)
separator() separator()