Skip to content
Draft
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
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/rs/zerolog v1.34.0
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.41.0
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b
golang.org/x/sync v0.16.0
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0=
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
10 changes: 6 additions & 4 deletions std/accumulator/merkle/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ func nodeSum(api frontend.API, h hash.FieldHasher, a, b frontend.Variable) front
return res
}

// VerifyProof takes a Merkle root, a proofSet, and a proofIndex and returns
// true if the first element of the proof set is a leaf of data in the Merkle
// root. False is returned if the proof set or Merkle root is nil, and if
// 'numLeaves' equals 0.
// VerifyProof encodes constraints that verify inclusion of a leaf at the given
// index into the Merkle root stored in mp.RootHash, using the authentication
// path stored in mp.Path. The argument leaf is the leaf index (little-endian
// bit order). The actual leaf value must be provided as mp.Path[0]. This
// method does not return a value; it asserts equality of the recomputed root
// and mp.RootHash via constraints.
func (mp *MerkleProof) VerifyProof(api frontend.API, h hash.FieldHasher, leaf frontend.Variable) {

depth := len(mp.Path) - 1
Expand Down
7 changes: 0 additions & 7 deletions std/compress/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,3 @@ func (nr *NumReader) next(v frontend.Variable) frontend.Variable {
nr.toRead = nr.toRead[1:]
return nr.last
}

func min(a, b int) int {
if a < b {
return a
}
return b
}
2 changes: 1 addition & 1 deletion std/fiat-shamir/transcript.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package fiatshamir
import (
"errors"

"golang.org/x/exp/slices"
"slices"

"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/std/hash"
Expand Down
18 changes: 2 additions & 16 deletions std/math/emulated/field.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package emulated

import (
"cmp"
"errors"
"fmt"
"math/big"
Expand All @@ -15,7 +16,6 @@ import (
"github.com/consensys/gnark/std/math/fieldextension"
"github.com/consensys/gnark/std/rangecheck"
"github.com/rs/zerolog"
"golang.org/x/exp/constraints"
)

// Field holds the configuration for non-native field operations. The field
Expand Down Expand Up @@ -285,21 +285,7 @@ func (f *Field[T]) maxOverflow() uint {
return f.maxOf
}

func max[T constraints.Ordered](a ...T) T {
if len(a) == 0 {
var f T
return f
}
m := a[0]
for _, v := range a {
if v > m {
m = v
}
}
return m
}

func sum[T constraints.Ordered](a ...T) T {
func sum[T cmp.Ordered](a ...T) T {
if len(a) == 0 {
var f T
return f
Expand Down
5 changes: 4 additions & 1 deletion std/math/emulated/field_mul.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,9 @@ func (mc *mvCheck[T]) cleanEvaluations() {
// As it only depends on the bit-length of the inputs, then we can precompute it
// regardless of the actual values.
func (f *Field[T]) polyMvEvalQuoSize(mv *multivariate[T], at []*Element[T]) (quoSize uint) {
if len(mv.Terms) == 0 {
return 0
}
quoSizes := make([]uint, len(mv.Terms))
for i, term := range mv.Terms {
// for every term, the result length is the sum of the lengths of the
Expand All @@ -1034,7 +1037,7 @@ func (f *Field[T]) polyMvEvalQuoSize(mv *multivariate[T], at []*Element[T]) (quo
}
// and for the full result, it is maximum of the inputs. We also add a bit
// for every term for overflow.
quoSize = max(quoSizes...) + uint(len(quoSizes))
quoSize = slices.Max(quoSizes) + uint(len(quoSizes))
return quoSize
}

Expand Down
3 changes: 2 additions & 1 deletion std/math/uints/hints.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package uints

import (
"errors"
"fmt"
"math/big"

"github.com/consensys/gnark/constraint/solver"
Expand Down Expand Up @@ -44,7 +45,7 @@ func toBytes(m *big.Int, inputs []*big.Int, outputs []*big.Int) error {
}
nbLimbs := int(inputs[0].Uint64())
if len(outputs) != nbLimbs {
return errors.New("output must be 8 elements")
return fmt.Errorf("expecting %d outputs, got %d", nbLimbs, len(outputs))
}
if !inputs[1].IsUint64() {
return errors.New("input must be 64 bits")
Expand Down
3 changes: 2 additions & 1 deletion std/recursion/wrapped_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"hash"
"math/big"

"slices"

"github.com/consensys/gnark-crypto/ecc"
cryptomimc "github.com/consensys/gnark-crypto/hash"
"github.com/consensys/gnark/frontend"
fiatshamir "github.com/consensys/gnark/std/fiat-shamir"
stdhash "github.com/consensys/gnark/std/hash"
"github.com/consensys/gnark/std/hash/mimc"
"github.com/consensys/gnark/std/math/bits"
"golang.org/x/exp/slices"
)

type shortNativeHash struct {
Expand Down
Loading