Skip to content

Commit ac1472a

Browse files
ivokuboliveredgetdashangcunzhuhaicityhidewrong
authored
fix: stashed typo fixes for v0.12 (#1398)
Signed-off-by: oliveredget <[email protected]> Signed-off-by: dashangcun <[email protected]> Signed-off-by: zhuhaicity <[email protected]> Signed-off-by: hidewrong <[email protected]> Co-authored-by: oliveredget <[email protected]> Co-authored-by: dashangcun <[email protected]> Co-authored-by: ZhuHaiCheng <[email protected]> Co-authored-by: hidewrong <[email protected]> Co-authored-by: VolodymyrBg <[email protected]>
1 parent 5a846d1 commit ac1472a

File tree

6 files changed

+14
-27
lines changed

6 files changed

+14
-27
lines changed

constraint/solver/hint_registry.go

+3-10
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package solver
22

33
import (
44
"fmt"
5-
"github.com/consensys/gnark/internal/hints"
5+
"maps"
66
"math/big"
77
"sync"
88

9+
"github.com/consensys/gnark/internal/hints"
910
"github.com/consensys/gnark/logger"
1011
)
1112

@@ -60,18 +61,10 @@ func GetRegisteredHints() []Hint {
6061
return ret
6162
}
6263

63-
func cloneMap[K comparable, V any](src map[K]V) map[K]V {
64-
res := make(map[K]V, len(registry))
65-
for k, v := range src {
66-
res[k] = v
67-
}
68-
return res
69-
}
70-
7164
func cloneHintRegistry() map[HintID]Hint {
7265
registryM.Lock()
7366
defer registryM.Unlock()
74-
return cloneMap(registry)
67+
return maps.Clone(registry)
7568
}
7669

7770
// InvZeroHint computes the value 1/a for the single input a. If a == 0, returns 0.

examples/rollup/circuit.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
const (
1616
nbAccounts = 16 // 16 accounts so we know that the proof length is 5
17-
depth = 5 // size fo the inclusion proofs
18-
BatchSizeCircuit = 1 // nbTranfers to batch in a proof
17+
depth = 5 // size of the inclusion proofs
18+
BatchSizeCircuit = 1 // nbTransfers to batch in a proof
1919
)
2020

2121
// Circuit "toy" rollup circuit where an operator can generate a proof that he processed

examples/rollup/operator.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func (o *Operator) updateState(t Transfer, numTransfer int) error {
230230
if err != nil {
231231
return err
232232
}
233-
merkleRootAfer, proofInclusionSenderAfter, _, err := merkletree.BuildReaderProof(&buf, o.h, segmentSize, posSender)
233+
merkleRootAfter, proofInclusionSenderAfter, _, err := merkletree.BuildReaderProof(&buf, o.h, segmentSize, posSender)
234234
if err != nil {
235235
return err
236236
}
@@ -247,9 +247,9 @@ func (o *Operator) updateState(t Transfer, numTransfer int) error {
247247
}
248248
// merkleProofHelperReceiverAfter := merkle.GenerateProofHelper(proofInclusionReceiverAfter, posReceiver, numLeaves)
249249

250-
o.witnesses.RootHashesAfter[numTransfer] = merkleRootAfer
251-
o.witnesses.MerkleProofReceiverAfter[numTransfer].RootHash = merkleRootAfer
252-
o.witnesses.MerkleProofSenderAfter[numTransfer].RootHash = merkleRootAfer
250+
o.witnesses.RootHashesAfter[numTransfer] = merkleRootAfter
251+
o.witnesses.MerkleProofReceiverAfter[numTransfer].RootHash = merkleRootAfter
252+
o.witnesses.MerkleProofSenderAfter[numTransfer].RootHash = merkleRootAfter
253253

254254
for i := 0; i < len(proofInclusionSenderAfter); i++ {
255255
o.witnesses.MerkleProofReceiverAfter[numTransfer].Path[i] = proofInclusionReceiverAfter[i]

frontend/schema/tags.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,8 @@ type tagOptions string
9696
// parseTag splits a struct field's json tag into its name and
9797
// comma-separated options.
9898
func parseTag(tag string) (string, tagOptions) {
99-
if idx := strings.Index(tag, ","); idx != -1 {
100-
return tag[:idx], tagOptions(tag[idx+1:])
101-
}
102-
return tag, tagOptions("")
99+
name, remainder, _ := strings.Cut(tag, ",")
100+
return name, tagOptions(remainder)
103101
}
104102

105103
// contains reports whether a comma-separated list of options

std/algebra/emulated/sw_bn254/pairing.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ func (pr Pairing) millerLoopAndFinalExpResult(P *G1Affine, Q *G2Affine, previous
829829
}
830830

831831
// IsMillerLoopAndFinalExpOne computes the Miller loop between P and Q,
832-
// multiplies it in 𝔽p¹² by previous and and returns a boolean indicating if
832+
// multiplies it in 𝔽p¹² by previous and returns a boolean indicating if
833833
// the result lies in the same equivalence class as the reduced pairing
834834
// purported to be 1. This check replaces the final exponentiation step
835835
// in-circuit and follows Section 4 of [On Proving Pairings] paper by A.

std/polynomial/polynomial.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,13 @@ func negFactorial(n int) int {
101101
// computeDeltaAtNaive brute forces the computation of the δᵢ(at)
102102
func computeDeltaAtNaive(api frontend.API, at frontend.Variable, valuesLen int) []frontend.Variable {
103103
deltaAt := make([]frontend.Variable, valuesLen)
104-
atMinus := make([]frontend.Variable, valuesLen) //TODO: No need for this array and the following loop
105-
for i := range atMinus {
106-
atMinus[i] = api.Sub(at, i)
107-
}
108104
factInv := api.Inverse(negFactorial(valuesLen - 1))
109105

110106
for i := range deltaAt {
111107
deltaAt[i] = factInv
112-
for j := range atMinus {
108+
for j := 0; j < valuesLen; j++ {
113109
if i != j {
114-
deltaAt[i] = api.Mul(deltaAt[i], atMinus[j])
110+
deltaAt[i] = api.Mul(deltaAt[i], api.Sub(at, j))
115111
}
116112
}
117113

0 commit comments

Comments
 (0)