bn254

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NONE = 0
	DIF  = 1
	DIT  = 2
)
View Source
const BASE_SIZE = 8
View Source
const SCALAR_SIZE = 8

Variables

This section is empty.

Functions

func AffinePointFromMontgomery

func AffinePointFromMontgomery(d_points unsafe.Pointer, len int) (int, error)

func Commit

func Commit(d_out, d_scalars, d_points unsafe.Pointer, count, bucketFactor int) int

func CommitBatch

func CommitBatch(d_out, d_scalars, d_points unsafe.Pointer, count, batch_size int) int

func CommitG2

func CommitG2(d_out, d_scalars, d_points unsafe.Pointer, count, bucketFactor int) int

func CommitG2Batch

func CommitG2Batch(d_out, d_scalars, d_points unsafe.Pointer, count, batch_size int) int

func ConvertUint32ArrToUint64Arr

func ConvertUint32ArrToUint64Arr(arr32 [8]uint32) [4]uint64

Function to convert [8]uint32 to [4]uint64

func ConvertUint64ArrToUint32Arr

func ConvertUint64ArrToUint32Arr(arr64 [4]uint64) [8]uint32

func EcNtt

func EcNtt(values *[]G1ProjectivePoint, isInverse bool, deviceId int) uint64

func EcNttBatch

func EcNttBatch(values *[]G1ProjectivePoint, isInverse bool, batchSize, deviceId int) uint64

func Evaluate

func Evaluate(scalars_out, scalars, twiddles, coset_powers unsafe.Pointer, scalars_size, twiddles_size int, isCoset bool) int

func FromMontgomery

func FromMontgomery(d_scalars unsafe.Pointer, len int) (int, error)

func G2AffinePointFromMontgomery

func G2AffinePointFromMontgomery(d_points unsafe.Pointer, len int) (int, error)

func GenerateTwiddles

func GenerateTwiddles(d_size int, log_d_size int, inverse bool) (up unsafe.Pointer, err error)

func GetFixedLimbs

func GetFixedLimbs(slice *[]uint32) [BASE_SIZE]uint32

func Interpolate

func Interpolate(scalars, twiddles, cosetPowers unsafe.Pointer, size int, isCoset bool) unsafe.Pointer

func MultiplyMatrix

func MultiplyMatrix(a []G1ScalarField, b []G1ScalarField, deviceID int)

Multiply a matrix by a scalar:

`a` - flattenned matrix;
`b` - vector to multiply `a` by;

func MultiplyScalar

func MultiplyScalar(a []G1ScalarField, b []G1ScalarField, deviceID int)

func MultiplyVec

func MultiplyVec(a []G1ProjectivePoint, b []G1ScalarField, deviceID int)

func Ntt

func Ntt(scalars *[]G1ScalarField, isInverse bool, deviceId int) uint64

func NttBatch

func NttBatch(scalars *[]G1ScalarField, isInverse bool, batchSize, deviceId int) uint64

func ReverseScalars

func ReverseScalars(d_scalars unsafe.Pointer, len int) (int, error)

Reverses d_scalars in-place

func TimeTrack

func TimeTrack(start time.Time)

func ToMontgomery

func ToMontgomery(d_scalars unsafe.Pointer, len int) (int, error)

func VecScalarAdd

func VecScalarAdd(in1_d, in2_d unsafe.Pointer, size int) int

func VecScalarMulMod

func VecScalarMulMod(scalarVec1, scalarVec2 unsafe.Pointer, size int) int

func VecScalarSub

func VecScalarSub(in1_d, in2_d unsafe.Pointer, size int) int

Types

type ExtentionField

type ExtentionField struct {
	A0, A1 G2Element
}

type G1BaseField

type G1BaseField struct {
	S [BASE_SIZE]uint32
}

func (*G1BaseField) FromLimbs

func (f *G1BaseField) FromLimbs(limbs [BASE_SIZE]uint32) *G1BaseField

func (*G1BaseField) Limbs

func (f *G1BaseField) Limbs() [BASE_SIZE]uint32

func (*G1BaseField) SetOne

