Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stashed typo fixes for v0.12 #1398

Merged
merged 5 commits into from
Jan 21, 2025
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
13 changes: 3 additions & 10 deletions constraint/solver/hint_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package solver

import (
"fmt"
"github.com/consensys/gnark/internal/hints"
"maps"
"math/big"
"sync"

"github.com/consensys/gnark/internal/hints"
"github.com/consensys/gnark/logger"
)

Expand Down Expand Up @@ -60,18 +61,10 @@ func GetRegisteredHints() []Hint {
return ret
}

func cloneMap[K comparable, V any](src map[K]V) map[K]V {
res := make(map[K]V, len(registry))
for k, v := range src {
res[k] = v
}
return res
}

func cloneHintRegistry() map[HintID]Hint {
registryM.Lock()
defer registryM.Unlock()
return cloneMap(registry)
return maps.Clone(registry)
}

// InvZeroHint computes the value 1/a for the single input a. If a == 0, returns 0.
Expand Down
4 changes: 2 additions & 2 deletions examples/rollup/circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

const (
nbAccounts = 16 // 16 accounts so we know that the proof length is 5
depth = 5 // size fo the inclusion proofs
BatchSizeCircuit = 1 // nbTranfers to batch in a proof
depth = 5 // size of the inclusion proofs
BatchSizeCircuit = 1 // nbTransfers to batch in a proof
)

// Circuit "toy" rollup circuit where an operator can generate a proof that he processed
Expand Down
8 changes: 4 additions & 4 deletions examples/rollup/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (o *Operator) updateState(t Transfer, numTransfer int) error {
if err != nil {
return err
}
merkleRootAfer, proofInclusionSenderAfter, _, err := merkletree.BuildReaderProof(&buf, o.h, segmentSize, posSender)
merkleRootAfter, proofInclusionSenderAfter, _, err := merkletree.BuildReaderProof(&buf, o.h, segmentSize, posSender)
if err != nil {
return err
}
Expand All @@ -247,9 +247,9 @@ func (o *Operator) updateState(t Transfer, numTransfer int) error {
}
// merkleProofHelperReceiverAfter := merkle.GenerateProofHelper(proofInclusionReceiverAfter, posReceiver, numLeaves)

o.witnesses.RootHashesAfter[numTransfer] = merkleRootAfer
o.witnesses.MerkleProofReceiverAfter[numTransfer].RootHash = merkleRootAfer
o.witnesses.MerkleProofSenderAfter[numTransfer].RootHash = merkleRootAfer
o.witnesses.RootHashesAfter[numTransfer] = merkleRootAfter
o.witnesses.MerkleProofReceiverAfter[numTransfer].RootHash = merkleRootAfter
o.witnesses.MerkleProofSenderAfter[numTransfer].RootHash = merkleRootAfter

for i := 0; i < len(proofInclusionSenderAfter); i++ {
o.witnesses.MerkleProofReceiverAfter[numTransfer].Path[i] = proofInclusionReceiverAfter[i]
Expand Down
6 changes: 2 additions & 4 deletions frontend/schema/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ type tagOptions string
// parseTag splits a struct field's json tag into its name and
// comma-separated options.
func parseTag(tag string) (string, tagOptions) {
if idx := strings.Index(tag, ","); idx != -1 {
return tag[:idx], tagOptions(tag[idx+1:])
}
return tag, tagOptions("")
name, remainder, _ := strings.Cut(tag, ",")
return name, tagOptions(remainder)
}

// contains reports whether a comma-separated list of options
Expand Down
2 changes: 1 addition & 1 deletion std/algebra/emulated/sw_bn254/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func (pr Pairing) millerLoopAndFinalExpResult(P *G1Affine, Q *G2Affine, previous
}

// IsMillerLoopAndFinalExpOne computes the Miller loop between P and Q,
// multiplies it in 𝔽p¹² by previous and and returns a boolean indicating if
// multiplies it in 𝔽p¹² by previous and returns a boolean indicating if
// the result lies in the same equivalence class as the reduced pairing
// purported to be 1. This check replaces the final exponentiation step
// in-circuit and follows Section 4 of [On Proving Pairings] paper by A.
Expand Down
8 changes: 2 additions & 6 deletions std/polynomial/polynomial.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,13 @@ func negFactorial(n int) int {
// computeDeltaAtNaive brute forces the computation of the δᵢ(at)
func computeDeltaAtNaive(api frontend.API, at frontend.Variable, valuesLen int) []frontend.Variable {
deltaAt := make([]frontend.Variable, valuesLen)
atMinus := make([]frontend.Variable, valuesLen) //TODO: No need for this array and the following loop
for i := range atMinus {
atMinus[i] = api.Sub(at, i)
}
factInv := api.Inverse(negFactorial(valuesLen - 1))

for i := range deltaAt {
deltaAt[i] = factInv
for j := range atMinus {
for j := 0; j < valuesLen; j++ {
if i != j {
deltaAt[i] = api.Mul(deltaAt[i], atMinus[j])
deltaAt[i] = api.Mul(deltaAt[i], api.Sub(at, j))
}
}

Expand Down
Loading