Skip to content

Commit b9457d1

Browse files
authored
Start burst from given number (#338)
1 parent 8e9b66e commit b9457d1

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ batcher_send_infinite_groth16: ./batcher/client/target/release/aligned ## Send a
232232

233233
batcher_send_burst_groth16: build_batcher_client
234234
@echo "Sending a burst of tasks to Batcher..."
235-
@./batcher/client/send_burst_tasks.sh $(BURST_SIZE)
235+
@mkdir -p task_sender/test_examples/gnark_groth16_bn254_infinite_script/infinite_proofs
236+
@./batcher/client/send_burst_tasks.sh $(BURST_SIZE) $(START_COUNTER)
236237

237238
batcher_send_halo2_ipa_task: batcher/client/target/release/aligned
238239
@echo "Sending Halo2 IPA 1!=0 task to Batcher..."

batcher/client/send_burst_tasks.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,27 @@ burst=8
66
if [ -z "$1" ]; then
77
echo "Using default burst value: 10"
88
elif ! [[ "$1" =~ ^[0-9]+$ ]]; then
9-
echo "Error: Argument must be a number."
9+
echo "Error: First argument must be a number."
1010
exit 1
1111
else
1212
burst=$1
1313
echo "Using burst value: $burst"
1414
fi
1515

16-
counter=1
17-
while true
16+
if [ -z "$2" ]; then
17+
echo "Using default counter start value: 1"
18+
elif ! [[ "$2" =~ ^[0-9]+$ ]]; then
19+
echo "Error: Second argument must be a number."
20+
exit 1
21+
else
22+
counter=$2
23+
echo "Starting counter from: $counter"
24+
fi
25+
26+
for ((i=0; i<burst; i++))
1827
do
1928
# Run in backaground to be able to run onece per second, and not wait for the previous one to finish
20-
./batcher/client/generate_proof_and_send.sh $counter $burst &
21-
sleep 1
22-
counter=$((counter + 1))
29+
./batcher/client/generate_proof_and_send.sh $counter $burst &
30+
sleep 1
31+
counter=$((counter + 1))
2332
done
24-

task_sender/test_examples/gnark_groth16_bn254_infinite_script/pkg/generate_proof.go

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ import (
88

99
"github.com/consensys/gnark-crypto/ecc"
1010
"github.com/consensys/gnark/backend/groth16"
11-
12-
// "github.com/consensys/gnark/frontend/cs/scs"
13-
"github.com/consensys/gnark/frontend/cs/r1cs"
14-
1511
"github.com/consensys/gnark/frontend"
12+
"github.com/consensys/gnark/frontend/cs/r1cs"
1613
)
1714

18-
// CubicCircuit defines a simple circuit
15+
// InequalityCircuit defines a simple circuit
1916
// x != 0
2017
type InequalityCircuit struct {
21-
// struct tags on a variable is optional
22-
// default uses variable name and secret visibility.
2318
X frontend.Variable `gnark:"x"`
2419
}
2520

@@ -34,23 +29,12 @@ func GenerateIneqProof(x int) {
3429
outputDir := "task_sender/test_examples/gnark_groth16_bn254_infinite_script/infinite_proofs/"
3530

3631
var circuit InequalityCircuit
37-
// use r1cs.NewBuilder instead of scs.NewBuilder
3832
ccs, err := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &circuit)
3933
if err != nil {
4034
panic("circuit compilation error")
4135
}
4236

43-
// rics is not used in the setup
44-
// r1cs := ccs.(*cs.SparseR1CS)
45-
// as srs is not used in the setup, we can remove it
46-
// srs, err := test.NewKZGSRS(r1cs)
47-
if err != nil {
48-
panic("KZG setup error")
49-
}
50-
51-
// no need to use srs in the setup
5237
pk, vk, _ := groth16.Setup(ccs)
53-
// pk, vk, err := groth16.Setup(ccs, srs)
5438

5539
assignment := InequalityCircuit{X: x}
5640

@@ -59,25 +43,21 @@ func GenerateIneqProof(x int) {
5943
log.Fatal(err)
6044
}
6145

62-
// TODO , this should be empty, right? private input is x and no pub input
6346
publicWitness, err := frontend.NewWitness(&assignment, ecc.BN254.ScalarField(), frontend.PublicOnly())
6447
if err != nil {
6548
log.Fatal(err)
6649
}
6750

68-
// This proof should be serialized for testing in the operator
6951
proof, err := groth16.Prove(ccs, pk, fullWitness)
7052
if err != nil {
7153
panic("GROTH16 proof generation error")
7254
}
7355

74-
// The proof is verified before writing it into a file to make sure it is valid.
7556
err = groth16.Verify(proof, vk, publicWitness)
7657
if err != nil {
7758
panic("GROTH16 proof not verified")
7859
}
7960

80-
// Open files for writing the proof, the verification key and the public witness
8161
proofFile, err := os.Create(outputDir + "ineq_" + strconv.Itoa(x) + "_groth16.proof")
8262
if err != nil {
8363
panic(err)
@@ -107,7 +87,7 @@ func GenerateIneqProof(x int) {
10787
panic("could not serialize proof into file")
10888
}
10989

110-
fmt.Println("Proof written into ineq_{x}_groth16.proof")
111-
fmt.Println("Verification key written into groth16_verification_key")
112-
fmt.Println("Public witness written into witness.pub")
90+
fmt.Printf("Proof written into ineq_%d_groth16.proof\n", x)
91+
fmt.Printf("Verification key written into ineq_%d_groth16.vk\n", x)
92+
fmt.Printf("Public witness written into ineq_%d_groth16.pub\n", x)
11393
}

0 commit comments

Comments
 (0)