func (f *G1BaseField) SetOne() *G1BaseField

func (*G1BaseField) SetZero

func (f *G1BaseField) SetZero() *G1BaseField

func (*G1BaseField) ToBytesLe

func (f *G1BaseField) ToBytesLe() []byte

type G1PointAffine

type G1PointAffine struct {
	X, Y G1BaseField
}

func (*G1PointAffine) FromLimbs

func (p *G1PointAffine) FromLimbs(X, Y *[]uint32) *G1PointAffine

func (*G1PointAffine) FromProjective

func (p *G1PointAffine) FromProjective(projective *G1ProjectivePoint) *G1PointAffine

func (*G1PointAffine) ToProjective

func (p *G1PointAffine) ToProjective() *G1ProjectivePoint

type G1ProjectivePoint

type G1ProjectivePoint struct {
	X, Y, Z G1BaseField
}

func Msm

func Msm(out *G1ProjectivePoint, points []G1PointAffine, scalars []G1ScalarField, device_id int) (*G1ProjectivePoint, error)

func MsmBatch

func MsmBatch(points *[]G1PointAffine, scalars *[]G1ScalarField, batchSize, deviceId int) ([]G1ProjectivePoint, error)

func (*G1ProjectivePoint) Eq

func (p *G1ProjectivePoint) Eq(pCompare *G1ProjectivePoint) bool

func (*G1ProjectivePoint) FromAffine

func (p *G1ProjectivePoint) FromAffine(affine *G1PointAffine) *G1ProjectivePoint

func (*G1ProjectivePoint) FromLimbs

func (p *G1ProjectivePoint) FromLimbs(x, y, z *[]uint32) *G1ProjectivePoint

func (*G1ProjectivePoint) IsOnCurve

func (p *G1ProjectivePoint) IsOnCurve() bool

func (*G1ProjectivePoint) Random

func (p *G1ProjectivePoint) Random() *G1ProjectivePoint

func (*G1ProjectivePoint) SetZero

func (f *G1ProjectivePoint) SetZero() *G1ProjectivePoint

func (*G1ProjectivePoint) StripZ

func (p *G1ProjectivePoint) StripZ() *G1PointAffine

type G1ScalarField

type G1ScalarField struct {
	S [SCALAR_SIZE]uint32
}

func (*G1ScalarField) Eq

func (a *G1ScalarField) Eq(b *G1ScalarField) bool

func (*G1ScalarField) Limbs

func (f *G1ScalarField) Limbs() [SCALAR_SIZE]uint32

func (*G1ScalarField) Random

func (p *G1ScalarField) Random() *G1ScalarField

func (*G1ScalarField) SetOne

func (f *G1ScalarField) SetOne() *G1ScalarField

func (*G1ScalarField) SetZero

func (f *G1ScalarField) SetZero() *G1ScalarField

func (*G1ScalarField) ToBytesLe

func (f *G1ScalarField) ToBytesLe() []byte

type G2Element

type G2Element [4]uint64

func (*G2Element) ToBytesLe

func (f *G2Element) ToBytesLe() []byte

type G2Point

type G2Point struct {
	X, Y, Z ExtentionField
}

func MsmG2

func MsmG2(out *G2Point, points []G2PointAffine, scalars []G1ScalarField, device_id int) (*G2Point, error)

func MsmG2Batch

func MsmG2Batch(points *[]G2PointAffine, scalars *[]G1ScalarField, batchSize, deviceId int) ([]G2Point, error)

func (*G2Point) Eq

func (p *G2Point) Eq(pCompare *G2Point) bool

func (*G2Point) FromAffine

func (p *G2Point) FromAffine(affine *G2PointAffine) *G2Point

func (*G2Point) IsOnCurve

func (p *G2Point) IsOnCurve() bool

func (*G2Point) Random

func (p *G2Point) Random() *G2Point

type G2PointAffine

type G2PointAffine struct {
	X, Y ExtentionField
}

func (*G2PointAffine) FromProjective

func (p *G2PointAffine) FromProjective(projective *G2Point) *G2PointAffine

Jump to

Keyboard shortcuts

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