From 546848bed2329a126576442283973eb5331f08d0 Mon Sep 17 00:00:00 2001 From: bytetigers Date: Fri, 30 Aug 2024 16:06:46 +0800 Subject: [PATCH 1/5] refactor: use strings.ReplaceAll (#1257) --- profile/internal/graph/dotgraph.go | 6 +++--- profile/profile_worker.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/profile/internal/graph/dotgraph.go b/profile/internal/graph/dotgraph.go index 6282bf9272..a65e15e113 100644 --- a/profile/internal/graph/dotgraph.go +++ b/profile/internal/graph/dotgraph.go @@ -384,11 +384,11 @@ func dotColor(score float64, isBackground bool) string { func multilinePrintableName(info *NodeInfo) string { infoCopy := *info infoCopy.Name = escapeForDot(ShortenFunctionName(infoCopy.Name)) - infoCopy.Name = strings.Replace(infoCopy.Name, "::", `\n`, -1) + infoCopy.Name = strings.ReplaceAll(infoCopy.Name, "::", `\n`) // Go type parameters are reported as "[...]" by Go pprof profiles. // Keep this ellipsis rather than replacing with newlines below. - infoCopy.Name = strings.Replace(infoCopy.Name, "[...]", "[…]", -1) - infoCopy.Name = strings.Replace(infoCopy.Name, ".", `\n`, -1) + infoCopy.Name = strings.ReplaceAll(infoCopy.Name, "[...]", "[…]") + infoCopy.Name = strings.ReplaceAll(infoCopy.Name, ".", `\n`) if infoCopy.File != "" { infoCopy.File = filepath.Base(infoCopy.File) } diff --git a/profile/profile_worker.go b/profile/profile_worker.go index 62b4a453fb..fefe77413c 100644 --- a/profile/profile_worker.go +++ b/profile/profile_worker.go @@ -83,7 +83,7 @@ func collectSample(pc []uintptr) { // TODO @gbotrel [...] -> from generics display poorly in pprof // https://github.com/golang/go/issues/54105 - frame.Function = strings.Replace(frame.Function, "[...]", "[T]", -1) + frame.Function = strings.ReplaceAll(frame.Function, "[...]", "[T]") for i := 0; i < len(samples); i++ { samples[i].Location = append(samples[i].Location, sessions[i].getLocation(&frame)) From 8d4704b20d4d169c6de821fd92ba63dcb6e2d6c7 Mon Sep 17 00:00:00 2001 From: highcloudwind Date: Fri, 30 Aug 2024 16:19:42 +0800 Subject: [PATCH 2/5] chore: fix some function names (#1240) Signed-off-by: highcloudwind Co-authored-by: Ivo Kubjas --- std/algebra/emulated/fields_bw6761/e6_pairing.go | 2 +- std/algebra/native/sw_bls24315/pairing2.go | 2 +- std/hash/mimc/encrypt.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/std/algebra/emulated/fields_bw6761/e6_pairing.go b/std/algebra/emulated/fields_bw6761/e6_pairing.go index 8907c0535b..e2715f3cca 100644 --- a/std/algebra/emulated/fields_bw6761/e6_pairing.go +++ b/std/algebra/emulated/fields_bw6761/e6_pairing.go @@ -81,7 +81,7 @@ func (e Ext6) ExpX0Plus1(z *E6) *E6 { return result } -// ExpX0Minus1Div3 set z to z^(x₀-1)/3 in E6 and return z +// ExptMinus1Div3 set z to z^(x₀-1)/3 in E6 and return z // (x₀-1)/3 = 3195374304363544576 func (e Ext6) ExptMinus1Div3(z *E6) *E6 { z = e.Reduce(z) diff --git a/std/algebra/native/sw_bls24315/pairing2.go b/std/algebra/native/sw_bls24315/pairing2.go index a6d67db967..405d53b2b3 100644 --- a/std/algebra/native/sw_bls24315/pairing2.go +++ b/std/algebra/native/sw_bls24315/pairing2.go @@ -334,7 +334,7 @@ func NewG1Affine(v bls24315.G1Affine) G1Affine { } } -// NewG2Affine allocates a witness from the native G2 element and returns it. +// newG2AffP allocates a witness from the native G2 element and returns it. func newG2AffP(v bls24315.G2Affine) g2AffP { return g2AffP{ X: fields_bls24315.E4{ diff --git a/std/hash/mimc/encrypt.go b/std/hash/mimc/encrypt.go index 664a5281e2..78efcfaf81 100644 --- a/std/hash/mimc/encrypt.go +++ b/std/hash/mimc/encrypt.go @@ -142,7 +142,7 @@ func pow17(api frontend.API, x frontend.Variable) frontend.Variable { return api.Mul(r, x) } -// encryptBn256 of a mimc run expressed as r1cs +// encryptPow5 of a mimc run expressed as r1cs // m is the message, k the key func encryptPow5(h MiMC, m frontend.Variable) frontend.Variable { x := m @@ -152,7 +152,7 @@ func encryptPow5(h MiMC, m frontend.Variable) frontend.Variable { return h.api.Add(x, h.h) } -// encryptBLS24317 of a mimc run expressed as r1cs +// encryptPow7 of a mimc run expressed as r1cs // m is the message, k the key func encryptPow7(h MiMC, m frontend.Variable) frontend.Variable { x := m @@ -162,7 +162,7 @@ func encryptPow7(h MiMC, m frontend.Variable) frontend.Variable { return h.api.Add(x, h.h) } -// encryptBLS377 of a mimc run expressed as r1cs +// encryptPow17 of a mimc run expressed as r1cs // m is the message, k the key func encryptPow17(h MiMC, m frontend.Variable) frontend.Variable { x := m From 1e1d6b1f71f17e6ea3b15a7cc8fc2ca98220dbfc Mon Sep 17 00:00:00 2001 From: shuriu <161208801+shuriu@users.noreply.github.com> Date: Fri, 30 Aug 2024 09:29:29 +0100 Subject: [PATCH 3/5] fix: fix most typos (#1185) * fix: fix most typos * fix: update template --------- Co-authored-by: Ivo Kubjas --- backend/plonk/bls12-377/prove.go | 2 +- backend/plonk/bls12-381/prove.go | 2 +- backend/plonk/bls24-315/prove.go | 2 +- backend/plonk/bls24-317/prove.go | 2 +- backend/plonk/bn254/prove.go | 2 +- backend/plonk/bw6-633/prove.go | 2 +- backend/plonk/bw6-761/prove.go | 2 +- constraint/solver/hint.go | 2 +- constraint/solver/hint_test.go | 2 +- examples/rollup/error.go | 2 +- frontend/api.go | 4 ++-- frontend/compile.go | 2 +- frontend/cs/r1cs/r1cs_test.go | 2 +- .../backend/template/zkpschemes/plonk/plonk.prove.go.tmpl | 2 +- profile/internal/measurement/measurement.go | 2 +- profile/internal/report/report.go | 2 +- std/algebra/emulated/sw_bls12381/g1.go | 6 +++--- std/algebra/emulated/sw_bls12381/g2.go | 4 ++-- std/algebra/emulated/sw_bls12381/pairing.go | 6 +++--- std/algebra/emulated/sw_bn254/g1.go | 4 ++-- std/algebra/emulated/sw_bn254/g2.go | 2 +- std/algebra/emulated/sw_bn254/pairing.go | 4 ++-- std/algebra/emulated/sw_bw6761/g1.go | 8 ++++---- std/algebra/emulated/sw_bw6761/g2.go | 4 ++-- std/algebra/emulated/sw_emulated/point.go | 6 +++--- std/algebra/native/twistededwards/curve_test.go | 2 +- std/gkr/compile.go | 2 +- std/hash/hash.go | 2 +- std/math/cmp/bounded.go | 2 +- std/math/emulated/emparams/emparams.go | 6 +++--- std/math/emulated/field_mul.go | 2 +- std/multicommit/nativecommit.go | 6 +++--- std/recursion/groth16/nonnative_doc_test.go | 2 +- std/recursion/plonk/nonnative_doc_test.go | 2 +- std/recursion/plonk/verifier.go | 4 ++-- 35 files changed, 54 insertions(+), 54 deletions(-) diff --git a/backend/plonk/bls12-377/prove.go b/backend/plonk/bls12-377/prove.go index c5380230ea..f4ee3fd2f3 100644 --- a/backend/plonk/bls12-377/prove.go +++ b/backend/plonk/bls12-377/prove.go @@ -941,7 +941,7 @@ func (s *instance) computeNumerator() (*iop.Polynomial, error) { // we do **a lot** of FFT here, but on the small domain. // note that for all the polynomials in the proving key // (Ql, Qr, Qm, Qo, S1, S2, S3, Qcp, Qc) and ID, LOne - // we could pre-compute theses rho*2 FFTs and store them + // we could pre-compute these rho*2 FFTs and store them // at the cost of a huge memory footprint. batchApply(s.x, func(p *iop.Polynomial) { nbTasks := calculateNbTasks(len(s.x)-1) * 2 diff --git a/backend/plonk/bls12-381/prove.go b/backend/plonk/bls12-381/prove.go index 69944d248f..4541252745 100644 --- a/backend/plonk/bls12-381/prove.go +++ b/backend/plonk/bls12-381/prove.go @@ -941,7 +941,7 @@ func (s *instance) computeNumerator() (*iop.Polynomial, error) { // we do **a lot** of FFT here, but on the small domain. // note that for all the polynomials in the proving key // (Ql, Qr, Qm, Qo, S1, S2, S3, Qcp, Qc) and ID, LOne - // we could pre-compute theses rho*2 FFTs and store them + // we could pre-compute these rho*2 FFTs and store them // at the cost of a huge memory footprint. batchApply(s.x, func(p *iop.Polynomial) { nbTasks := calculateNbTasks(len(s.x)-1) * 2 diff --git a/backend/plonk/bls24-315/prove.go b/backend/plonk/bls24-315/prove.go index a26b5b68a7..2aac05cb74 100644 --- a/backend/plonk/bls24-315/prove.go +++ b/backend/plonk/bls24-315/prove.go @@ -941,7 +941,7 @@ func (s *instance) computeNumerator() (*iop.Polynomial, error) { // we do **a lot** of FFT here, but on the small domain. // note that for all the polynomials in the proving key // (Ql, Qr, Qm, Qo, S1, S2, S3, Qcp, Qc) and ID, LOne - // we could pre-compute theses rho*2 FFTs and store them + // we could pre-compute these rho*2 FFTs and store them // at the cost of a huge memory footprint. batchApply(s.x, func(p *iop.Polynomial) { nbTasks := calculateNbTasks(len(s.x)-1) * 2 diff --git a/backend/plonk/bls24-317/prove.go b/backend/plonk/bls24-317/prove.go index cb292bcc86..20d3eeb389 100644 --- a/backend/plonk/bls24-317/prove.go +++ b/backend/plonk/bls24-317/prove.go @@ -941,7 +941,7 @@ func (s *instance) computeNumerator() (*iop.Polynomial, error) { // we do **a lot** of FFT here, but on the small domain. // note that for all the polynomials in the proving key // (Ql, Qr, Qm, Qo, S1, S2, S3, Qcp, Qc) and ID, LOne - // we could pre-compute theses rho*2 FFTs and store them + // we could pre-compute these rho*2 FFTs and store them // at the cost of a huge memory footprint. batchApply(s.x, func(p *iop.Polynomial) { nbTasks := calculateNbTasks(len(s.x)-1) * 2 diff --git a/backend/plonk/bn254/prove.go b/backend/plonk/bn254/prove.go index 6b2e90a05f..08e431cca7 100644 --- a/backend/plonk/bn254/prove.go +++ b/backend/plonk/bn254/prove.go @@ -941,7 +941,7 @@ func (s *instance) computeNumerator() (*iop.Polynomial, error) { // we do **a lot** of FFT here, but on the small domain. // note that for all the polynomials in the proving key // (Ql, Qr, Qm, Qo, S1, S2, S3, Qcp, Qc) and ID, LOne - // we could pre-compute theses rho*2 FFTs and store them + // we could pre-compute these rho*2 FFTs and store them // at the cost of a huge memory footprint. batchApply(s.x, func(p *iop.Polynomial) { nbTasks := calculateNbTasks(len(s.x)-1) * 2 diff --git a/backend/plonk/bw6-633/prove.go b/backend/plonk/bw6-633/prove.go index 5f0ff6b701..30b0b64ab4 100644 --- a/backend/plonk/bw6-633/prove.go +++ b/backend/plonk/bw6-633/prove.go @@ -941,7 +941,7 @@ func (s *instance) computeNumerator() (*iop.Polynomial, error) { // we do **a lot** of FFT here, but on the small domain. // note that for all the polynomials in the proving key // (Ql, Qr, Qm, Qo, S1, S2, S3, Qcp, Qc) and ID, LOne - // we could pre-compute theses rho*2 FFTs and store them + // we could pre-compute these rho*2 FFTs and store them // at the cost of a huge memory footprint. batchApply(s.x, func(p *iop.Polynomial) { nbTasks := calculateNbTasks(len(s.x)-1) * 2 diff --git a/backend/plonk/bw6-761/prove.go b/backend/plonk/bw6-761/prove.go index a35d11ea01..0635e1473a 100644 --- a/backend/plonk/bw6-761/prove.go +++ b/backend/plonk/bw6-761/prove.go @@ -941,7 +941,7 @@ func (s *instance) computeNumerator() (*iop.Polynomial, error) { // we do **a lot** of FFT here, but on the small domain. // note that for all the polynomials in the proving key // (Ql, Qr, Qm, Qo, S1, S2, S3, Qcp, Qc) and ID, LOne - // we could pre-compute theses rho*2 FFTs and store them + // we could pre-compute these rho*2 FFTs and store them // at the cost of a huge memory footprint. batchApply(s.x, func(p *iop.Polynomial) { nbTasks := calculateNbTasks(len(s.x)-1) * 2 diff --git a/constraint/solver/hint.go b/constraint/solver/hint.go index 9526151605..263d5b3c95 100644 --- a/constraint/solver/hint.go +++ b/constraint/solver/hint.go @@ -100,7 +100,7 @@ func GetHintID(fn Hint) HintID { hf := fnv.New32a() name := GetHintName(fn) - // TODO relying on name to derive UUID is risky; if fn is an anonymous func, wil be package.glob..funcN + // TODO relying on name to derive UUID is risky; if fn is an anonymous func, will be package.glob..funcN // and if new anonymous functions are added in the package, N may change, so will UUID. hf.Write([]byte(name)) // #nosec G104 -- does not err diff --git a/constraint/solver/hint_test.go b/constraint/solver/hint_test.go index ee073b4a36..f4b6a54d9c 100644 --- a/constraint/solver/hint_test.go +++ b/constraint/solver/hint_test.go @@ -8,7 +8,7 @@ func TestRegexpRename(t *testing.T) { {"github.com/consensys/gnark/internal/regression_tests/issue1045.init.func1", "github.com/consensys/gnark/internal/regression_tests/issue1045.glob..func1"}, // conversion from old to old same {"github.com/consensys/gnark/internal/regression_tests/issue1045.glob..func1", "github.com/consensys/gnark/internal/regression_tests/issue1045.glob..func1"}, - // conversion from explicit to explit same + // conversion from explicit to explicit same {"github.com/consensys/gnark/internal/regression_tests/issue1045.ExplicitHint", "github.com/consensys/gnark/internal/regression_tests/issue1045.ExplicitHint"}, } { if got := newToOldStyle(v.input); got != v.expected { diff --git a/examples/rollup/error.go b/examples/rollup/error.go index b712599090..ebf8504a1f 100644 --- a/examples/rollup/error.go +++ b/examples/rollup/error.go @@ -34,7 +34,7 @@ var ( // ErrNonce inconsistent nonce between transfer and account ErrNonce = errors.New("incorrect nonce") - // ErrIndexConsistency the map publicKey(string) -> index(int) gives acces to the account position. + // ErrIndexConsistency the map publicKey(string) -> index(int) gives access to the account position. // Account has a field index, that should match position. ErrIndexConsistency = errors.New("account's position should match account's index") ) diff --git a/frontend/api.go b/frontend/api.go index 4daa79cf33..c2b9d05a53 100644 --- a/frontend/api.go +++ b/frontend/api.go @@ -106,7 +106,7 @@ type API interface { // * -1 if i1 bound. // // If the absolute difference between the variables b and bound is known, then - // it is more efficient to use the bounded methdods in package + // it is more efficient to use the bounded methods in package // [github.com/consensys/gnark/std/math/bits]. AssertIsLessOrEqual(v Variable, bound Variable) diff --git a/frontend/compile.go b/frontend/compile.go index 072aca1c34..23110ddac4 100644 --- a/frontend/compile.go +++ b/frontend/compile.go @@ -78,7 +78,7 @@ func parseCircuit(builder Builder, circuit Circuit) (err error) { log := logger.Logger() log.Info().Int("nbSecret", s.Secret).Int("nbPublic", s.Public).Msg("parsed circuit inputs") - // leaf handlers are called when encoutering leafs in the circuit data struct + // leaf handlers are called when encountering leafs in the circuit data struct // leafs are Constraints that need to be initialized in the context of compiling a circuit variableAdder := func(targetVisibility schema.Visibility) func(f schema.LeafInfo, tInput reflect.Value) error { return func(f schema.LeafInfo, tInput reflect.Value) error { diff --git a/frontend/cs/r1cs/r1cs_test.go b/frontend/cs/r1cs/r1cs_test.go index 02762db1e0..4999c13bbf 100644 --- a/frontend/cs/r1cs/r1cs_test.go +++ b/frontend/cs/r1cs/r1cs_test.go @@ -113,7 +113,7 @@ func BenchmarkReduce(b *testing.B) { mL := make([]frontend.Variable, 1000) b.ResetTimer() - b.Run("reduce redudancy", func(b *testing.B) { + b.Run("reduce redundancy", func(b *testing.B) { for i := 0; i < b.N; i++ { mL[i%len(mL)] = cs.Add(rand.Uint64(), rL[0], rL[1:]...) //#nosec G404 -- This is a false positive } diff --git a/internal/generator/backend/template/zkpschemes/plonk/plonk.prove.go.tmpl b/internal/generator/backend/template/zkpschemes/plonk/plonk.prove.go.tmpl index 1c0e634b15..ce258ef5c8 100644 --- a/internal/generator/backend/template/zkpschemes/plonk/plonk.prove.go.tmpl +++ b/internal/generator/backend/template/zkpschemes/plonk/plonk.prove.go.tmpl @@ -918,7 +918,7 @@ func (s *instance) computeNumerator() (*iop.Polynomial, error) { // we do **a lot** of FFT here, but on the small domain. // note that for all the polynomials in the proving key // (Ql, Qr, Qm, Qo, S1, S2, S3, Qcp, Qc) and ID, LOne - // we could pre-compute theses rho*2 FFTs and store them + // we could pre-compute these rho*2 FFTs and store them // at the cost of a huge memory footprint. batchApply(s.x, func(p *iop.Polynomial) { nbTasks := calculateNbTasks(len(s.x)-1) * 2 diff --git a/profile/internal/measurement/measurement.go b/profile/internal/measurement/measurement.go index b5fcfbc3e4..4f8ba245e5 100644 --- a/profile/internal/measurement/measurement.go +++ b/profile/internal/measurement/measurement.go @@ -206,7 +206,7 @@ func (ut unitType) findByAlias(alias string) *unit { return nil } -// sniffUnit simpifies the input alias and returns the unit associated with the +// sniffUnit simplifies the input alias and returns the unit associated with the // specified alias. It returns nil if the unit with such alias is not found. func (ut unitType) sniffUnit(unit string) *unit { unit = strings.ToLower(unit) diff --git a/profile/internal/report/report.go b/profile/internal/report/report.go index f89c33be36..4b4112a6e9 100644 --- a/profile/internal/report/report.go +++ b/profile/internal/report/report.go @@ -285,7 +285,7 @@ func (rpt *Report) newGraph(nodes graph.NodeSet) *graph.Graph { return graph.New(rpt.prof, gopt) } -// printProto writes the incoming proto via thw writer w. +// printProto writes the incoming proto via the writer w. // If the divide_by option has been specified, samples are scaled appropriately. func printProto(w io.Writer, rpt *Report) error { p, o := rpt.prof, rpt.options diff --git a/std/algebra/emulated/sw_bls12381/g1.go b/std/algebra/emulated/sw_bls12381/g1.go index 7b8c539712..161db08538 100644 --- a/std/algebra/emulated/sw_bls12381/g1.go +++ b/std/algebra/emulated/sw_bls12381/g1.go @@ -118,7 +118,7 @@ func (g1 G1) doubleAndAdd(p, q *G1Affine) *G1Affine { xqxp = g1.curveF.Add(&p.X, &q.X) x2 := g1.curveF.Sub(λ1λ1, xqxp) - // ommit y1 computation + // omit y1 computation // compute λ1 = -λ1-1*p.y/(x1-p.x) ypyp := g1.curveF.Add(&p.Y, &p.Y) x2xp := g1.curveF.Sub(x2, &p.X) @@ -173,8 +173,8 @@ func NewScalar(v fr_bls12381.Element) Scalar { return emulated.ValueOf[ScalarField](v) } -// ScalarField is the [emulated.FieldParams] impelementation of the curve scalar field. +// ScalarField is the [emulated.FieldParams] implementation of the curve scalar field. type ScalarField = emulated.BLS12381Fr -// BaseField is the [emulated.FieldParams] impelementation of the curve base field. +// BaseField is the [emulated.FieldParams] implementation of the curve base field. type BaseField = emulated.BLS12381Fp diff --git a/std/algebra/emulated/sw_bls12381/g2.go b/std/algebra/emulated/sw_bls12381/g2.go index c607c50693..e6a275cfbb 100644 --- a/std/algebra/emulated/sw_bls12381/g2.go +++ b/std/algebra/emulated/sw_bls12381/g2.go @@ -198,7 +198,7 @@ func (g2 G2) triple(p *G2Affine) *G2Affine { λ1λ1 := g2.Square(λ1) x2 = g2.Sub(λ1λ1, x2) - // ommit y2 computation, and + // omit y2 computation, and // compute λ2 = 2p.y/(x2 − p.x) − λ1. x1x2 := g2.Sub(&p.P.X, x2) λ2 := g2.DivUnchecked(y2, x1x2) @@ -234,7 +234,7 @@ func (g2 G2) doubleAndAdd(p, q *G2Affine) *G2Affine { xqxp = g2.Ext2.Add(&p.P.X, &q.P.X) x2 := g2.Ext2.Sub(λ1λ1, xqxp) - // ommit y2 computation + // omit y2 computation // compute λ2 = -λ1-2*p.y/(x2-p.x) ypyp := g2.Ext2.Add(&p.P.Y, &p.P.Y) x2xp := g2.Ext2.Sub(x2, &p.P.X) diff --git a/std/algebra/emulated/sw_bls12381/pairing.go b/std/algebra/emulated/sw_bls12381/pairing.go index 4bc99671d6..3763c46d51 100644 --- a/std/algebra/emulated/sw_bls12381/pairing.go +++ b/std/algebra/emulated/sw_bls12381/pairing.go @@ -156,7 +156,7 @@ func (pr Pairing) finalExponentiation(e *GTEl, unsafe bool) *GTEl { if unsafe { // The Miller loop result is ≠ {-1,1}, otherwise this means P and Q are - // linearly dependant and not from G1 and G2 respectively. + // linearly dependent and not from G1 and G2 respectively. // So e ∈ G_{q,2} \ {-1,1} and hence e.C1 ≠ 0. // Nothing to do. @@ -213,7 +213,7 @@ func (pr Pairing) finalExponentiation(e *GTEl, unsafe bool) *GTEl { result = *pr.DecompressTorus(pr.MulTorus(c, t1)) } else { // For a product of pairings this might happen when the result is expected to be 1. - // We assign a dummy value (1) to t1 and proceed furhter. + // We assign a dummy value (1) to t1 and proceed further. // Finally we do a select on both edge cases: // - Only if seletor1=0 and selector2=0, we return MulTorus(c, t1) decompressed. // - Otherwise, we return 1. @@ -548,7 +548,7 @@ func (pr Pairing) tripleStep(p1 *g2AffP) (*g2AffP, *lineEvaluation, *lineEvaluat x2 := pr.Ext2.Square(λ1) x2 = pr.Ext2.Sub(x2, pr.Ext2.MulByConstElement(&p1.X, big.NewInt(2))) - // ommit yr computation, and + // omit yr computation, and // compute λ2 = 2y/(x2 − x) − λ1. x1x2 := pr.Ext2.Sub(&p1.X, x2) λ2 := pr.Ext2.DivUnchecked(d, x1x2) diff --git a/std/algebra/emulated/sw_bn254/g1.go b/std/algebra/emulated/sw_bn254/g1.go index 82b9bb7689..05ae12a4c2 100644 --- a/std/algebra/emulated/sw_bn254/g1.go +++ b/std/algebra/emulated/sw_bn254/g1.go @@ -28,8 +28,8 @@ func NewScalar(v fr_bn254.Element) Scalar { return emulated.ValueOf[ScalarField](v) } -// ScalarField is the [emulated.FieldParams] impelementation of the curve scalar field. +// ScalarField is the [emulated.FieldParams] implementation of the curve scalar field. type ScalarField = emulated.BN254Fr -// BaseField is the [emulated.FieldParams] impelementation of the curve base field. +// BaseField is the [emulated.FieldParams] implementation of the curve base field. type BaseField = emulated.BN254Fp diff --git a/std/algebra/emulated/sw_bn254/g2.go b/std/algebra/emulated/sw_bn254/g2.go index 66493302bf..8edb7953c5 100644 --- a/std/algebra/emulated/sw_bn254/g2.go +++ b/std/algebra/emulated/sw_bn254/g2.go @@ -233,7 +233,7 @@ func (g2 G2) doubleAndAdd(p, q *G2Affine) *G2Affine { xqxp = g2.Ext2.Add(&p.P.X, &q.P.X) x2 := g2.Ext2.Sub(λ1λ1, xqxp) - // ommit y2 computation + // omit y2 computation // compute λ2 = -λ1-2*p.y/(x2-p.x) ypyp := g2.Ext2.Add(&p.P.Y, &p.P.Y) x2xp := g2.Ext2.Sub(x2, &p.P.X) diff --git a/std/algebra/emulated/sw_bn254/pairing.go b/std/algebra/emulated/sw_bn254/pairing.go index 61a7e051e6..a2e998ad33 100644 --- a/std/algebra/emulated/sw_bn254/pairing.go +++ b/std/algebra/emulated/sw_bn254/pairing.go @@ -150,7 +150,7 @@ func (pr Pairing) finalExponentiation(e *GTEl, unsafe bool) *GTEl { if unsafe { // The Miller loop result is ≠ {-1,1}, otherwise this means P and Q are - // linearly dependant and not from G1 and G2 respectively. + // linearly dependent and not from G1 and G2 respectively. // So e ∈ G_{q,2} \ {-1,1} and hence e.C1 ≠ 0. // Nothing to do. @@ -213,7 +213,7 @@ func (pr Pairing) finalExponentiation(e *GTEl, unsafe bool) *GTEl { result = *pr.DecompressTorus(pr.MulTorus(t2, t0)) } else { // For a product of pairings this might happen when the result is expected to be 1. - // We assign a dummy value (1) to t0 and proceed furhter. + // We assign a dummy value (1) to t0 and proceed further. // Finally we do a select on both edge cases: // - Only if seletor1=0 and selector2=0, we return MulTorus(t2, t0) decompressed. // - Otherwise, we return 1. diff --git a/std/algebra/emulated/sw_bw6761/g1.go b/std/algebra/emulated/sw_bw6761/g1.go index a1c0e0588e..c31d3159ec 100644 --- a/std/algebra/emulated/sw_bw6761/g1.go +++ b/std/algebra/emulated/sw_bw6761/g1.go @@ -32,10 +32,10 @@ func NewScalar(v fr_bw6761.Element) Scalar { return emulated.ValueOf[ScalarField](v) } -// ScalarField is the [emulated.FieldParams] impelementation of the curve scalar field. +// ScalarField is the [emulated.FieldParams] implementation of the curve scalar field. type ScalarField = emulated.BW6761Fr -// BaseField is the [emulated.FieldParams] impelementation of the curve base field. +// BaseField is the [emulated.FieldParams] implementation of the curve base field. type BaseField = emulated.BW6761Fp type G1 struct { @@ -143,7 +143,7 @@ func (g1 G1) doubleAndAdd(p, q *G1Affine) *G1Affine { xqxp = g1.curveF.Add(&p.X, &q.X) x2 := g1.curveF.Sub(λ1λ1, xqxp) - // ommit y1 computation + // omit y1 computation // compute λ1 = -λ1-1*p.y/(x1-p.x) ypyp := g1.curveF.Add(&p.Y, &p.Y) x2xp := g1.curveF.Sub(x2, &p.X) @@ -180,7 +180,7 @@ func (g1 G1) triple(p *G1Affine) *G1Affine { λ1λ1 := g1.curveF.Mul(λ1, λ1) x2 = g1.curveF.Sub(λ1λ1, x2) - // ommit y2 computation, and + // omit y2 computation, and // compute λ2 = 2p.y/(x2 − p.x) − λ1. x1x2 := g1.curveF.Sub(&p.X, x2) λ2 := g1.curveF.Div(y2, x1x2) diff --git a/std/algebra/emulated/sw_bw6761/g2.go b/std/algebra/emulated/sw_bw6761/g2.go index 235e22eaa1..d1b2a4f752 100644 --- a/std/algebra/emulated/sw_bw6761/g2.go +++ b/std/algebra/emulated/sw_bw6761/g2.go @@ -188,7 +188,7 @@ func (g2 G2) doubleAndAdd(p, q *G2Affine) *G2Affine { xqxp = g2.curveF.Add(&p.P.X, &q.P.X) x2 := g2.curveF.Sub(λ1λ1, xqxp) - // ommit y2 computation + // omit y2 computation // compute λ2 = -λ1-2*p.y/(x2-p.x) ypyp := g2.curveF.Add(&p.P.Y, &p.P.Y) x2xp := g2.curveF.Sub(x2, &p.P.X) @@ -227,7 +227,7 @@ func (g2 G2) triple(p *G2Affine) *G2Affine { λ1λ1 := g2.curveF.Mul(λ1, λ1) x2 = g2.curveF.Sub(λ1λ1, x2) - // ommit y2 computation, and + // omit y2 computation, and // compute λ2 = 2p.y/(x2 − p.x) − λ1. x1x2 := g2.curveF.Sub(&p.P.X, x2) λ2 := g2.curveF.Div(y2, x1x2) diff --git a/std/algebra/emulated/sw_emulated/point.go b/std/algebra/emulated/sw_emulated/point.go index 649022d6a1..21063b5f20 100644 --- a/std/algebra/emulated/sw_emulated/point.go +++ b/std/algebra/emulated/sw_emulated/point.go @@ -348,7 +348,7 @@ func (c *Curve[B, S]) triple(p *AffinePoint[B]) *AffinePoint[B] { λ1λ1 := c.baseApi.MulMod(λ1, λ1) x2 = c.baseApi.Sub(λ1λ1, x2) - // ommit y2 computation, and + // omit y2 computation, and // compute λ2 = 2p.y/(x2 − p.x) − λ1. x1x2 := c.baseApi.Sub(&p.X, x2) λ2 := c.baseApi.Div(y2, x1x2) @@ -393,7 +393,7 @@ func (c *Curve[B, S]) doubleAndAdd(p, q *AffinePoint[B]) *AffinePoint[B] { xqxp = c.baseApi.Add(&p.X, &q.X) x2 := c.baseApi.Sub(λ1λ1, xqxp) - // ommit y2 computation + // omit y2 computation // compute λ2 = λ1+2*p.y/(x2-p.x) ypyp := c.baseApi.MulConst(&p.Y, big.NewInt(2)) x2xp := c.baseApi.Sub(x2, &p.X) @@ -435,7 +435,7 @@ func (c *Curve[B, S]) doubleAndAddSelect(b frontend.Variable, p, q *AffinePoint[ xqxp = c.baseApi.Add(&p.X, &q.X) x2 := c.baseApi.Sub(λ1λ1, xqxp) - // ommit y2 computation + // omit y2 computation // conditional second addition t := c.Select(b, p, q) diff --git a/std/algebra/native/twistededwards/curve_test.go b/std/algebra/native/twistededwards/curve_test.go index a8492cd26b..b12a027c01 100644 --- a/std/algebra/native/twistededwards/curve_test.go +++ b/std/algebra/native/twistededwards/curve_test.go @@ -204,7 +204,7 @@ func TestCurve(t *testing.T) { // testData generates random test data for given curve // returns p1, p2 and r, d such that p1 + p2 == r and p1 + p1 == d // returns rs1, rs12, s1, s2 such that rs1 = p2 * s2 and rs12 = p1*s1 + p2 * s2 -// retunrs n such that n = -p2 +// returns n such that n = -p2 func testData(params *CurveParams, curveID twistededwards.ID) ( _p1, _p2, diff --git a/std/gkr/compile.go b/std/gkr/compile.go index dd3ad75ee0..31a790c56d 100644 --- a/std/gkr/compile.go +++ b/std/gkr/compile.go @@ -66,7 +66,7 @@ func (api *API) Series(input, output constraint.GkrVariable, inputInstance, outp } // Import creates a new input variable, whose values across all instances are given by assignment. -// If the value in an instance depends on an output of another instance, leave the corresponding index in assigment nil and use Series to specify the dependency. +// If the value in an instance depends on an output of another instance, leave the corresponding index in assignment nil and use Series to specify the dependency. func (api *API) Import(assignment []frontend.Variable) (constraint.GkrVariable, error) { nbInstances := len(assignment) logNbInstances := log2(uint(nbInstances)) diff --git a/std/hash/hash.go b/std/hash/hash.go index 2df30fa1ef..24854c577f 100644 --- a/std/hash/hash.go +++ b/std/hash/hash.go @@ -28,7 +28,7 @@ import ( // FieldHasher hashes inputs into a short digest. This interface mocks // [BinaryHasher], but is more suitable in-circuit by assuming the inputs are // scalar field elements and outputs digest as a field element. Such hash -// functions are for examle Poseidon, MiMC etc. +// functions are for example Poseidon, MiMC etc. type FieldHasher interface { // Sum computes the hash of the internal state of the hash function. Sum() frontend.Variable diff --git a/std/math/cmp/bounded.go b/std/math/cmp/bounded.go index 0c527ffcf3..14d5a433a5 100644 --- a/std/math/cmp/bounded.go +++ b/std/math/cmp/bounded.go @@ -29,7 +29,7 @@ func GetHints() []solver.Hint { // NewBoundedComparator, for more information. type BoundedComparator struct { // absDiffUppBitLen is the assumed maximum length for the binary representation - // of |a - b|. Every method preforms exactly one binary decomposition of this + // of |a - b|. Every method performs exactly one binary decomposition of this // length. absDiffUppBitLen int api frontend.API diff --git a/std/math/emulated/emparams/emparams.go b/std/math/emulated/emparams/emparams.go index 22e7872203..55d1008cf1 100644 --- a/std/math/emulated/emparams/emparams.go +++ b/std/math/emulated/emparams/emparams.go @@ -282,7 +282,7 @@ type BLS24315Fr struct{ fourLimbPrimeField } func (fr BLS24315Fr) Modulus() *big.Int { return ecc.BLS24_315.ScalarField() } -// Mod1e4096 provides type parametrization for emulated aritmetic: +// Mod1e4096 provides type parametrization for emulated arithmetic: // - limbs: 64 // - limb width: 64 bits // @@ -301,7 +301,7 @@ func (Mod1e4096) Modulus() *big.Int { return val } -// Mod1e512 provides type parametrization for emulated aritmetic: +// Mod1e512 provides type parametrization for emulated arithmetic: // - limbs: 8 // - limb width: 64 bits // @@ -320,7 +320,7 @@ func (Mod1e512) Modulus() *big.Int { return val } -// Mod1e256 provides type parametrization for emulated aritmetic: +// Mod1e256 provides type parametrization for emulated arithmetic: // - limbs: 4 // - limb width: 64 bits // diff --git a/std/math/emulated/field_mul.go b/std/math/emulated/field_mul.go index 15310b96e7..78785d82b0 100644 --- a/std/math/emulated/field_mul.go +++ b/std/math/emulated/field_mul.go @@ -19,7 +19,7 @@ import ( // With this approach this is important that we do not change the [Element] // values after they are returned from [mulMod] as mulCheck keeps pointers and // the check will fail if the values referred to by the pointers change. By -// following the [Field] public methods this shouldn't happened as we always take +// following the [Field] public methods this shouldn't happen as we always take // and return pointers, and to change the values the user has to explicitly // dereference. // diff --git a/std/multicommit/nativecommit.go b/std/multicommit/nativecommit.go index c260a16f46..60f10f76b0 100644 --- a/std/multicommit/nativecommit.go +++ b/std/multicommit/nativecommit.go @@ -83,13 +83,13 @@ func (mct *multicommitter) commitAndCall(api frontend.API) error { if len(mct.cbs) == 0 { // shouldn't happen. we defer this function on creating multicommitter // instance. It is probably some race. - panic("calling commiter with zero callbacks") + panic("calling committer with zero callbacks") } - commiter, ok := api.Compiler().(frontend.Committer) + committer, ok := api.Compiler().(frontend.Committer) if !ok { panic("compiler doesn't implement frontend.Committer") } - rootCmt, err := commiter.Commit(mct.vars...) + rootCmt, err := committer.Commit(mct.vars...) if err != nil { return fmt.Errorf("commit: %w", err) } diff --git a/std/recursion/groth16/nonnative_doc_test.go b/std/recursion/groth16/nonnative_doc_test.go index bca062279f..beeeffcba7 100644 --- a/std/recursion/groth16/nonnative_doc_test.go +++ b/std/recursion/groth16/nonnative_doc_test.go @@ -36,7 +36,7 @@ func (c *InnerCircuitNative) Define(api frontend.API) error { // computeInnerProof computes the proof for the inner circuit we want to verify // recursively. In this example the Groth16 keys are generated on the fly, but -// in practice should be genrated once and using MPC. +// in practice should be generated once and using MPC. func computeInnerProof(field, outer *big.Int) (constraint.ConstraintSystem, groth16.VerifyingKey, witness.Witness, groth16.Proof) { innerCcs, err := frontend.Compile(field, r1cs.NewBuilder, &InnerCircuitNative{}) if err != nil { diff --git a/std/recursion/plonk/nonnative_doc_test.go b/std/recursion/plonk/nonnative_doc_test.go index 968671fd49..deff88902e 100644 --- a/std/recursion/plonk/nonnative_doc_test.go +++ b/std/recursion/plonk/nonnative_doc_test.go @@ -37,7 +37,7 @@ func (c *InnerCircuitNative) Define(api frontend.API) error { // computeInnerProof computes the proof for the inner circuit we want to verify // recursively. In this example the PLONK keys are generated on the fly, but -// in practice should be genrated once and using MPC. +// in practice should be generated once and using MPC. func computeInnerProof(field, outer *big.Int) (constraint.ConstraintSystem, native_plonk.VerifyingKey, witness.Witness, native_plonk.Proof) { innerCcs, err := frontend.Compile(field, scs.NewBuilder, &InnerCircuitNative{}) if err != nil { diff --git a/std/recursion/plonk/verifier.go b/std/recursion/plonk/verifier.go index 738790897e..cec5b15e06 100644 --- a/std/recursion/plonk/verifier.go +++ b/std/recursion/plonk/verifier.go @@ -312,7 +312,7 @@ type VerifyingKey[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra } // ValueOfBaseVerifyingKey assigns the base verification key from the witness. -// Use one of the verifiaction keys for the same-sized circuits. +// Use one of the verification keys for the same-sized circuits. func ValueOfBaseVerifyingKey[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT](vk backend_plonk.VerifyingKey) (BaseVerifyingKey[FR, G1El, G2El], error) { var ret BaseVerifyingKey[FR, G1El, G2El] var err error @@ -1078,7 +1078,7 @@ func (v *Verifier[FR, G1El, G2El, GtEl]) AssertSameProofs(vk VerifyingKey[FR, G1 // AssertDifferentProofs asserts the validity of different proofs for different // circuits. We define the base verification key bvk and per-circuit part in // cvks. The selector which verification key to use ise given in slice switches. -// The proofs and witnesses are given in the argumens and must correspond to +// The proofs and witnesses are given in the arguments and must correspond to // each other. func (v *Verifier[FR, G1El, G2El, GtEl]) AssertDifferentProofs(bvk BaseVerifyingKey[FR, G1El, G2El], cvks []CircuitVerifyingKey[FR, G1El], switches []frontend.Variable, proofs []Proof[FR, G1El, G2El], witnesses []Witness[FR], opts ...VerifierOption) error { From 9dd3050bdbd826c8b1b605734ba999a74c626dde Mon Sep 17 00:00:00 2001 From: fivecut Date: Fri, 30 Aug 2024 17:30:31 +0900 Subject: [PATCH 4/5] chore: make function comment match function names (#1168) Signed-off-by: fivecut From 85fcd6eee0ad84e8dda2f653654e12a4039f4a97 Mon Sep 17 00:00:00 2001 From: Pan chao <152830401+Pan-chao@users.noreply.github.com> Date: Fri, 30 Aug 2024 10:33:13 +0200 Subject: [PATCH 5/5] chore(std): some proofreading (#1001) * err msg * emulated field * bounded --------- Co-authored-by: Ivo Kubjas