switch to scalarMul_vartime

This commit is contained in:
Balazs Komuves 2024-01-18 13:04:46 +01:00
parent 1b20438c63
commit 14ee5ab14f
No known key found for this signature in database
GPG Key ID: F63B7AEF18435562
2 changed files with 8 additions and 8 deletions

View File

@ -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_affine as aff
import constantine/math/elliptic/ec_shortweierstrass_projective as prj import constantine/math/elliptic/ec_shortweierstrass_projective as prj
import constantine/math/pairings/pairings_bn as ate 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 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 = func `**`*( coeff: Fr , point: G1 ) : G1 =
var q : ProjG1 var q : ProjG1
prj.fromAffine( q , point ) prj.fromAffine( q , point )
scl.scalarMulGeneric( q , coeff.toBig() ) scl.scalarMul_vartime( q , coeff.toBig() )
var r : G1 var r : G1
prj.affine( r, q ) prj.affine( r, q )
return r return r
@ -190,7 +190,7 @@ func `**`*( coeff: Fr , point: G1 ) : G1 =
func `**`*( coeff: Fr , point: G2 ) : G2 = func `**`*( coeff: Fr , point: G2 ) : G2 =
var q : ProjG2 var q : ProjG2
prj.fromAffine( q , point ) prj.fromAffine( q , point )
scl.scalarMulGeneric( q , coeff.toBig() ) scl.scalarMul_vartime( q , coeff.toBig() )
var r : G2 var r : G2
prj.affine( r, q ) prj.affine( r, q )
return r return r
@ -200,7 +200,7 @@ func `**`*( coeff: Fr , point: G2 ) : G2 =
func `**`*( coeff: BigInt , point: G1 ) : G1 = func `**`*( coeff: BigInt , point: G1 ) : G1 =
var q : ProjG1 var q : ProjG1
prj.fromAffine( q , point ) prj.fromAffine( q , point )
scl.scalarMulGeneric( q , coeff ) scl.scalarMul_vartime( q , coeff )
var r : G1 var r : G1
prj.affine( r, q ) prj.affine( r, q )
return r return r
@ -208,7 +208,7 @@ func `**`*( coeff: BigInt , point: G1 ) : G1 =
func `**`*( coeff: BigInt , point: G2 ) : G2 = func `**`*( coeff: BigInt , point: G2 ) : G2 =
var q : ProjG2 var q : ProjG2
prj.fromAffine( q , point ) prj.fromAffine( q , point )
scl.scalarMulGeneric( q , coeff ) scl.scalarMul_vartime( q , coeff )
var r : G2 var r : G2
prj.affine( r, q ) prj.affine( r, q )
return r return r

View File

@ -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/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_affine as aff except Subgroup
import constantine/math/elliptic/ec_shortweierstrass_projective as prj 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 constantine/math/elliptic/ec_multi_scalar_mul as msm except Subgroup
import groth16/bn128/fields import groth16/bn128/fields
@ -121,7 +121,7 @@ func msmNaiveG1*( coeffs: seq[Fr] , points: seq[G1] ): G1 =
for i in 0..<N: for i in 0..<N:
var t : ProjG1 var t : ProjG1
prj.fromAffine( t, points[i] ) prj.fromAffine( t, points[i] )
scl.scalarMulGeneric( t , coeffs[i].toBig() ) scl.scalarMul_vartime( t , coeffs[i].toBig() )
s += t s += t
var r : G1 var r : G1
@ -141,7 +141,7 @@ func msmNaiveG2*( coeffs: seq[Fr] , points: seq[G2] ): G2 =
for i in 0..<N: for i in 0..<N:
var t : ProjG2 var t : ProjG2
prj.fromAffine( t, points[i] ) prj.fromAffine( t, points[i] )
scl.scalarMulGeneric( t , coeffs[i].toBig() ) scl.scalarMul_vartime( t , coeffs[i].toBig() )
s += t s += t
var r : G2 var r : G2