From 69fb6a12aee0f00ea2abd21e65fb1d59b829bbdc Mon Sep 17 00:00:00 2001 From: MozirDmitriy Date: Wed, 17 Sep 2025 12:46:10 +0300 Subject: [PATCH 01/10] fix: panic on zero-length inputs in Mux (#1600) Co-authored-by: Ivo Kubjas --- std/selector/multiplexer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/std/selector/multiplexer.go b/std/selector/multiplexer.go index fc87371b37..2155c529ab 100644 --- a/std/selector/multiplexer.go +++ b/std/selector/multiplexer.go @@ -56,6 +56,9 @@ func Map(api frontend.API, queryKey frontend.Variable, // inputs, otherwise the proof will fail. func Mux(api frontend.API, sel frontend.Variable, inputs ...frontend.Variable) frontend.Variable { n := uint(len(inputs)) + if n == 0 { + panic("invalid input length 0 for mux") + } if n == 1 { api.AssertIsEqual(sel, 0) return inputs[0] From 272175725dae6b21e4ca9b26a8000c2f26e7b0b3 Mon Sep 17 00:00:00 2001 From: Galoretka Date: Wed, 17 Sep 2025 12:52:47 +0300 Subject: [PATCH 02/10] Handle empty inputs in EvalUnivariate and EvalMultilinearMany (#1605) --- std/math/polynomial/polynomial.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/std/math/polynomial/polynomial.go b/std/math/polynomial/polynomial.go index aa763cbe88..5f94b0c98f 100644 --- a/std/math/polynomial/polynomial.go +++ b/std/math/polynomial/polynomial.go @@ -93,6 +93,9 @@ func New[FR emulated.FieldParams](api frontend.API) (*Polynomial[FR], error) { // EvalUnivariate evaluates univariate polynomial at a point at. It returns the // evaluation. The method does not mutate the inputs. func (p *Polynomial[FR]) EvalUnivariate(P Univariate[FR], at *emulated.Element[FR]) *emulated.Element[FR] { + if len(P) == 0 { + return p.f.Zero() + } res := p.f.Zero() for i := len(P) - 1; i > 0; i-- { res = p.f.Add(res, &P[i]) @@ -118,6 +121,9 @@ func (p *Polynomial[FR]) EvalMultilinear(at []*emulated.Element[FR], M Multiline // The method allows to share computations of computing the coefficients of the // multilinear polynomials at the given evaluation points. func (p *Polynomial[FR]) EvalMultilinearMany(at []*emulated.Element[FR], M ...Multilinear[FR]) ([]*emulated.Element[FR], error) { + if len(M) == 0 { + return nil, errors.New("no multilinear polynomials to evaluate") + } lenM := len(M[0]) for i := range M { if len(M[i]) != lenM { From 254db5ef2057ddac7422c877f39ce4d7652da8a9 Mon Sep 17 00:00:00 2001 From: sashass1315 Date: Wed, 17 Sep 2025 13:30:14 +0300 Subject: [PATCH 03/10] fix(emulated): MulConst negative constant handling and correct mul-check formula comment (#1603) --- std/math/emulated/field_mul.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/std/math/emulated/field_mul.go b/std/math/emulated/field_mul.go index 15269a5509..91fa7a95a8 100644 --- a/std/math/emulated/field_mul.go +++ b/std/math/emulated/field_mul.go @@ -85,7 +85,7 @@ type deferredChecker interface { // // Given these values, the following holds: // -// a * b = r * k*p +// a * b = r + k*p // // But for asserting that the previous equation holds, we instead use the // polynomial representation of the elements. If a non-native element a is given @@ -623,7 +623,7 @@ func (f *Field[T]) MulConst(a *Element[T], c *big.Int) *Element[T] { } switch c.Sign() { case -1: - f.MulConst(f.Neg(a), new(big.Int).Neg(c)) + return f.MulConst(f.Neg(a), new(big.Int).Neg(c)) case 0: return f.Zero() } From b13db61f11a2ea879f2895e2bd9fcf68675ac99a Mon Sep 17 00:00:00 2001 From: GarmashAlex Date: Wed, 17 Sep 2025 13:32:10 +0300 Subject: [PATCH 04/10] plonk(recursion): fix incorrect error messages for bw6-761 and bn254 branches (#1597) --- std/recursion/plonk/verifier.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/std/recursion/plonk/verifier.go b/std/recursion/plonk/verifier.go index 688866cb4b..8f09b4a7a2 100644 --- a/std/recursion/plonk/verifier.go +++ b/std/recursion/plonk/verifier.go @@ -177,7 +177,7 @@ func ValueOfProof[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra case *Proof[sw_bw6761.ScalarField, sw_bw6761.G1Affine, sw_bw6761.G2Affine]: tProof, ok := proof.(*plonkbackend_bw6761.Proof) if !ok { - return ret, fmt.Errorf("expected sw_bls12377.Proof, got %T", proof) + return ret, fmt.Errorf("expected sw_bw6761.Proof, got %T", proof) } for i := range r.LRO { r.LRO[i], err = kzg.ValueOfCommitment[sw_bw6761.G1Affine](tProof.LRO[i]) @@ -214,7 +214,7 @@ func ValueOfProof[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra case *Proof[sw_bn254.ScalarField, sw_bn254.G1Affine, sw_bn254.G2Affine]: tProof, ok := proof.(*plonkbackend_bn254.Proof) if !ok { - return ret, fmt.Errorf("expected sw_bls12377.Proof, got %T", proof) + return ret, fmt.Errorf("expected sw_bn254.Proof, got %T", proof) } for i := range r.LRO { r.LRO[i], err = kzg.ValueOfCommitment[sw_bn254.G1Affine](tProof.LRO[i]) @@ -353,7 +353,7 @@ func ValueOfBaseVerifyingKey[FR emulated.FieldParams, G1El algebra.G1ElementT, G case *BaseVerifyingKey[sw_bw6761.ScalarField, sw_bw6761.G1Affine, sw_bw6761.G2Affine]: tVk, ok := vk.(*plonkbackend_bw6761.VerifyingKey) if !ok { - return ret, fmt.Errorf("expected bls12377.VerifyingKey, got %T", vk) + return ret, fmt.Errorf("expected bw6761.VerifyingKey, got %T", vk) } r.NbPublicVariables = tVk.NbPublicVariables r.Kzg, err = kzg.ValueOfVerifyingKeyFixed[sw_bw6761.G1Affine, sw_bw6761.G2Affine](tVk.Kzg) @@ -523,7 +523,7 @@ func ValueOfCircuitVerifyingKey[FR emulated.FieldParams, G1El algebra.G1ElementT case *CircuitVerifyingKey[sw_bw6761.ScalarField, sw_bw6761.G1Affine]: tVk, ok := vk.(*plonkbackend_bw6761.VerifyingKey) if !ok { - return ret, fmt.Errorf("expected bls12377.VerifyingKey, got %T", vk) + return ret, fmt.Errorf("expected bw6761.VerifyingKey, got %T", vk) } r.Size = tVk.Size r.SizeInv = sw_bw6761.NewScalar(tVk.SizeInv) From 98ec8671ffd8c8ef04039c761af737b8803f25e1 Mon Sep 17 00:00:00 2001 From: Fibonacci747 Date: Wed, 17 Sep 2025 13:42:13 +0200 Subject: [PATCH 05/10] fix: propagate ReadFrom errors in generated r1cs tests (#1588) --- constraint/babybear/r1cs_test.go | 4 ++-- constraint/bls12-377/r1cs_test.go | 4 ++-- constraint/bls12-381/r1cs_test.go | 4 ++-- constraint/bls24-315/r1cs_test.go | 4 ++-- constraint/bls24-317/r1cs_test.go | 4 ++-- constraint/bn254/r1cs_test.go | 4 ++-- constraint/bw6-633/r1cs_test.go | 4 ++-- constraint/bw6-761/r1cs_test.go | 4 ++-- constraint/koalabear/r1cs_test.go | 4 ++-- constraint/tinyfield/r1cs_test.go | 4 ++-- .../backend/template/representations/tests/r1cs.go.tmpl | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/constraint/babybear/r1cs_test.go b/constraint/babybear/r1cs_test.go index ea08cd0d76..a60a7668e8 100644 --- a/constraint/babybear/r1cs_test.go +++ b/constraint/babybear/r1cs_test.go @@ -108,14 +108,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/constraint/bls12-377/r1cs_test.go b/constraint/bls12-377/r1cs_test.go index afc5da5eca..363228d687 100644 --- a/constraint/bls12-377/r1cs_test.go +++ b/constraint/bls12-377/r1cs_test.go @@ -103,14 +103,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/constraint/bls12-381/r1cs_test.go b/constraint/bls12-381/r1cs_test.go index bea1fcc52a..b7c17a9f54 100644 --- a/constraint/bls12-381/r1cs_test.go +++ b/constraint/bls12-381/r1cs_test.go @@ -103,14 +103,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/constraint/bls24-315/r1cs_test.go b/constraint/bls24-315/r1cs_test.go index 4f33de051d..a20f16dd00 100644 --- a/constraint/bls24-315/r1cs_test.go +++ b/constraint/bls24-315/r1cs_test.go @@ -103,14 +103,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/constraint/bls24-317/r1cs_test.go b/constraint/bls24-317/r1cs_test.go index 40808c223f..bc4016db3d 100644 --- a/constraint/bls24-317/r1cs_test.go +++ b/constraint/bls24-317/r1cs_test.go @@ -103,14 +103,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/constraint/bn254/r1cs_test.go b/constraint/bn254/r1cs_test.go index c1f47a6658..e150534966 100644 --- a/constraint/bn254/r1cs_test.go +++ b/constraint/bn254/r1cs_test.go @@ -103,14 +103,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/constraint/bw6-633/r1cs_test.go b/constraint/bw6-633/r1cs_test.go index 1cbe0407c1..731dbc6515 100644 --- a/constraint/bw6-633/r1cs_test.go +++ b/constraint/bw6-633/r1cs_test.go @@ -103,14 +103,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/constraint/bw6-761/r1cs_test.go b/constraint/bw6-761/r1cs_test.go index cd07ebec6e..fa401fe2b0 100644 --- a/constraint/bw6-761/r1cs_test.go +++ b/constraint/bw6-761/r1cs_test.go @@ -106,14 +106,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/constraint/koalabear/r1cs_test.go b/constraint/koalabear/r1cs_test.go index 8140af4f35..f85e1ce207 100644 --- a/constraint/koalabear/r1cs_test.go +++ b/constraint/koalabear/r1cs_test.go @@ -108,14 +108,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/constraint/tinyfield/r1cs_test.go b/constraint/tinyfield/r1cs_test.go index d34669126e..3124b95826 100644 --- a/constraint/tinyfield/r1cs_test.go +++ b/constraint/tinyfield/r1cs_test.go @@ -111,14 +111,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { diff --git a/internal/generator/backend/template/representations/tests/r1cs.go.tmpl b/internal/generator/backend/template/representations/tests/r1cs.go.tmpl index ca4c866a06..636c9cc7f9 100644 --- a/internal/generator/backend/template/representations/tests/r1cs.go.tmpl +++ b/internal/generator/backend/template/representations/tests/r1cs.go.tmpl @@ -113,14 +113,14 @@ func TestSerialization(t *testing.T) { var r, r2 cs.R1CS n, err = r.ReadFrom(&buffer) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if n == 0 { t.Fatal("No bytes are read") } _, err = r2.ReadFrom(&buffer2) if err != nil { - t.Fatal(nil) + t.Fatal(err) } if !reflect.DeepEqual(r, r2) { From b51111a1028a27b1cd108be022b00b39f58e5d03 Mon Sep 17 00:00:00 2001 From: liyue201 Date: Wed, 17 Sep 2025 19:46:30 +0800 Subject: [PATCH 06/10] fix NewPoseidon2 (#1598) --- std/permutation/poseidon2/poseidon2.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/std/permutation/poseidon2/poseidon2.go b/std/permutation/poseidon2/poseidon2.go index 55afe73be5..383e4a2d07 100644 --- a/std/permutation/poseidon2/poseidon2.go +++ b/std/permutation/poseidon2/poseidon2.go @@ -50,8 +50,25 @@ func NewPoseidon2(api frontend.API) (*Permutation, error) { switch utils.FieldToCurve(api.Compiler().Field()) { // TODO: assumes pairing based builder, reconsider when supporting other backends case ecc.BLS12_377: params := poseidonbls12377.GetDefaultParameters() - return NewPoseidon2FromParameters(api, 2, params.NbFullRounds, params.NbPartialRounds) - // TODO: we don't have default parameters for other curves yet. Update this when we do. + return NewPoseidon2FromParameters(api, params.Width, params.NbFullRounds, params.NbPartialRounds) + case ecc.BN254: + params := poseidonbn254.GetDefaultParameters() + return NewPoseidon2FromParameters(api, params.Width, params.NbFullRounds, params.NbPartialRounds) + case ecc.BLS12_381: + params := poseidonbls12381.GetDefaultParameters() + return NewPoseidon2FromParameters(api, params.Width, params.NbFullRounds, params.NbPartialRounds) + case ecc.BLS24_315: + params := poseidonbls24315.GetDefaultParameters() + return NewPoseidon2FromParameters(api, params.Width, params.NbFullRounds, params.NbPartialRounds) + case ecc.BLS24_317: + params := poseidonbls24317.GetDefaultParameters() + return NewPoseidon2FromParameters(api, params.Width, params.NbFullRounds, params.NbPartialRounds) + case ecc.BW6_761: + params := poseidonbw6761.GetDefaultParameters() + return NewPoseidon2FromParameters(api, params.Width, params.NbFullRounds, params.NbPartialRounds) + case ecc.BW6_633: + params := poseidonbw6633.GetDefaultParameters() + return NewPoseidon2FromParameters(api, params.Width, params.NbFullRounds, params.NbPartialRounds) default: return nil, fmt.Errorf("field %s not supported", api.Compiler().Field().String()) } From f2f9da28fc5825d6ecfe4cefb2b7e7fec7fe49a1 Mon Sep 17 00:00:00 2001 From: Bashmunta Date: Tue, 11 Nov 2025 02:05:10 +0200 Subject: [PATCH 07/10] fix: use dynamic expected/actual counts in toBytes error (#1645) --- std/math/uints/hints.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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") From 8ed77b3fc69317b32d4c83300f1b18365b6e2bd9 Mon Sep 17 00:00:00 2001 From: Snezhkko Date: Tue, 11 Nov 2025 02:13:04 +0200 Subject: [PATCH 08/10] fix: VerifyProof comment to reflect in-circuit behavior (#1641) --- std/accumulator/merkle/verify.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 From a1edc8df821a7f5fbb684778481f7e2ced5c0e0a Mon Sep 17 00:00:00 2001 From: stemlaud Date: Tue, 11 Nov 2025 08:39:24 +0800 Subject: [PATCH 09/10] chore: remove unused min func (#1617) Signed-off-by: stemlaud Co-authored-by: Ivo Kubjas --- go.mod | 1 - go.sum | 2 -- std/compress/io.go | 6 ------ std/fiat-shamir/transcript.go | 2 +- std/math/emulated/field.go | 18 ++---------------- std/math/emulated/field_mul.go | 5 ++++- std/recursion/wrapped_hash.go | 3 ++- 7 files changed, 9 insertions(+), 28 deletions(-) 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/compress/io.go b/std/compress/io.go index 25dadfae47..55f7a0492d 100644 --- a/std/compress/io.go +++ b/std/compress/io.go @@ -250,9 +250,3 @@ func (nr *NumReader) next(v frontend.Variable) frontend.Variable { 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/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 { From a295c858ffa35fa24aec459e36818506e2484197 Mon Sep 17 00:00:00 2001 From: Ivo Kubjas Date: Tue, 11 Nov 2025 00:42:32 +0000 Subject: [PATCH 10/10] fix: empty line --- std/compress/io.go | 1 - 1 file changed, 1 deletion(-) diff --git a/std/compress/io.go b/std/compress/io.go index 55f7a0492d..8586cca452 100644 --- a/std/compress/io.go +++ b/std/compress/io.go @@ -249,4 +249,3 @@ func (nr *NumReader) next(v frontend.Variable) frontend.Variable { nr.toRead = nr.toRead[1:] return nr.last } -