From abc4044c811c7ce309c0e6e30d51128b5d92f94f Mon Sep 17 00:00:00 2001 From: wizard <112275929+famouswizard@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:20:13 +0300 Subject: [PATCH 01/16] Fix typo Update logger.go (#1323) --- logger/logger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logger/logger.go b/logger/logger.go index 4d3f370bc8..a97450a85d 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -29,7 +29,7 @@ func SetOutput(w io.Writer) { logger = logger.Output(w) } -// Set allow a gnark user to overhide the global logger +// Set allows a gnark user to overhide the global logger func Set(l zerolog.Logger) { logger = l } From 1900f20414845f4840a0e0a158a4a7e147d0cd1e Mon Sep 17 00:00:00 2001 From: Elias Rad <146735585+nnsW3@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:22:31 +0200 Subject: [PATCH 02/16] Fix typos (#1313) --- CODE_OF_CONDUCT.md | 4 ++-- README.md | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 9579bd2200..a591c5fbac 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -26,7 +26,7 @@ Examples of unacceptable behavior by participants include: advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others' private information, such as a physical or electronic +* Publishing others' private information, such as physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting @@ -70,4 +70,4 @@ members of the project's leadership. This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html -[homepage]: https://www.contributor-covenant.org \ No newline at end of file +[homepage]: https://www.contributor-covenant.org diff --git a/README.md b/README.md index 02c008f95a..61c9c71c14 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/consensys/gnark)](https://pkg.go.dev/mod/github.com/consensys/gnark) [![Documentation Status](https://readthedocs.com/projects/pegasys-gnark/badge/)][`gnark` User Documentation] [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5819104.svg)](https://doi.org/10.5281/zenodo.5819104) -`gnark` is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open source and developed under the Apache 2.0 license. +`gnark` is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open-source and developed under the Apache 2.0 license. `gnark` uses [`gnark-crypto`] for the finite-field arithmetic and out-circuit implementation of cryptographic algorithms. @@ -29,7 +29,7 @@ Checkout the [online playground][`gnark` Playground] to compile circuits and vis ## Security -**`gnark` and [`gnark-crypto`] have been [extensively audited](#audits), but are provided as-is, we make no guarantees or warranties to its safety and reliability. In particular, `gnark` makes no security guarantees such as constant time implementation or side-channel attack resistance.** +**`gnark` and [`gnark-crypto`] have been [extensively audited](#audits), but are provided as-is, we make no guarantees or warranties to their safety and reliability. In particular, `gnark` makes no security guarantees such as constant time implementation or side-channel attack resistance.** **To report a security bug, please refer to [`gnark` Security Policy](SECURITY.md).** @@ -56,7 +56,7 @@ The tests are automatically run during every PR and merge commit. We run full te ## Performance -`gnark` and `gnark-crypto` packages are optimized for 64bits architectures (x86 `amd64`) using assembly operations. We have generic implementation of the same arithmetic algorithms for ARM backends (`arm64`). We do not implement vector operations. +`gnark` and `gnark-crypto` packages are optimized for 64bits architectures (x86 `amd64`) using assembly operations. We have a generic implementation of the same arithmetic algorithms for ARM backends (`arm64`). We do not implement vector operations. ## Backwards compatibility @@ -228,4 +228,4 @@ This project is licensed under the Apache 2 License - see the [LICENSE](LICENSE) [`gnark-announce`]: https://groups.google.com/g/gnark-announce [@gnark_team]: https://twitter.com/gnark_team [`gnark-crypto`]: https://github.com/Consensys/gnark-crypto -[`gnark-solidity-checker`]: https://github.com/Consensys/gnark-solidity-checker \ No newline at end of file +[`gnark-solidity-checker`]: https://github.com/Consensys/gnark-solidity-checker From c85c168009f57a02bc5ef64330777c9dd09a48d0 Mon Sep 17 00:00:00 2001 From: Dmitry <98899785+mdqst@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:23:55 +0300 Subject: [PATCH 03/16] Fix typo Update api.go (#1319) --- frontend/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/api.go b/frontend/api.go index a09bce9299..de8361f9a6 100644 --- a/frontend/api.go +++ b/frontend/api.go @@ -24,7 +24,7 @@ type API interface { // doing: // // acopy := api.Mul(a, 1) - // acopy = MulAcc(acopy, b, c) + // acopy = api.MulAcc(acopy, b, c) // // ! But it may not modify a, always use MulAcc(...) result for correctness. MulAcc(a, b, c Variable) Variable From 92c2e8281d58252111dad65fa1d8be1c77d7206f Mon Sep 17 00:00:00 2001 From: Donny <130464015+defitricks@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:24:39 +0200 Subject: [PATCH 04/16] Fix typos in comments for clarity and grammatical correctness (#1320) --- frontend/builder.go | 2 +- frontend/variable.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/builder.go b/frontend/builder.go index f39262be1e..40663985f0 100644 --- a/frontend/builder.go +++ b/frontend/builder.go @@ -14,7 +14,7 @@ type NewBuilder func(*big.Int, CompileConfig) (Builder, error) type Compiler interface { constraint.CustomizableSystem - // MarkBoolean sets (but do not constraint!) v to be boolean + // MarkBoolean sets (but does not constrain!) v to be boolean // This is useful in scenarios where a variable is known to be boolean through a constraint // that is not api.AssertIsBoolean. If v is a constant, this is a no-op. MarkBoolean(v Variable) diff --git a/frontend/variable.go b/frontend/variable.go index c0f7603c9a..d4337955e5 100644 --- a/frontend/variable.go +++ b/frontend/variable.go @@ -13,7 +13,7 @@ import ( type Variable interface{} // IsCanonical returns true if the Variable has been normalized in a (internal) LinearExpression -// by one of the constraint system builder. In other words, if the Variable is a circuit input OR +// by one of the constraint system builders. In other words, if the Variable is a circuit input OR // returned by the API. func IsCanonical(v Variable) bool { switch v.(type) { From 1b68d28315907050f470314f3adcb3dee0e5ebd3 Mon Sep 17 00:00:00 2001 From: Bryer <0xbryer@gmail.com> Date: Fri, 22 Nov 2024 14:25:29 +0200 Subject: [PATCH 05/16] Typo Update profile.go (#1321) --- profile/profile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile/profile.go b/profile/profile.go index fe3e58f3c2..ed80741d23 100644 --- a/profile/profile.go +++ b/profile/profile.go @@ -26,7 +26,7 @@ var ( // Profile represents an active constraint system profiling session. type Profile struct { // defaults to ./gnark.pprof - // if blank, profiile is not written to disk + // if blank, profile is not written to disk filePath string // actual pprof profile struct From 8d50738bb8bec10d88bd5acc334bb6369eb68a4d Mon Sep 17 00:00:00 2001 From: leopardracer <136604165+leopardracer@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:24:03 +0200 Subject: [PATCH 06/16] fix: typos in documentation files (#1327) --- SECURITY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 39db02c5e7..215f8ca6bc 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -28,7 +28,7 @@ Issues in the **PUBLIC** track affect niche configurations, have very limited im Issues in the **PRIVATE** track are violations of committed security properties. -**PRIVATE** track issues are fixed in the next scheduled minor releases , and are kept private until then. +**PRIVATE** track issues are fixed in the next scheduled minor releases, and are kept private until then. Three to seven days before the release, a pre-announcement is sent to [`gnark-announce`] and [@gnark_team], announcing the presence of a security fix in the upcoming releases, and which component in gnark is affected; compiler, constraint system or proof system (but not disclosing any more details). @@ -59,4 +59,4 @@ This process can take some time, especially when coordination is required with m The best way to receive security announcements is to subscribe to the [`gnark-announce`] mailing list. Any messages pertaining to a security issue will be prefixed with \[security\]. [`gnark-announce`]: https://groups.google.com/g/gnark-announce -[@gnark_team]: https://twitter.com/gnark_team \ No newline at end of file +[@gnark_team]: https://twitter.com/gnark_team From 25cfaedd3522deab567d0a20b087b171b48f6d1d Mon Sep 17 00:00:00 2001 From: wangjingcun Date: Wed, 27 Nov 2024 19:28:46 +0800 Subject: [PATCH 07/16] chore: fix some struct and interface names in comment (#1329) Signed-off-by: wangjingcun --- frontend/api.go | 2 +- std/commitments/fri/fri.go | 2 +- std/multicommit/doc_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/api.go b/frontend/api.go index de8361f9a6..5bfb761574 100644 --- a/frontend/api.go +++ b/frontend/api.go @@ -142,7 +142,7 @@ type API interface { ConstantValue(v Variable) (*big.Int, bool) } -// BatchInvert returns a slice of variables containing the inverse of each element in i1 +// BatchInverter returns a slice of variables containing the inverse of each element in i1 // This is a temporary API, do not use it in your circuit type BatchInverter interface { // BatchInvert returns a slice of variables containing the inverse of each element in i1 diff --git a/std/commitments/fri/fri.go b/std/commitments/fri/fri.go index cf91d6e826..8b4bad94c0 100644 --- a/std/commitments/fri/fri.go +++ b/std/commitments/fri/fri.go @@ -43,7 +43,7 @@ type ProofOfProximity struct { Rounds []Round } -// radixTwoFri empty structs implementing compressionFunction for +// RadixTwoFri empty structs implementing compressionFunction for // the squaring function. type RadixTwoFri struct { diff --git a/std/multicommit/doc_test.go b/std/multicommit/doc_test.go index b7860932b3..b7ed380847 100644 --- a/std/multicommit/doc_test.go +++ b/std/multicommit/doc_test.go @@ -10,7 +10,7 @@ import ( "github.com/consensys/gnark/std/multicommit" ) -// MultipleCommitmentCircuit is an example circuit showing usage of multiple +// MultipleCommitmentsCircuit is an example circuit showing usage of multiple // independent commitments in-circuit. type MultipleCommitmentsCircuit struct { Secrets [4]frontend.Variable From d11906664d6a05930d1ed4c326f6b9510b13640d Mon Sep 17 00:00:00 2001 From: John <153272819+hishope@users.noreply.github.com> Date: Wed, 4 Dec 2024 08:16:13 +0800 Subject: [PATCH 08/16] chore: fix some problematic function names in comment (#1334) Signed-off-by: hishope --- std/math/emulated/field_mul.go | 2 +- test/unsafekzg/options.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/std/math/emulated/field_mul.go b/std/math/emulated/field_mul.go index 1d44483d56..92714fa16a 100644 --- a/std/math/emulated/field_mul.go +++ b/std/math/emulated/field_mul.go @@ -262,7 +262,7 @@ func (f *Field[T]) evalWithChallenge(a *Element[T], at []frontend.Variable) *Ele return a } -// performMulChecks should be deferred to actually perform all the +// performDeferredChecks should be deferred to actually perform all the // multiplication checks. func (f *Field[T]) performDeferredChecks(api frontend.API) error { // use given api. We are in defer and API may be different to what we have diff --git a/test/unsafekzg/options.go b/test/unsafekzg/options.go index 120e17079e..b4a7323050 100644 --- a/test/unsafekzg/options.go +++ b/test/unsafekzg/options.go @@ -13,7 +13,7 @@ import ( // Option allows changing the behaviour of the unsafe KZG SRS generation. type Option func(*config) error -// WithCacheDir enables the filesystem cache and sets the cache directory +// WithFSCache enables the filesystem cache and sets the cache directory // to ~/.gnark/kzg by default. func WithFSCache() Option { return func(opt *config) error { From 4f120c9c35219eea70e19178911c22d6645b814b Mon Sep 17 00:00:00 2001 From: Ivo Kubjas Date: Wed, 4 Dec 2024 01:17:26 +0100 Subject: [PATCH 09/16] Fix/emulated field doc (#1330) --- std/math/emulated/field.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/std/math/emulated/field.go b/std/math/emulated/field.go index d7087974c6..a9a1761c62 100644 --- a/std/math/emulated/field.go +++ b/std/math/emulated/field.go @@ -54,9 +54,7 @@ type ctxKey[T FieldParams] struct{} // NewField returns an object to be used in-circuit to perform emulated // arithmetic over the field defined by type parameter [FieldParams]. The -// operations on this type are defined on [Element]. There is also another type -// [FieldAPI] implementing [frontend.API] which can be used in place of native -// API for existing circuits. +// operations on this type are defined on [Element]. // // This is an experimental feature and performing emulated arithmetic in-circuit // is extremely costly. See package doc for more info. From 92fc93c3530db79931f46beab87b323190adcdff Mon Sep 17 00:00:00 2001 From: Andi <36215014+ChengenH@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:41:54 +0800 Subject: [PATCH 10/16] chore: use errors.New to replace fmt.Errorf with no parameters (#1338) Signed-off-by: ChengenH --- std/algebra/algopts/algopts.go | 12 +++++---- std/algebra/defaults.go | 5 ++-- std/algebra/emulated/sw_emulated/hints.go | 15 ++++++----- std/algebra/native/sw_bls12377/hints.go | 26 +++++++++---------- std/algebra/native/sw_bls12377/pairing2.go | 7 ++--- std/algebra/native/sw_bls24315/hints.go | 12 ++++----- std/algebra/native/sw_bls24315/pairing2.go | 7 ++--- std/algebra/native/twistededwards/hints.go | 11 ++++---- std/gkr/compile.go | 6 ++--- std/gkr/gkr.go | 5 ++-- std/internal/limbcomposition/composition.go | 8 +++--- std/internal/logderivarg/logderivarg.go | 7 ++--- .../logderivprecomp/logderivprecomp.go | 4 +-- std/math/bitslice/hints.go | 8 +++--- std/math/emulated/field.go | 9 ++++--- std/math/emulated/field_hint.go | 11 ++++---- std/math/emulated/field_mul.go | 7 ++--- std/math/emulated/hints.go | 23 ++++++++-------- std/math/emulated/subtraction_padding.go | 7 ++--- std/math/polynomial/polynomial.go | 7 ++--- std/math/uints/hints.go | 10 +++---- std/sumcheck/sumcheck.go | 4 +-- 22 files changed, 112 insertions(+), 99 deletions(-) diff --git a/std/algebra/algopts/algopts.go b/std/algebra/algopts/algopts.go index 2434fd57a8..590d3a7f2d 100644 --- a/std/algebra/algopts/algopts.go +++ b/std/algebra/algopts/algopts.go @@ -5,7 +5,9 @@ // implementations. package algopts -import "fmt" +import ( + "errors" +) type algebraCfg struct { NbScalarBits int @@ -24,7 +26,7 @@ type AlgebraOption func(*algebraCfg) error func WithNbScalarBits(bits int) AlgebraOption { return func(ac *algebraCfg) error { if ac.NbScalarBits != 0 { - return fmt.Errorf("WithNbBits already set") + return errors.New("WithNbBits already set") } ac.NbScalarBits = bits return nil @@ -39,7 +41,7 @@ func WithNbScalarBits(bits int) AlgebraOption { func WithFoldingScalarMul() AlgebraOption { return func(ac *algebraCfg) error { if ac.FoldMulti { - return fmt.Errorf("withFoldingScalarMul already set") + return errors.New("withFoldingScalarMul already set") } ac.FoldMulti = true return nil @@ -51,7 +53,7 @@ func WithFoldingScalarMul() AlgebraOption { func WithCompleteArithmetic() AlgebraOption { return func(ac *algebraCfg) error { if ac.CompleteArithmetic { - return fmt.Errorf("WithCompleteArithmetic already set") + return errors.New("WithCompleteArithmetic already set") } ac.CompleteArithmetic = true return nil @@ -70,7 +72,7 @@ func WithCompleteArithmetic() AlgebraOption { func WithCanonicalBitRepresentation() AlgebraOption { return func(ac *algebraCfg) error { if ac.ToBitsCanonical { - return fmt.Errorf("WithCanonicalBitRepresentation already set") + return errors.New("WithCanonicalBitRepresentation already set") } ac.ToBitsCanonical = true return nil diff --git a/std/algebra/defaults.go b/std/algebra/defaults.go index e90063bb10..abc730df72 100644 --- a/std/algebra/defaults.go +++ b/std/algebra/defaults.go @@ -1,6 +1,7 @@ package algebra import ( + "errors" "fmt" "github.com/consensys/gnark/frontend" @@ -58,7 +59,7 @@ func GetCurve[FR emulated.FieldParams, G1El G1ElementT](api frontend.API) (Curve } *s = c default: - return ret, fmt.Errorf("unknown type parametrisation") + return ret, errors.New("unknown type parametrisation") } return ret, nil } @@ -94,7 +95,7 @@ func GetPairing[G1El G1ElementT, G2El G2ElementT, GtEl GtElementT](api frontend. p := sw_bls24315.NewPairing(api) *s = p default: - return ret, fmt.Errorf("unknown type parametrisation") + return ret, errors.New("unknown type parametrisation") } return ret, nil } diff --git a/std/algebra/emulated/sw_emulated/hints.go b/std/algebra/emulated/sw_emulated/hints.go index f19bfeef0f..6061d0b698 100644 --- a/std/algebra/emulated/sw_emulated/hints.go +++ b/std/algebra/emulated/sw_emulated/hints.go @@ -2,6 +2,7 @@ package sw_emulated import ( "crypto/elliptic" + "errors" "fmt" "math/big" @@ -42,10 +43,10 @@ func GetHints() []solver.Hint { func decomposeScalarG1Subscalars(mod *big.Int, inputs []*big.Int, outputs []*big.Int) error { return emulated.UnwrapHint(inputs, outputs, func(field *big.Int, inputs, outputs []*big.Int) error { if len(inputs) != 2 { - return fmt.Errorf("expecting two inputs") + return errors.New("expecting two inputs") } if len(outputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } glvBasis := new(ecc.Lattice) ecc.PrecomputeLattice(field, inputs[1], glvBasis) @@ -71,10 +72,10 @@ func decomposeScalarG1Subscalars(mod *big.Int, inputs []*big.Int, outputs []*big func decomposeScalarG1Signs(mod *big.Int, inputs []*big.Int, outputs []*big.Int) error { return emulated.UnwrapHintWithNativeOutput(inputs, outputs, func(field *big.Int, inputs, outputs []*big.Int) error { if len(inputs) != 2 { - return fmt.Errorf("expecting two inputs") + return errors.New("expecting two inputs") } if len(outputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } glvBasis := new(ecc.Lattice) ecc.PrecomputeLattice(field, inputs[1], glvBasis) @@ -97,10 +98,10 @@ func decomposeScalarG1Signs(mod *big.Int, inputs []*big.Int, outputs []*big.Int) func scalarMulHint(_ *big.Int, inputs []*big.Int, outputs []*big.Int) error { return emulated.UnwrapHintWithNativeInput(inputs, outputs, func(field *big.Int, inputs, outputs []*big.Int) error { if len(outputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } if len(outputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } if field.Cmp(elliptic.P256().Params().P) == 0 { var fp emparams.P256Fp @@ -282,7 +283,7 @@ func scalarMulHint(_ *big.Int, inputs []*big.Int, outputs []*big.Int) error { P.Y.BigInt(outputs[1]) } else { - return fmt.Errorf("unsupported curve") + return errors.New("unsupported curve") } return nil diff --git a/std/algebra/native/sw_bls12377/hints.go b/std/algebra/native/sw_bls12377/hints.go index 9c0c86333d..6a993b9095 100644 --- a/std/algebra/native/sw_bls12377/hints.go +++ b/std/algebra/native/sw_bls12377/hints.go @@ -1,7 +1,7 @@ package sw_bls12377 import ( - "fmt" + "errors" "math/big" "github.com/consensys/gnark-crypto/ecc" @@ -27,10 +27,10 @@ func init() { func decomposeScalarG1Simple(scalarField *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) != 1 { - return fmt.Errorf("expecting one input") + return errors.New("expecting one input") } if len(outputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } cc := getInnerCurveConfig(scalarField) sp := ecc.SplitScalar(inputs[0], cc.glvBasis) @@ -42,10 +42,10 @@ func decomposeScalarG1Simple(scalarField *big.Int, inputs []*big.Int, outputs [] func decomposeScalarG1(scalarField *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) != 1 { - return fmt.Errorf("expecting one input") + return errors.New("expecting one input") } if len(outputs) != 3 { - return fmt.Errorf("expecting three outputs") + return errors.New("expecting three outputs") } cc := getInnerCurveConfig(scalarField) sp := ecc.SplitScalar(inputs[0], cc.glvBasis) @@ -69,10 +69,10 @@ func decomposeScalarG1(scalarField *big.Int, inputs []*big.Int, outputs []*big.I func decomposeScalarG2(scalarField *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) != 1 { - return fmt.Errorf("expecting one input") + return errors.New("expecting one input") } if len(outputs) != 3 { - return fmt.Errorf("expecting three outputs") + return errors.New("expecting three outputs") } cc := getInnerCurveConfig(scalarField) sp := ecc.SplitScalar(inputs[0], cc.glvBasis) @@ -96,10 +96,10 @@ func decomposeScalarG2(scalarField *big.Int, inputs []*big.Int, outputs []*big.I func scalarMulGLVG1Hint(scalarField *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) != 3 { - return fmt.Errorf("expecting three inputs") + return errors.New("expecting three inputs") } if len(outputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } // compute the resulting point [s]Q @@ -114,10 +114,10 @@ func scalarMulGLVG1Hint(scalarField *big.Int, inputs []*big.Int, outputs []*big. func halfGCDEisenstein(scalarField *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) != 2 { - return fmt.Errorf("expecting two input") + return errors.New("expecting two input") } if len(outputs) != 5 { - return fmt.Errorf("expecting five outputs") + return errors.New("expecting five outputs") } cc := getInnerCurveConfig(scalarField) glvBasis := new(ecc.Lattice) @@ -168,10 +168,10 @@ func halfGCDEisenstein(scalarField *big.Int, inputs []*big.Int, outputs []*big.I func halfGCDEisensteinSigns(scalarField *big.Int, inputs, outputs []*big.Int) error { if len(inputs) != 2 { - return fmt.Errorf("expecting two input") + return errors.New("expecting two input") } if len(outputs) != 5 { - return fmt.Errorf("expecting five outputs") + return errors.New("expecting five outputs") } cc := getInnerCurveConfig(scalarField) glvBasis := new(ecc.Lattice) diff --git a/std/algebra/native/sw_bls12377/pairing2.go b/std/algebra/native/sw_bls12377/pairing2.go index 945b732209..d76daab6da 100644 --- a/std/algebra/native/sw_bls12377/pairing2.go +++ b/std/algebra/native/sw_bls12377/pairing2.go @@ -1,6 +1,7 @@ package sw_bls12377 import ( + "errors" "fmt" "math/big" "slices" @@ -28,7 +29,7 @@ type Curve struct { func NewCurve(api frontend.API) (*Curve, error) { f, err := emulated.NewField[ScalarField](api) if err != nil { - return nil, fmt.Errorf("scalar field") + return nil, errors.New("scalar field") } return &Curve{ api: api, @@ -166,7 +167,7 @@ func (c *Curve) MultiScalarMul(P []*G1Affine, scalars []*Scalar, opts ...algopts } if !cfg.FoldMulti { if len(P) != len(scalars) { - return nil, fmt.Errorf("mismatching points and scalars slice lengths") + return nil, errors.New("mismatching points and scalars slice lengths") } // points and scalars must be non-zero n := len(P) @@ -184,7 +185,7 @@ func (c *Curve) MultiScalarMul(P []*G1Affine, scalars []*Scalar, opts ...algopts } else { // scalars are powers if len(scalars) == 0 { - return nil, fmt.Errorf("need scalar for folding") + return nil, errors.New("need scalar for folding") } gamma := c.packScalarToVar(scalars[0]) // decompose gamma in the endomorphism eigenvalue basis and bit-decompose the sub-scalars diff --git a/std/algebra/native/sw_bls24315/hints.go b/std/algebra/native/sw_bls24315/hints.go index d20fac537c..98517cc4a8 100644 --- a/std/algebra/native/sw_bls24315/hints.go +++ b/std/algebra/native/sw_bls24315/hints.go @@ -1,7 +1,7 @@ package sw_bls24315 import ( - "fmt" + "errors" "math/big" "github.com/consensys/gnark-crypto/ecc" @@ -26,10 +26,10 @@ func init() { func decomposeScalarSimple(nativeMod *big.Int, nativeInputs, nativeOutputs []*big.Int) error { return emulated.UnwrapHintWithNativeInput(nativeInputs, nativeOutputs, func(nnMod *big.Int, nninputs, nnOutputs []*big.Int) error { if len(nninputs) != 1 { - return fmt.Errorf("expecting one input") + return errors.New("expecting one input") } if len(nnOutputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } cc := getInnerCurveConfig(nativeMod) sp := ecc.SplitScalar(nninputs[0], cc.glvBasis) @@ -43,10 +43,10 @@ func decomposeScalarSimple(nativeMod *big.Int, nativeInputs, nativeOutputs []*bi func decomposeScalar(nativeMod *big.Int, nativeInputs, nativeOutputs []*big.Int) error { return emulated.UnwrapHintWithNativeInput(nativeInputs, nativeOutputs, func(nnMod *big.Int, nninputs, nnOutputs []*big.Int) error { if len(nninputs) != 1 { - return fmt.Errorf("expecting one input") + return errors.New("expecting one input") } if len(nnOutputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } cc := getInnerCurveConfig(nativeMod) sp := ecc.SplitScalar(nninputs[0], cc.glvBasis) @@ -115,7 +115,7 @@ func callDecomposeScalar(api frontend.API, s frontend.Variable, simple bool) (s1 func decompose(mod *big.Int, inputs, outputs []*big.Int) error { if len(inputs) != 1 && len(outputs) != 4 { - return fmt.Errorf("input/output length mismatch") + return errors.New("input/output length mismatch") } tmp := new(big.Int).Set(inputs[0]) mask := new(big.Int).SetUint64(^uint64(0)) diff --git a/std/algebra/native/sw_bls24315/pairing2.go b/std/algebra/native/sw_bls24315/pairing2.go index 405d53b2b3..c213b4b5a3 100644 --- a/std/algebra/native/sw_bls24315/pairing2.go +++ b/std/algebra/native/sw_bls24315/pairing2.go @@ -1,6 +1,7 @@ package sw_bls24315 import ( + "errors" "fmt" "math/big" "slices" @@ -28,7 +29,7 @@ type Curve struct { func NewCurve(api frontend.API) (*Curve, error) { f, err := emulated.NewField[ScalarField](api) if err != nil { - return nil, fmt.Errorf("scalar field") + return nil, errors.New("scalar field") } return &Curve{ api: api, @@ -166,7 +167,7 @@ func (c *Curve) MultiScalarMul(P []*G1Affine, scalars []*Scalar, opts ...algopts } if !cfg.FoldMulti { if len(P) != len(scalars) { - return nil, fmt.Errorf("mismatching points and scalars slice lengths") + return nil, errors.New("mismatching points and scalars slice lengths") } // points and scalars must be non-zero n := len(P) @@ -184,7 +185,7 @@ func (c *Curve) MultiScalarMul(P []*G1Affine, scalars []*Scalar, opts ...algopts } else { // scalars are powers if len(scalars) == 0 { - return nil, fmt.Errorf("need scalar for folding") + return nil, errors.New("need scalar for folding") } gamma := c.packScalarToVar(scalars[0]) // decompose gamma in the endomorphism eigenvalue basis and bit-decompose the sub-scalars diff --git a/std/algebra/native/twistededwards/hints.go b/std/algebra/native/twistededwards/hints.go index 90a59619cd..c9c4f7c78d 100644 --- a/std/algebra/native/twistededwards/hints.go +++ b/std/algebra/native/twistededwards/hints.go @@ -2,7 +2,6 @@ package twistededwards import ( "errors" - "fmt" "math/big" "sync" @@ -69,10 +68,10 @@ func decomposeScalar(scalarField *big.Int, inputs []*big.Int, res []*big.Int) er func halfGCD(mod *big.Int, inputs, outputs []*big.Int) error { if len(inputs) != 2 { - return fmt.Errorf("expecting two inputs") + return errors.New("expecting two inputs") } if len(outputs) != 4 { - return fmt.Errorf("expecting four outputs") + return errors.New("expecting four outputs") } glvBasis := new(ecc.Lattice) ecc.PrecomputeLattice(inputs[1], inputs[0], glvBasis) @@ -96,10 +95,10 @@ func halfGCD(mod *big.Int, inputs, outputs []*big.Int) error { func scalarMulHint(field *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) != 4 { - return fmt.Errorf("expecting four inputs") + return errors.New("expecting four inputs") } if len(outputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } // compute the resulting point [s]Q if field.Cmp(ecc.BLS12_381.ScalarField()) == 0 { @@ -162,7 +161,7 @@ func scalarMulHint(field *big.Int, inputs []*big.Int, outputs []*big.Int) error P.X.BigInt(outputs[0]) P.Y.BigInt(outputs[1]) } else { - return fmt.Errorf("scalarMulHint: unknown curve") + return errors.New("scalarMulHint: unknown curve") } return nil } diff --git a/std/gkr/compile.go b/std/gkr/compile.go index 31a790c56d..50cf5b42e6 100644 --- a/std/gkr/compile.go +++ b/std/gkr/compile.go @@ -1,7 +1,7 @@ package gkr import ( - "fmt" + "errors" "math/bits" "github.com/consensys/gnark/constraint" @@ -71,11 +71,11 @@ func (api *API) Import(assignment []frontend.Variable) (constraint.GkrVariable, nbInstances := len(assignment) logNbInstances := log2(uint(nbInstances)) if logNbInstances == -1 { - return -1, fmt.Errorf("number of assignments must be a power of 2") + return -1, errors.New("number of assignments must be a power of 2") } if currentNbInstances := api.nbInstances(); currentNbInstances != -1 && currentNbInstances != nbInstances { - return -1, fmt.Errorf("number of assignments must be consistent across all variables") + return -1, errors.New("number of assignments must be consistent across all variables") } newVar := api.toStore.NewInputVariable() api.assignments = append(api.assignments, assignment) diff --git a/std/gkr/gkr.go b/std/gkr/gkr.go index a715a9d98e..0da52730a9 100644 --- a/std/gkr/gkr.go +++ b/std/gkr/gkr.go @@ -1,6 +1,7 @@ package gkr import ( + "errors" "fmt" "strconv" @@ -190,7 +191,7 @@ func setup(api frontend.API, c Circuit, assignment WireAssignment, transcriptSet o.nbVars = assignment.NumVars() nbInstances := assignment.NumInstances() if 1< len(res)*int(nbBits) { - return fmt.Errorf("decomposed integer does not fit into res") + return errors.New("decomposed integer does not fit into res") } for _, r := range res { if r == nil { - return fmt.Errorf("result slice element uninitialized") + return errors.New("result slice element uninitialized") } } base := new(big.Int).Lsh(big.NewInt(1), nbBits) diff --git a/std/internal/logderivarg/logderivarg.go b/std/internal/logderivarg/logderivarg.go index 4dcc559331..a52961410d 100644 --- a/std/internal/logderivarg/logderivarg.go +++ b/std/internal/logderivarg/logderivarg.go @@ -39,6 +39,7 @@ package logderivarg // we have to show that all sorted values ara monotonically increasing. import ( + "errors" "fmt" "math/big" @@ -74,14 +75,14 @@ func AsTable(vector []frontend.Variable) Table { // linear combinations. func Build(api frontend.API, table Table, queries Table) error { if len(table) == 0 { - return fmt.Errorf("table empty") + return errors.New("table empty") } nbRow := len(table[0]) constTable := true countInputs := []frontend.Variable{len(table), nbRow} for i := range table { if len(table[i]) != nbRow { - return fmt.Errorf("table row length mismatch") + return errors.New("table row length mismatch") } if constTable { for j := range table[i] { @@ -94,7 +95,7 @@ func Build(api frontend.API, table Table, queries Table) error { } for i := range queries { if len(queries[i]) != nbRow { - return fmt.Errorf("query row length mismatch") + return errors.New("query row length mismatch") } countInputs = append(countInputs, queries[i]...) } diff --git a/std/internal/logderivprecomp/logderivprecomp.go b/std/internal/logderivprecomp/logderivprecomp.go index d768c10a32..36493391b5 100644 --- a/std/internal/logderivprecomp/logderivprecomp.go +++ b/std/internal/logderivprecomp/logderivprecomp.go @@ -13,7 +13,7 @@ package logderivprecomp import ( - "fmt" + "errors" "math/big" "reflect" @@ -53,7 +53,7 @@ func New(api frontend.API, fn solver.Hint, rets []uint) (*Precomputed, error) { s += v } if s >= uint(api.Compiler().FieldBitLen()) { - return nil, fmt.Errorf("result doesn't fit into field element") + return nil, errors.New("result doesn't fit into field element") } t := &Precomputed{ api: api, diff --git a/std/math/bitslice/hints.go b/std/math/bitslice/hints.go index d9797c6a9a..0ec8f298d7 100644 --- a/std/math/bitslice/hints.go +++ b/std/math/bitslice/hints.go @@ -1,7 +1,7 @@ package bitslice import ( - "fmt" + "errors" "math/big" "github.com/consensys/gnark/constraint/solver" @@ -19,13 +19,13 @@ func GetHints() []solver.Hint { func partitionHint(_ *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) != 2 { - return fmt.Errorf("expecting two inputs") + return errors.New("expecting two inputs") } if len(outputs) != 2 { - return fmt.Errorf("expecting two outputs") + return errors.New("expecting two outputs") } if !inputs[0].IsUint64() { - return fmt.Errorf("split location must be int") + return errors.New("split location must be int") } split := uint(inputs[0].Uint64()) div := new(big.Int).Lsh(big.NewInt(1), split) diff --git a/std/math/emulated/field.go b/std/math/emulated/field.go index a9a1761c62..7dca5383e1 100644 --- a/std/math/emulated/field.go +++ b/std/math/emulated/field.go @@ -1,6 +1,7 @@ package emulated import ( + "errors" "fmt" "math/big" "sync" @@ -75,17 +76,17 @@ func NewField[T FieldParams](native frontend.API) (*Field[T], error) { // ensure prime is correctly set if f.fParams.IsPrime() { if !f.fParams.Modulus().ProbablyPrime(20) { - return nil, fmt.Errorf("invalid parametrization: modulus is not prime") + return nil, errors.New("invalid parametrization: modulus is not prime") } } if f.fParams.BitsPerLimb() < 3 { // even three is way too small, but it should probably work. - return nil, fmt.Errorf("nbBits must be at least 3") + return nil, errors.New("nbBits must be at least 3") } if f.fParams.Modulus().Cmp(big.NewInt(1)) < 1 { - return nil, fmt.Errorf("n must be at least 2") + return nil, errors.New("n must be at least 2") } nbLimbs := (uint(f.fParams.Modulus().BitLen()) + f.fParams.BitsPerLimb() - 1) / f.fParams.BitsPerLimb() @@ -94,7 +95,7 @@ func NewField[T FieldParams](native frontend.API) (*Field[T], error) { } if f.api == nil { - return f, fmt.Errorf("missing api") + return f, errors.New("missing api") } if uint(f.api.Compiler().FieldBitLen()) < 2*f.fParams.BitsPerLimb()+1 { diff --git a/std/math/emulated/field_hint.go b/std/math/emulated/field_hint.go index 826f33c075..ac47768903 100644 --- a/std/math/emulated/field_hint.go +++ b/std/math/emulated/field_hint.go @@ -1,6 +1,7 @@ package emulated import ( + "errors" "fmt" "math/big" @@ -50,15 +51,15 @@ func UnwrapHintWithNativeInput(nativeInputs, nativeOutputs []*big.Int, nonnative func unwrapHint(isEmulatedInput, isEmulatedOutput bool, nativeInputs, nativeOutputs []*big.Int, nonnativeHint solver.Hint) error { if len(nativeInputs) < 2 { - return fmt.Errorf("hint wrapper header is 2 elements") + return errors.New("hint wrapper header is 2 elements") } if !nativeInputs[0].IsInt64() || !nativeInputs[1].IsInt64() { - return fmt.Errorf("header must be castable to int64") + return errors.New("header must be castable to int64") } nbBits := int(nativeInputs[0].Int64()) nbLimbs := int(nativeInputs[1].Int64()) if len(nativeInputs) < 2+nbLimbs { - return fmt.Errorf("hint wrapper header is 2+nbLimbs elements") + return errors.New("hint wrapper header is 2+nbLimbs elements") } nonnativeMod := new(big.Int) if err := limbs.Recompose(nativeInputs[2:2+nbLimbs], uint(nbBits), nonnativeMod); err != nil { @@ -67,7 +68,7 @@ func unwrapHint(isEmulatedInput, isEmulatedOutput bool, nativeInputs, nativeOutp var nonnativeInputs []*big.Int if isEmulatedInput { if !nativeInputs[2+nbLimbs].IsInt64() { - return fmt.Errorf("number of nonnative elements must be castable to int64") + return errors.New("number of nonnative elements must be castable to int64") } nbInputs := int(nativeInputs[2+nbLimbs].Int64()) readPtr := 3 + nbLimbs @@ -101,7 +102,7 @@ func unwrapHint(isEmulatedInput, isEmulatedOutput bool, nativeInputs, nativeOutp var nonnativeOutputs []*big.Int if isEmulatedOutput { if len(nativeOutputs)%nbLimbs != 0 { - return fmt.Errorf("output count doesn't divide limb count") + return errors.New("output count doesn't divide limb count") } nonnativeOutputs = make([]*big.Int, len(nativeOutputs)/nbLimbs) } else { diff --git a/std/math/emulated/field_mul.go b/std/math/emulated/field_mul.go index 92714fa16a..6d7e697eac 100644 --- a/std/math/emulated/field_mul.go +++ b/std/math/emulated/field_mul.go @@ -1,6 +1,7 @@ package emulated import ( + "errors" "fmt" "math/big" "math/bits" @@ -889,7 +890,7 @@ func (f *Field[T]) polyMvEvalQuoSize(mv *multivariate[T], at []*Element[T]) (quo // handles the input packing and output unpacking. func polyMvHint(mod *big.Int, inputs, outputs []*big.Int) error { if len(inputs) < 7 { - return fmt.Errorf("not enough inputs") + return errors.New("not enough inputs") } var ( nbBits = int(inputs[0].Int64()) @@ -901,7 +902,7 @@ func polyMvHint(mod *big.Int, inputs, outputs []*big.Int) error { nbCarryLimbs = int(inputs[5].Int64()) ) if len(outputs) != nbQuoLimbs+nbRemLimbs+nbCarryLimbs { - return fmt.Errorf("output length mismatch") + return errors.New("output length mismatch") } outPtr := 0 quoLimbs := outputs[outPtr : outPtr+nbQuoLimbs] @@ -943,7 +944,7 @@ func polyMvHint(mod *big.Int, inputs, outputs []*big.Int) error { } } if ptr != len(inputs) { - return fmt.Errorf("inputs not exhausted") + return errors.New("inputs not exhausted") } // recompose the inputs in limb-form to *big.Int form vars := make([]*big.Int, nbVars) diff --git a/std/math/emulated/hints.go b/std/math/emulated/hints.go index 28a84b9a84..1a2205121d 100644 --- a/std/math/emulated/hints.go +++ b/std/math/emulated/hints.go @@ -1,6 +1,7 @@ package emulated import ( + "errors" "fmt" "math/big" @@ -54,15 +55,15 @@ func (f *Field[T]) computeInverseHint(inLimbs []frontend.Variable) (inverseLimbs // InverseHint computes the inverse x^-1 for the input x and stores it in outputs. func InverseHint(mod *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) < 2 { - return fmt.Errorf("input must be at least two elements") + return errors.New("input must be at least two elements") } nbBits := uint(inputs[0].Uint64()) nbLimbs := int(inputs[1].Int64()) if len(inputs[2:]) < 2*nbLimbs { - return fmt.Errorf("inputs missing") + return errors.New("inputs missing") } if len(outputs) != nbLimbs { - return fmt.Errorf("result does not fit into output") + return errors.New("result does not fit into output") } p := new(big.Int) if err := limbs.Recompose(inputs[2:2+nbLimbs], nbBits, p); err != nil { @@ -73,7 +74,7 @@ func InverseHint(mod *big.Int, inputs []*big.Int, outputs []*big.Int) error { return fmt.Errorf("recompose value: %w", err) } if x.ModInverse(x, p) == nil { - return fmt.Errorf("input and modulus not relatively primes") + return errors.New("input and modulus not relatively primes") } if err := limbs.Decompose(x, nbBits, outputs); err != nil { return fmt.Errorf("decompose: %w", err) @@ -101,7 +102,7 @@ func (f *Field[T]) computeDivisionHint(nomLimbs, denomLimbs []frontend.Variable) // outputs. func DivHint(mod *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) < 3 { - return fmt.Errorf("input must be at least three elements") + return errors.New("input must be at least three elements") } nbBits := uint(inputs[0].Uint64()) nbLimbs := int(inputs[1].Int64()) @@ -110,10 +111,10 @@ func DivHint(mod *big.Int, inputs []*big.Int, outputs []*big.Int) error { // Denominator and order have to be nbLimbs long. nbNomLimbs := int(inputs[3].Int64()) if len(inputs[4:]) != nbLimbs+nbNomLimbs+nbDenomLimbs { - return fmt.Errorf("input length mismatch") + return errors.New("input length mismatch") } if len(outputs) != nbLimbs { - return fmt.Errorf("result does not fit into output") + return errors.New("result does not fit into output") } p := new(big.Int) if err := limbs.Recompose(inputs[4:4+nbLimbs], nbBits, p); err != nil { @@ -129,7 +130,7 @@ func DivHint(mod *big.Int, inputs []*big.Int, outputs []*big.Int) error { } res := new(big.Int).ModInverse(denominator, p) if res == nil { - return fmt.Errorf("no modular inverse") + return errors.New("no modular inverse") } res.Mul(res, nominator) res.Mod(res, p) @@ -143,14 +144,14 @@ func DivHint(mod *big.Int, inputs []*big.Int, outputs []*big.Int) error { func SqrtHint(mod *big.Int, inputs []*big.Int, outputs []*big.Int) error { return UnwrapHint(inputs, outputs, func(field *big.Int, inputs, outputs []*big.Int) error { if len(inputs) != 1 { - return fmt.Errorf("expecting single input") + return errors.New("expecting single input") } if len(outputs) != 1 { - return fmt.Errorf("expecting single output") + return errors.New("expecting single output") } res := new(big.Int) if res.ModSqrt(inputs[0], field) == nil { - return fmt.Errorf("no square root") + return errors.New("no square root") } outputs[0].Set(res) return nil diff --git a/std/math/emulated/subtraction_padding.go b/std/math/emulated/subtraction_padding.go index ae4ff8ddc6..454827796c 100644 --- a/std/math/emulated/subtraction_padding.go +++ b/std/math/emulated/subtraction_padding.go @@ -1,6 +1,7 @@ package emulated import ( + "errors" "fmt" "math/big" @@ -72,17 +73,17 @@ func subPadding(modulus *big.Int, bitsPerLimbs uint, overflow uint, nbLimbs uint // In case of fixed modulus use subPadding instead. func subPaddingHint(mod *big.Int, inputs, outputs []*big.Int) error { if len(inputs) < 4 { - return fmt.Errorf("input must be at least four elements") + return errors.New("input must be at least four elements") } nbLimbs := int(inputs[0].Int64()) bitsPerLimbs := uint(inputs[1].Uint64()) overflow := uint(inputs[2].Uint64()) retLimbs := int(inputs[3].Int64()) if len(inputs[4:]) != nbLimbs { - return fmt.Errorf("input length mismatch") + return errors.New("input length mismatch") } if len(outputs) != retLimbs { - return fmt.Errorf("result does not fit into output") + return errors.New("result does not fit into output") } pLimbs := inputs[4 : 4+nbLimbs] p := new(big.Int) diff --git a/std/math/polynomial/polynomial.go b/std/math/polynomial/polynomial.go index 59be7084f5..aa763cbe88 100644 --- a/std/math/polynomial/polynomial.go +++ b/std/math/polynomial/polynomial.go @@ -1,6 +1,7 @@ package polynomial import ( + "errors" "fmt" "math/big" "math/bits" @@ -120,7 +121,7 @@ func (p *Polynomial[FR]) EvalMultilinearMany(at []*emulated.Element[FR], M ...Mu lenM := len(M[0]) for i := range M { if len(M[i]) != lenM { - return nil, fmt.Errorf("incompatible multilinear polynomial sizes") + return nil, errors.New("incompatible multilinear polynomial sizes") } } mlelems := make([][]*emulated.Element[FR], len(M)) @@ -128,11 +129,11 @@ func (p *Polynomial[FR]) EvalMultilinearMany(at []*emulated.Element[FR], M ...Mu mlelems[i] = FromSlice(M[i]) } if bits.OnesCount(uint(lenM)) != 1 { - return nil, fmt.Errorf("multilinear polynomial length must be a power of 2") + return nil, errors.New("multilinear polynomial length must be a power of 2") } nbExpvars := bits.Len(uint(lenM)) - 1 if len(at) != nbExpvars { - return nil, fmt.Errorf("incompatible evaluation vector size") + return nil, errors.New("incompatible evaluation vector size") } split1 := nbExpvars / 2 nbSplit1Elems := 1 << split1 diff --git a/std/math/uints/hints.go b/std/math/uints/hints.go index 58edf9fd51..6e230ed8cf 100644 --- a/std/math/uints/hints.go +++ b/std/math/uints/hints.go @@ -1,7 +1,7 @@ package uints import ( - "fmt" + "errors" "math/big" "github.com/consensys/gnark/constraint/solver" @@ -37,17 +37,17 @@ func orHint(_ *big.Int, inputs, outputs []*big.Int) error { func toBytes(m *big.Int, inputs []*big.Int, outputs []*big.Int) error { if len(inputs) != 2 { - return fmt.Errorf("input must be 2 elements") + return errors.New("input must be 2 elements") } if !inputs[0].IsUint64() { - return fmt.Errorf("first input must be uint64") + return errors.New("first input must be uint64") } nbLimbs := int(inputs[0].Uint64()) if len(outputs) != nbLimbs { - return fmt.Errorf("output must be 8 elements") + return errors.New("output must be 8 elements") } if !inputs[1].IsUint64() { - return fmt.Errorf("input must be 64 bits") + return errors.New("input must be 64 bits") } base := new(big.Int).Lsh(big.NewInt(1), uint(8)) tmp := new(big.Int).Set(inputs[1]) diff --git a/std/sumcheck/sumcheck.go b/std/sumcheck/sumcheck.go index de3689cbb8..ad96621c96 100644 --- a/std/sumcheck/sumcheck.go +++ b/std/sumcheck/sumcheck.go @@ -1,7 +1,7 @@ package sumcheck import ( - "fmt" + "errors" "strconv" "github.com/consensys/gnark/frontend" @@ -87,7 +87,7 @@ func Verify(api frontend.API, claims LazyClaims, proof Proof, transcriptSettings for j := 0; j < claims.VarsNum(); j++ { partialSumPoly := proof.PartialSumPolys[j] //proof.PartialSumPolys(j) if len(partialSumPoly) != claims.Degree(j) { - return fmt.Errorf("malformed proof") //Malformed proof + return errors.New("malformed proof") //Malformed proof } copy(gJ[1:], partialSumPoly) gJ[0] = api.Sub(gJR, partialSumPoly[0]) // Requirement that gⱼ(0) + gⱼ(1) = gⱼ₋₁(r) From fa2fcc703bd8aa8d2a209805bc00261a4fc37c7f Mon Sep 17 00:00:00 2001 From: taikoon Date: Wed, 11 Dec 2024 16:45:04 +0800 Subject: [PATCH 11/16] chore: fix error message (#1337) --- std/evmprecompiles/hints.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/evmprecompiles/hints.go b/std/evmprecompiles/hints.go index 1ff0021ebe..fb3665f332 100644 --- a/std/evmprecompiles/hints.go +++ b/std/evmprecompiles/hints.go @@ -42,7 +42,7 @@ func recoverPublicKeyHint(_ *big.Int, inputs []*big.Int, outputs []*big.Int) err return fmt.Errorf("expected %d limbs got %d", emfr.NbLimbs()*3+1, len(inputs)) } if !inputs[emfr.NbLimbs()].IsInt64() { - return fmt.Errorf("second input input must be in [0,3]") + return fmt.Errorf("second input must be in [0,3]") } if len(outputs) != 2*int(emfp.NbLimbs())+1 { return fmt.Errorf("expected output %d limbs got %d", 2*emfp.NbLimbs(), len(outputs)) From f55f7a4846c2bc61305e86318196be2004f3c4e2 Mon Sep 17 00:00:00 2001 From: argentpapa Date: Fri, 20 Dec 2024 22:57:18 +0800 Subject: [PATCH 12/16] fix: spellchecker (#1359) Co-authored-by: Gautam Botrel --- std/math/emulated/emparams/emparams.go | 2 +- std/math/emulated/field_assert.go | 2 +- std/permutation/poseidon2/poseidon2.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/std/math/emulated/emparams/emparams.go b/std/math/emulated/emparams/emparams.go index b6ac1ce9ab..51e3ed8c2e 100644 --- a/std/math/emulated/emparams/emparams.go +++ b/std/math/emulated/emparams/emparams.go @@ -313,7 +313,7 @@ type STARKCurveFr struct{ fourLimbPrimeField } func (fp STARKCurveFr) Modulus() *big.Int { return ecc.STARK_CURVE.ScalarField() } -// Mod1e4096 provides type parametrization for emulated aritmetic: +// Mod1e4096 provides type parametrization for emulated arithmetic: // - limbs: 64 // - limb width: 64 bits // diff --git a/std/math/emulated/field_assert.go b/std/math/emulated/field_assert.go index 3cac83ea2c..e33409e4bc 100644 --- a/std/math/emulated/field_assert.go +++ b/std/math/emulated/field_assert.go @@ -108,7 +108,7 @@ func (f *Field[T]) IsZero(a *Element[T]) frontend.Variable { // in this case the result can be either 0 or p (if it is zero). // // so we check that the reduced value limbs are either all zeros or - // corrspond to the modulus limbs. + // correspond to the modulus limbs. ca := f.Reduce(a) p := f.Modulus() diff --git a/std/permutation/poseidon2/poseidon2.go b/std/permutation/poseidon2/poseidon2.go index 0e403e15da..00fb9306fd 100644 --- a/std/permutation/poseidon2/poseidon2.go +++ b/std/permutation/poseidon2/poseidon2.go @@ -147,7 +147,7 @@ func (h *Hash) sBox(api frontend.API, index int, input []frontend.Variable) { // (4 6 1 1) // (1 3 5 7) // (1 1 4 6) -// on chunks of 4 elemts on each part of the buffer +// on chunks of 4 elements on each part of the buffer // see https://eprint.iacr.org/2023/323.pdf appendix B for the addition chain func (h *Hash) matMulM4InPlace(api frontend.API, s []frontend.Variable) { c := len(s) / 4 From 74f72d900abec52eb8d20f513900255a39543330 Mon Sep 17 00:00:00 2001 From: teenager-ETH Date: Fri, 20 Dec 2024 16:00:19 +0100 Subject: [PATCH 13/16] Fix Typos Across Multiple Files for Enhanced Clarity and Accuracy (#1364) Co-authored-by: Gautam Botrel --- backend/groth16/bn254/solidity.go | 2 +- std/hash/ripemd160/ripemd160_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/groth16/bn254/solidity.go b/backend/groth16/bn254/solidity.go index 31255fb94a..d9c8b0130a 100644 --- a/backend/groth16/bn254/solidity.go +++ b/backend/groth16/bn254/solidity.go @@ -206,7 +206,7 @@ contract Verifier { /// @notice Will revert with InvalidProof() if /// * the input is not a square, /// * the hint is incorrect, or - /// * the input coefficents are not reduced. + /// * the input coefficients are not reduced. /// @param a0 The real part of the input. /// @param a1 The imaginary part of the input. /// @param hint A hint which of two possible signs to pick in the equation. diff --git a/std/hash/ripemd160/ripemd160_test.go b/std/hash/ripemd160/ripemd160_test.go index 83f37cbd04..87db38d626 100644 --- a/std/hash/ripemd160/ripemd160_test.go +++ b/std/hash/ripemd160/ripemd160_test.go @@ -8,7 +8,7 @@ import ( "github.com/consensys/gnark/frontend" "github.com/consensys/gnark/std/math/uints" "github.com/consensys/gnark/test" - "golang.org/x/crypto/ripemd160" //nolint staticcheck, backwards compatiblity + "golang.org/x/crypto/ripemd160" //nolint staticcheck, backwards compatibility ) type ripemd160Circuit struct { From 93c6ed71fc09a7b631f1eb2ca2743b842ce4b561 Mon Sep 17 00:00:00 2001 From: chloefeal <188809157+chloefeal@users.noreply.github.com> Date: Thu, 26 Dec 2024 07:09:42 +0800 Subject: [PATCH 14/16] chore: fix typos (#1371) Co-authored-by: Ivo Kubjas --- std/math/bitslice/partition.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/math/bitslice/partition.go b/std/math/bitslice/partition.go index 7b07c3f983..17987eecd4 100644 --- a/std/math/bitslice/partition.go +++ b/std/math/bitslice/partition.go @@ -9,7 +9,7 @@ import ( "github.com/consensys/gnark/std/rangecheck" ) -// Partition partitions v into two parts splitted at bit numbered split. The +// Partition partitions v into two parts split at bit numbered split. The // following holds // // v = lower + 2^split * upper. From 2dd099ffd6e732d21bd8cde2731b4518e6b530c6 Mon Sep 17 00:00:00 2001 From: "fuder.eth" <139509124+vtjl10@users.noreply.github.com> Date: Thu, 26 Dec 2024 01:10:39 +0200 Subject: [PATCH 15/16] fix: typos in documentation files (#1369) --- std/math/emulated/element_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/math/emulated/element_test.go b/std/math/emulated/element_test.go index 510d3d6a96..d5a6901086 100644 --- a/std/math/emulated/element_test.go +++ b/std/math/emulated/element_test.go @@ -1482,7 +1482,7 @@ func (c *FastPathsCircuit[T]) Define(api frontend.API) error { return nil } -func TestFasthPaths(t *testing.T) { +func TestFastPaths(t *testing.T) { testFastPaths[Goldilocks](t) testFastPaths[BN254Fr](t) testFastPaths[emparams.Mod1e512](t) From a7fd50864b2f50d8a477e5c22cf2e33f82beee3a Mon Sep 17 00:00:00 2001 From: linchizhen Date: Thu, 26 Dec 2024 07:11:39 +0800 Subject: [PATCH 16/16] chore: fix some struct names in comment (#1370) Signed-off-by: linchizhen --- std/hash/mimc/mimc_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/hash/mimc/mimc_test.go b/std/hash/mimc/mimc_test.go index 019862cb34..8efc7cdc87 100644 --- a/std/hash/mimc/mimc_test.go +++ b/std/hash/mimc/mimc_test.go @@ -84,7 +84,7 @@ func TestMimcAll(t *testing.T) { } -// stateStoreCircuit checks that SetState works as expected. The circuit, however +// stateStoreTestCircuit checks that SetState works as expected. The circuit, however // does not check the correctness of the hashes returned by the MiMC function // as there is another test already testing this property. type stateStoreTestCircuit struct {