diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 637df2e2be..c486d09455 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -22,7 +22,7 @@ assignees: '' ## Steps to Reproduce - + 1. 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 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 diff --git a/frontend/api.go b/frontend/api.go index a09bce9299..5bfb761574 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 @@ -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/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) { 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 } 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 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/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/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)) 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/doc.go b/std/math/emulated/doc.go index 48ff30a7f8..64451297dc 100644 --- a/std/math/emulated/doc.go +++ b/std/math/emulated/doc.go @@ -70,7 +70,7 @@ overflow. The total maximal bitwidth of the limbs is then w+f. Keep in mind that parameter w is global for all emulated elements and f is -individual for every individual element. +individual for each individual element. To compute the overflow for the operations, we consider the arithmetic operations which affect the overflow. In this implementation only addition is @@ -125,7 +125,7 @@ through the following identity: # Subtraction We perform subtraction limb-wise between the elements x and y. However, we have -to ensure than any limb in the result does not result in overflow, i.e. +to ensure that any limb in the result does not result in overflow, i.e. x_i ≥ y_i, ∀ 0≤i