From 177c7a15329ccf1a489aa930a96ab42750507d73 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Mon, 14 Oct 2024 15:05:07 +0100 Subject: [PATCH] [multi] - cleanup comments and remove Add from g2 since there is no Add precompile for G2 --- crypto/bn256/gnark/g1.go | 16 ++++++++-------- crypto/bn256/gnark/g2.go | 19 +++++++------------ 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/crypto/bn256/gnark/g1.go b/crypto/bn256/gnark/g1.go index cc80e06cc4..2f933dd536 100644 --- a/crypto/bn256/gnark/g1.go +++ b/crypto/bn256/gnark/g1.go @@ -18,27 +18,27 @@ type G1 struct { inner bn254.G1Affine } -// Add adds `a` and `b` together storing the result in `g` +// Add adds `a` and `b` together, storing the result in `g` func (g *G1) Add(a, b *G1) { g.inner.Add(&a.inner, &b.inner) } // ScalarMult computes the scalar multiplication between `a` and -// `scalar` storing the result in `g` +// `scalar`, storing the result in `g` func (g *G1) ScalarMult(a *G1, scalar *big.Int) { g.inner.ScalarMultiplication(&a.inner, scalar) } // Unmarshal deserializes `buf` into `g` // -// Note: whether the serialization is of a compressed -// or an uncompressed point, is encoding in the bytes. +// Note: whether the deserialization is of a compressed +// or an uncompressed point, is encoded in the bytes. // -// For our purpose, the point will always be serialized as uncompressed -// ie 64 bytes. +// For our purpose, the point will always be serialized +// as uncompressed, ie 64 bytes. // -// This method checks whether the point is on the curve and -// in the subgroup. +// This method also checks whether the point is on the +// curve and in the prime order subgroup. func (g *G1) Unmarshal(buf []byte) (int, error) { return g.inner.SetBytes(buf) } diff --git a/crypto/bn256/gnark/g2.go b/crypto/bn256/gnark/g2.go index c79d8604e0..205373a591 100644 --- a/crypto/bn256/gnark/g2.go +++ b/crypto/bn256/gnark/g2.go @@ -8,7 +8,7 @@ import ( // // Since this code is used for precompiles, using Jacobian // points are not beneficial because there are no intermediate -// points. +// points and G2 in particular is only used for the pairing input. // // Note: We also use this struct so that we can conform to the existing API // that the precompiles want. @@ -16,21 +16,16 @@ type G2 struct { inner bn254.G2Affine } -// Add adds `a` and `b` together storing the result in `g` -func (g *G2) Add(a, b *G2) { - g.inner.Add(&a.inner, &b.inner) -} - // Unmarshal deserializes `buf` into `g` // -// Note: whether the serialization is of a compressed -// or an uncompressed point, is encoding in the bytes. +// Note: whether the deserialization is of a compressed +// or an uncompressed point, is encoded in the bytes. // -// For our purpose, the point will always be serialized as uncompressed -// ie 128 bytes. +// For our purpose, the point will always be serialized +// as uncompressed, ie 128 bytes. // -// This method checks whether the point is on the curve and -// in the subgroup. +// This method also checks whether the point is on the +// curve and in the prime order subgroup. func (g *G2) Unmarshal(buf []byte) (int, error) { return g.inner.SetBytes(buf) }