- cleanup comments and remove Add from g2 since there is no Add precompile for G2
This commit is contained in:
Kevaundray Wedderburn 2024-10-14 15:05:07 +01:00
parent 3c03b0cbbc
commit 177c7a1532
2 changed files with 15 additions and 20 deletions

View file

@ -18,27 +18,27 @@ type G1 struct {
inner bn254.G1Affine 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) { func (g *G1) Add(a, b *G1) {
g.inner.Add(&a.inner, &b.inner) g.inner.Add(&a.inner, &b.inner)
} }
// ScalarMult computes the scalar multiplication between `a` and // 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) { func (g *G1) ScalarMult(a *G1, scalar *big.Int) {
g.inner.ScalarMultiplication(&a.inner, scalar) g.inner.ScalarMultiplication(&a.inner, scalar)
} }
// Unmarshal deserializes `buf` into `g` // Unmarshal deserializes `buf` into `g`
// //
// Note: whether the serialization is of a compressed // Note: whether the deserialization is of a compressed
// or an uncompressed point, is encoding in the bytes. // or an uncompressed point, is encoded in the bytes.
// //
// For our purpose, the point will always be serialized as uncompressed // For our purpose, the point will always be serialized
// ie 64 bytes. // as uncompressed, ie 64 bytes.
// //
// This method checks whether the point is on the curve and // This method also checks whether the point is on the
// in the subgroup. // curve and in the prime order subgroup.
func (g *G1) Unmarshal(buf []byte) (int, error) { func (g *G1) Unmarshal(buf []byte) (int, error) {
return g.inner.SetBytes(buf) return g.inner.SetBytes(buf)
} }

View file

@ -8,7 +8,7 @@ import (
// //
// Since this code is used for precompiles, using Jacobian // Since this code is used for precompiles, using Jacobian
// points are not beneficial because there are no intermediate // 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 // Note: We also use this struct so that we can conform to the existing API
// that the precompiles want. // that the precompiles want.
@ -16,21 +16,16 @@ type G2 struct {
inner bn254.G2Affine 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` // Unmarshal deserializes `buf` into `g`
// //
// Note: whether the serialization is of a compressed // Note: whether the deserialization is of a compressed
// or an uncompressed point, is encoding in the bytes. // or an uncompressed point, is encoded in the bytes.
// //
// For our purpose, the point will always be serialized as uncompressed // For our purpose, the point will always be serialized
// ie 128 bytes. // as uncompressed, ie 128 bytes.
// //
// This method checks whether the point is on the curve and // This method also checks whether the point is on the
// in the subgroup. // curve and in the prime order subgroup.
func (g *G2) Unmarshal(buf []byte) (int, error) { func (g *G2) Unmarshal(buf []byte) (int, error) {
return g.inner.SetBytes(buf) return g.inner.SetBytes(buf)
} }