From 28f03e9b87451d421d5e8ab2e97ff7182fae43f1 Mon Sep 17 00:00:00 2001 From: Mamy Ratsimbazafy Date: Fri, 12 Jul 2024 23:20:45 +0200 Subject: [PATCH] fix(zkalc): workaround generic sandwich bug in Nim 1.6.x https://github.com/nim-lang/Nim/issues/8677 https://github.com/nim-lang/Nim/issues/11225 --- benchmarks/zkalc.nim | 5 ++++- constantine/named/zoo_subgroups.nim | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/benchmarks/zkalc.nim b/benchmarks/zkalc.nim index c4308ca4..fb452d66 100644 --- a/benchmarks/zkalc.nim +++ b/benchmarks/zkalc.nim @@ -32,6 +32,9 @@ import # Third-party jsony, cliche +# Workarounds generic sandwich bug in 1.6.x +from constantine/named/algebras import matchingBigInt, matchingOrderBigInt, getLimbs2x + type ZkalcBenchDetails = object `range`: seq[int] @@ -110,7 +113,7 @@ template bench(body: untyped): AggStats = # We can store integers up to 2⁵³ in a float64 without loss of precision (see also ulp) # 1 billion is ~ 2³⁰, so you would need 2²³ seconds = 8388608s = 13 weeks 6 days 2 hours 10 minutes 8 seconds - stats.push(elapsedNs) + stats.push(elapsedNs.int) (stats, batchSize) diff --git a/constantine/named/zoo_subgroups.nim b/constantine/named/zoo_subgroups.nim index 2a9e584e..2942ade0 100644 --- a/constantine/named/zoo_subgroups.nim +++ b/constantine/named/zoo_subgroups.nim @@ -33,7 +33,7 @@ export func clearCofactor*[EC](P: var EC) {.inline.} = ## Clear the cofactor of a point on the curve ## From a point on the curve, returns a point on the subgroup of order r - when EC.getName() in {BN254_Nogami, BN254_Snarks, BLS12_377, BLS12_381}: + when EC.F.Name in {BN254_Nogami, BN254_Snarks, BLS12_377, BLS12_381}: P.clearCofactorFast() else: P.clearCofactorReference()