Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/stats/latest_stats.csv
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ scalar_mul_G1_bn254,bn254,groth16,108168,163915
scalar_mul_G1_bn254,bn254,plonk,355353,340385
scalar_mul_G1_bn254_incomplete,bn254,groth16,51579,81902
scalar_mul_G1_bn254_incomplete,bn254,plonk,185916,179316
scalar_mul_G2_bls12381,bn254,groth16,303414,456759
scalar_mul_G2_bls12381,bn254,plonk,989717,947171
scalar_mul_G2_bn254,bn254,groth16,217155,326138
scalar_mul_G2_bn254,bn254,plonk,721207,689834
scalar_mul_G2_bw6761,bn254,groth16,389209,617382
scalar_mul_G2_bw6761,bn254,plonk,1244592,1192510
scalar_mul_P256,bn254,groth16,96724,151768
scalar_mul_P256,bn254,plonk,328895,315729
scalar_mul_P256_incomplete,bn254,groth16,75542,121798
Expand Down
83 changes: 83 additions & 0 deletions internal/stats/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,89 @@ func initSnippets() {

}, ecc.BN254)

// G2 scalar mul snippets — exercise the GLV+FakeGLV path to track its cost.
registerSnippet("scalar_mul_G2_bls12381", func(api frontend.API, newVariable func() frontend.Variable) {
bls12381fp, _ := emulated.NewField[emulated.BLS12381Fp](api)
newFp := func() *emulated.Element[emulated.BLS12381Fp] {
nbLimbs, _ := emulated.GetEffectiveFieldParams[emulated.BLS12381Fp](api.Compiler().Field())
limbs := make([]frontend.Variable, nbLimbs)
for i := range limbs {
limbs[i] = newVariable()
}
return bls12381fp.NewElement(limbs)
}
bls12381fr, _ := emulated.NewField[emulated.BLS12381Fr](api)
newFr := func() *emulated.Element[emulated.BLS12381Fr] {
nbLimbs, _ := emulated.GetEffectiveFieldParams[emulated.BLS12381Fr](api.Compiler().Field())
limbs := make([]frontend.Variable, nbLimbs)
for i := range limbs {
limbs[i] = newVariable()
}
return bls12381fr.NewElement(limbs)
}
g2, _ := sw_bls12381.NewG2(api)
var dummyQ sw_bls12381.G2Affine
dummyQ.P.X.A0 = *newFp()
dummyQ.P.X.A1 = *newFp()
dummyQ.P.Y.A0 = *newFp()
dummyQ.P.Y.A1 = *newFp()
_ = g2.ScalarMul(&dummyQ, newFr())
}, ecc.BN254)

registerSnippet("scalar_mul_G2_bn254", func(api frontend.API, newVariable func() frontend.Variable) {
bn254fp, _ := emulated.NewField[emulated.BN254Fp](api)
newFp := func() *emulated.Element[emulated.BN254Fp] {
nbLimbs, _ := emulated.GetEffectiveFieldParams[emulated.BN254Fp](api.Compiler().Field())
limbs := make([]frontend.Variable, nbLimbs)
for i := range limbs {
limbs[i] = newVariable()
}
return bn254fp.NewElement(limbs)
}
bn254fr, _ := emulated.NewField[emulated.BN254Fr](api)
newFr := func() *emulated.Element[emulated.BN254Fr] {
nbLimbs, _ := emulated.GetEffectiveFieldParams[emulated.BN254Fr](api.Compiler().Field())
limbs := make([]frontend.Variable, nbLimbs)
for i := range limbs {
limbs[i] = newVariable()
}
return bn254fr.NewElement(limbs)
}
g2, _ := sw_bn254.NewG2(api)
var dummyQ sw_bn254.G2Affine
dummyQ.P.X.A0 = *newFp()
dummyQ.P.X.A1 = *newFp()
dummyQ.P.Y.A0 = *newFp()
dummyQ.P.Y.A1 = *newFp()
_ = g2.ScalarMul(&dummyQ, newFr())
}, ecc.BN254)

registerSnippet("scalar_mul_G2_bw6761", func(api frontend.API, newVariable func() frontend.Variable) {
bw6fp, _ := emulated.NewField[emulated.BW6761Fp](api)
newFp := func() *emulated.Element[emulated.BW6761Fp] {
nbLimbs, _ := emulated.GetEffectiveFieldParams[emulated.BW6761Fp](api.Compiler().Field())
limbs := make([]frontend.Variable, nbLimbs)
for i := range limbs {
limbs[i] = newVariable()
}
return bw6fp.NewElement(limbs)
}
bw6fr, _ := emulated.NewField[emulated.BW6761Fr](api)
newFr := func() *emulated.Element[emulated.BW6761Fr] {
nbLimbs, _ := emulated.GetEffectiveFieldParams[emulated.BW6761Fr](api.Compiler().Field())
limbs := make([]frontend.Variable, nbLimbs)
for i := range limbs {
limbs[i] = newVariable()
}
return bw6fr.NewElement(limbs)
}
g2, _ := sw_bw6761.NewG2(api)
var dummyQ sw_bw6761.G2Affine
dummyQ.P.X = *newFp()
dummyQ.P.Y = *newFp()
_ = g2.ScalarMul(&dummyQ, newFr())
}, ecc.BN254)

registerSnippet("selector/mux_3", func(api frontend.API, newVariable func() frontend.Variable) {
selector.Mux(api, newVariable(), newVariable(), newVariable(), newVariable())
})
Expand Down
Loading
Loading