From 14ee5ab14f8e74c8a1a59321d2e359a31e56059f Mon Sep 17 00:00:00 2001 From: Balazs Komuves Date: Thu, 18 Jan 2024 13:04:46 +0100 Subject: [PATCH] switch to `scalarMul_vartime` --- groth16/bn128/curves.nim | 10 +++++----- groth16/bn128/msm.nim | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/groth16/bn128/curves.nim b/groth16/bn128/curves.nim index d9c1559..42611b2 100644 --- a/groth16/bn128/curves.nim +++ b/groth16/bn128/curves.nim @@ -24,7 +24,7 @@ import constantine/math/extension_fields/towers as ext except Fp, Fp2, Fp12, Fr import constantine/math/elliptic/ec_shortweierstrass_affine as aff import constantine/math/elliptic/ec_shortweierstrass_projective as prj import constantine/math/pairings/pairings_bn as ate -import constantine/math/elliptic/ec_scalar_mul as scl +import constantine/math/elliptic/ec_scalar_mul_vartime as scl import groth16/bn128/fields @@ -182,7 +182,7 @@ func `-=`*(p: var G2, q: G2) = p = addG2(p,negG2(q)) func `**`*( coeff: Fr , point: G1 ) : G1 = var q : ProjG1 prj.fromAffine( q , point ) - scl.scalarMulGeneric( q , coeff.toBig() ) + scl.scalarMul_vartime( q , coeff.toBig() ) var r : G1 prj.affine( r, q ) return r @@ -190,7 +190,7 @@ func `**`*( coeff: Fr , point: G1 ) : G1 = func `**`*( coeff: Fr , point: G2 ) : G2 = var q : ProjG2 prj.fromAffine( q , point ) - scl.scalarMulGeneric( q , coeff.toBig() ) + scl.scalarMul_vartime( q , coeff.toBig() ) var r : G2 prj.affine( r, q ) return r @@ -200,7 +200,7 @@ func `**`*( coeff: Fr , point: G2 ) : G2 = func `**`*( coeff: BigInt , point: G1 ) : G1 = var q : ProjG1 prj.fromAffine( q , point ) - scl.scalarMulGeneric( q , coeff ) + scl.scalarMul_vartime( q , coeff ) var r : G1 prj.affine( r, q ) return r @@ -208,7 +208,7 @@ func `**`*( coeff: BigInt , point: G1 ) : G1 = func `**`*( coeff: BigInt , point: G2 ) : G2 = var q : ProjG2 prj.fromAffine( q , point ) - scl.scalarMulGeneric( q , coeff ) + scl.scalarMul_vartime( q , coeff ) var r : G2 prj.affine( r, q ) return r diff --git a/groth16/bn128/msm.nim b/groth16/bn128/msm.nim index 9d2b335..14a5459 100644 --- a/groth16/bn128/msm.nim +++ b/groth16/bn128/msm.nim @@ -19,7 +19,7 @@ import constantine/math/config/type_ff except Fp, Fr, Subgroup import constantine/math/extension_fields/towers as ext except Fp, Fp2, Fp12, Fr import constantine/math/elliptic/ec_shortweierstrass_affine as aff except Subgroup import constantine/math/elliptic/ec_shortweierstrass_projective as prj except Subgroup -import constantine/math/elliptic/ec_scalar_mul as scl except Subgroup +import constantine/math/elliptic/ec_scalar_mul_vartime as scl except Subgroup import constantine/math/elliptic/ec_multi_scalar_mul as msm except Subgroup import groth16/bn128/fields @@ -121,7 +121,7 @@ func msmNaiveG1*( coeffs: seq[Fr] , points: seq[G1] ): G1 = for i in 0..