Skip to content

Commit

Permalink
fix: several external typo fixes (#1261)
Browse files Browse the repository at this point in the history
* refactor: use strings.ReplaceAll (#1257)

* chore: fix some function names (#1240)

Signed-off-by: highcloudwind <highcloud@aliyun.com.>
Co-authored-by: Ivo Kubjas <ivo.kubjas@consensys.net>

* fix: fix most typos (#1185)

* fix: fix most typos

* fix: update template

---------

Co-authored-by: Ivo Kubjas <ivo.kubjas@consensys.net>

* chore: make function comment match function names (#1168)

Signed-off-by: fivecut <fivecut@126.com>

* chore(std): some proofreading (#1001)

* err msg

* emulated field

* bounded

---------

Co-authored-by: Ivo Kubjas <ivo.kubjas@consensys.net>

---------

Signed-off-by: highcloudwind <highcloud@aliyun.com.>
Signed-off-by: fivecut <fivecut@126.com>
Co-authored-by: bytetigers <bytetiger@icloud.com>
Co-authored-by: highcloudwind <highcloud@aliyun.com>
Co-authored-by: shuriu <161208801+shuriu@users.noreply.github.com>
Co-authored-by: fivecut <fivecut@126.com>
Co-authored-by: Pan chao <152830401+Pan-chao@users.noreply.github.com>
  • Loading branch information
6 people authored Aug 30, 2024
1 parent 429616e commit c59881d
Show file tree
Hide file tree
Showing 40 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion backend/plonk/bls12-377/prove.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/plonk/bls12-381/prove.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/plonk/bls24-315/prove.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/plonk/bls24-317/prove.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/plonk/bn254/prove.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/plonk/bw6-633/prove.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/plonk/bw6-761/prove.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion constraint/solver/hint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion constraint/solver/hint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/rollup/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
4 changes: 2 additions & 2 deletions frontend/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ type API interface {
// * -1 if i1<i2.
//
// If the absolute difference between the variables i1 and i2 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].
Cmp(i1, i2 Variable) Variable

Expand All @@ -127,7 +127,7 @@ type API interface {
// AssertIsLessOrEqual fails if v > 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)

Expand Down
2 changes: 1 addition & 1 deletion frontend/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion frontend/cs/r1cs/r1cs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions profile/internal/graph/dotgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion profile/internal/measurement/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion profile/internal/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion profile/profile_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion std/algebra/emulated/fields_bw6761/e6_pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions std/algebra/emulated/sw_bls12381/g1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions std/algebra/emulated/sw_bls12381/g2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions std/algebra/emulated/sw_bls12381/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions std/algebra/emulated/sw_bn254/g1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion std/algebra/emulated/sw_bn254/g2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions std/algebra/emulated/sw_bn254/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions std/algebra/emulated/sw_bw6761/g1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions std/algebra/emulated/sw_bw6761/g2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions std/algebra/emulated/sw_emulated/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion std/algebra/native/sw_bls24315/pairing2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion std/algebra/native/twistededwards/curve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion std/gkr/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading

0 comments on commit c59881d

Please sign in to comment.