Skip to content

Commit 133dac8

Browse files
committed
fix invalid pointer to temporal variable
1 parent 938afd1 commit 133dac8

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

bls12381/aggregate/main.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ package main
22

33
import (
44
"fmt"
5+
"log"
6+
57
"github.com/consensys/gnark-crypto/ecc"
68
bls12381_ecc "github.com/consensys/gnark-crypto/ecc/bls12-381"
79
"github.com/consensys/gnark/backend/groth16"
810
"github.com/consensys/gnark/frontend"
911
"github.com/consensys/gnark/frontend/cs/r1cs"
1012
bls12381 "github.com/consensys/gnark/std/algebra/emulated/sw_bls12381"
11-
"log"
1213
)
1314

1415
const (
15-
SignatureNum = 2
16+
SignatureNum = 16
1617
)
1718

1819
// Circuit Boneh-Lynn-Shacham (BLS) signature verification
@@ -35,13 +36,13 @@ func (circuit *Circuit) Define(api frontend.API) error {
3536
pl, _ := pair.Pair([]*bls12381.G1Affine{&circuit.Sig}, []*bls12381.G2Affine{&circuit.G2})
3637

3738
hm := []*bls12381.G1Affine{}
38-
for _, v := range circuit.Hm {
39-
hm = append(hm, &v)
39+
for k, _ := range circuit.Hm {
40+
hm = append(hm, &circuit.Hm[k])
4041
}
4142

4243
pk := []*bls12381.G2Affine{}
43-
for _, v := range circuit.Pk {
44-
pk = append(pk, &v)
44+
for k, _ := range circuit.Pk {
45+
pk = append(pk, &circuit.Pk[k])
4546
}
4647
pr, _ := pair.Pair(hm, pk)
4748
pair.AssertIsEqual(pl, pr)

bn254/aggregate/dynamic/main.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package main
22

33
import (
44
"fmt"
5+
"log"
6+
57
"github.com/consensys/gnark-crypto/ecc"
68
bn254_ecc "github.com/consensys/gnark-crypto/ecc/bn254"
79
"github.com/consensys/gnark/backend/groth16"
810
"github.com/consensys/gnark/frontend"
911
"github.com/consensys/gnark/frontend/cs/r1cs"
1012
bn254 "github.com/consensys/gnark/std/algebra/emulated/sw_bn254"
11-
"log"
1213
)
1314

1415
const (
@@ -35,13 +36,13 @@ func (circuit *Circuit) Define(api frontend.API) error {
3536
pl, _ := pair.Pair([]*bn254.G1Affine{&circuit.Sig}, []*bn254.G2Affine{&circuit.G2})
3637

3738
var hm []*bn254.G1Affine
38-
for _, v := range circuit.Hm {
39-
hm = append(hm, &v)
39+
for k, _ := range circuit.Hm {
40+
hm = append(hm, &circuit.Hm[k])
4041
}
4142

4243
var pk []*bn254.G2Affine
43-
for _, v := range circuit.Pk {
44-
pk = append(pk, &v)
44+
for k, _ := range circuit.Pk {
45+
pk = append(pk, &circuit.Pk[k])
4546
}
4647

4748
pr, _ := pair.Pair(hm, pk)

0 commit comments

Comments
 (0)