bn256

package
v1.14.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: GPL-3.0, BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PairingCheck

func PairingCheck(a_ []*G1, b_ []*G2) bool

Computes the following relation: ∏ᵢ e(Pᵢ, Qᵢ) =? 1

To explain why gnark returns a (bool, error):

  • If the function `e` does not return a result then internally an error is returned.
  • If `e` returns a result, then error will be nil, but if this value is not `1` then the boolean value will be false

We therefore check for an error, and return false if its non-nil and then return the value of the boolean if not.

Types

type G1

type G1 struct {
	// contains filtered or unexported fields
}

G1 is the affine representation of a G1 group element.

Since this code is used for precompiles, using Jacobian points are not beneficial because there are no intermediate points to allow us to save on inversions.

Note: We also use this struct so that we can conform to the existing API that the precompiles want.

func (*G1) Add

func (g *G1) Add(a, b *G1)

Add adds `a` and `b` together, storing the result in `g`

func (*G1) Marshal

func (p *G1) Marshal() []byte

Marshal serializes the point into a byte slice.

Note: The point is serialized as uncompressed.

func (*G1) ScalarMult

func (g *G1) ScalarMult(a *G1, scalar *big.Int)

ScalarMult computes the scalar multiplication between `a` and `scalar`, storing the result in `g`

func (*G1) Unmarshal

func (g *G1) Unmarshal(buf []byte) (int, error)

Unmarshal deserializes `buf` into `g`

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.

This method also checks whether the point is on the curve and in the prime order subgroup.

type G2

type G2 struct {
	// contains filtered or unexported fields
}

G2 is the affine representation of a G2 group element.

Since this code is used for precompiles, using Jacobian points are not beneficial because there are no intermediate 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.

func (*G2) Marshal

func (g *G2) Marshal() []byte

Marshal serializes the point into a byte slice.

Note: The point is serialized as uncompressed.

func (*G2) Unmarshal

func (g *G2) Unmarshal(buf []byte) (int, error)

Unmarshal deserializes `buf` into `g`

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.

This method also checks whether the point is on the curve and in the prime order subgroup.

type GT

type GT struct {
	// contains filtered or unexported fields
}

GT is the affine representation of a GT field element.

Note: GT is not explicitly used in mainline code. It is needed for fuzzing.

func Pair

func Pair(a_ *G1, b_ *G2) *GT

Pair compute the optimal Ate pairing between a G1 and G2 element.

Note: This method is not explicitly used in mainline code. It is needed for fuzzing. It should also be noted, that the output of this function may not match other

func (*GT) Exp

func (g *GT) Exp(base GT, exponent *big.Int) *GT

Exp raises `base` to the power of `exponent`

Note: This method is not explicitly used in mainline code. It is needed for fuzzing.

func (*GT) Marshal

func (g *GT) Marshal() []byte

Marshal serializes the point into a byte slice.

Note: This method is not explicitly used in mainline code. It is needed for fuzzing.

func (*GT) Unmarshal

func (g *GT) Unmarshal(buf []byte) error

Unmarshal deserializes `buf` into `g`

Note: This method is not explicitly used in mainline code. It is needed for fuzzing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL