diff --git a/go.mod b/go.mod index 341e196aeb..32742c25aa 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index b0de6a9c18..5d36fd8d58 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/std/accumulator/merkle/verify.go b/std/accumulator/merkle/verify.go index fad4b84506..56c74c6318 100644 --- a/std/accumulator/merkle/verify.go +++ b/std/accumulator/merkle/verify.go @@ -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 diff --git a/std/compress/io.go b/std/compress/io.go index 25dadfae47..8586cca452 100644 --- a/std/compress/io.go +++ b/std/compress/io.go @@ -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 -} diff --git a/std/fiat-shamir/transcript.go b/std/fiat-shamir/transcript.go index 6d7bd57110..f55ea78dd2 100644 --- a/std/fiat-shamir/transcript.go +++ b/std/fiat-shamir/transcript.go @@ -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" diff --git a/std/math/emulated/field.go b/std/math/emulated/field.go index 5bbf26f646..e84330024e 100644 --- a/std/math/emulated/field.go +++ b/std/math/emulated/field.go @@ -1,6 +1,7 @@ package emulated import ( + "cmp" "errors" "fmt" "math/big" @@ -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 @@ -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 diff --git a/std/math/emulated/field_mul.go b/std/math/emulated/field_mul.go index 91fa7a95a8..c81c1fe010 100644 --- a/std/math/emulated/field_mul.go +++ b/std/math/emulated/field_mul.go @@ -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 @@ -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 } diff --git a/std/math/uints/hints.go b/std/math/uints/hints.go index 6e230ed8cf..0096ea3327 100644 --- a/std/math/uints/hints.go +++ b/std/math/uints/hints.go @@ -2,6 +2,7 @@ package uints import ( "errors" + "fmt" "math/big" "github.com/consensys/gnark/constraint/solver" @@ -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") diff --git a/std/recursion/wrapped_hash.go b/std/recursion/wrapped_hash.go index e131629674..cb3899fba6 100644 --- a/std/recursion/wrapped_hash.go +++ b/std/recursion/wrapped_hash.go @@ -6,6 +6,8 @@ import ( "hash" "math/big" + "slices" + "github.com/consensys/gnark-crypto/ecc" cryptomimc "github.com/consensys/gnark-crypto/hash" "github.com/consensys/gnark/frontend" @@ -13,7 +15,6 @@ import ( 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 {