banderwagon

package
v0.0.0-...-514ddfb Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompressedSize   = coordinateSize
	UncompressedSize = 2 * coordinateSize
)

Variables

View Source
var Generator = Element{
	// contains filtered or unexported fields
}

Generator is the generator of the group.

View Source
var Identity = Element{
	// contains filtered or unexported fields
}

Identity is the identity element of the group.

Functions

func BatchMapToScalarField

func BatchMapToScalarField(result []*fr.Element, elements []*Element) error

BatchMapToScalarField maps a slice of group elements to the scalar field.

func BatchNormalize

func BatchNormalize(elements []*Element) error

BatchNormalize normalizes a slice of group elements.

func BatchToBytesUncompressed

func BatchToBytesUncompressed(elements ...*Element) [][UncompressedSize]byte

BatchToBytesUncompressed serialises a slice of group elements in uncompressed form.

func ElementsToBytes

func ElementsToBytes(elements ...*Element) [][CompressedSize]byte

ElementsToBytes serialises a slice of group elements in compressed form.

Types

type Element

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

Element is an element of the group.

func (*Element) Add

func (p *Element) Add(p1, p2 *Element) *Element

Add sets p to p1+p2.

func (*Element) AddMixed

func (p *Element) AddMixed(p1 *Element, p2 bandersnatch.PointAffine) *Element

AddMixed sets p to p1+p2, where p2 is in affine form.

func (Element) Bytes

func (p Element) Bytes() [CompressedSize]byte

Bytes returns the compressed serialized version of the element.

func (Element) BytesUncompressed

func (p Element) BytesUncompressed() [UncompressedSize]byte

BytesUncompressed returns the uncompressed serialized version of the element.

func (*Element) Double

func (p *Element) Double(p1 *Element) *Element

Double sets p to 2*p1.

func (*Element) Equal

func (p *Element) Equal(other *Element) bool

Equal returns true if p and other represent the same point.

func (*Element) IsOnCurve

func (p *Element) IsOnCurve() bool

IsOnCurve returns true if p is on the curve.

func (Element) MapToScalarField

func (p Element) MapToScalarField(res *fr.Element)

MapToScalarField maps a group element to the scalar field.

func (*Element) MultiExp

func (p *Element) MultiExp(points []Element, scalars []fr.Element, config MultiExpConfig) (*Element, error)

MultiExp calculates the multi exponentiation of points and scalars.

func (*Element) Neg

func (p *Element) Neg(p1 *Element) *Element

Neg sets p to -p1.

func (*Element) Normalize

func (p *Element) Normalize() error

Normalize returns a point in affine form. If the point is at infinity, returns an error.

func (*Element) ScalarMul

func (p *Element) ScalarMul(p1 *Element, scalarMont *fr.Element) *Element

ScalarMul sets p to p1*s.

func (*Element) Set

func (p *Element) Set(p1 *Element) *Element

Set sets p to p1.

func (*Element) SetBytes

func (p *Element) SetBytes(buf []byte) error

SetBytes deserializes a compressed group element from buf. This method does all the proper checks assuming the bytes come from an untrusted source.

func (*Element) SetBytesUncompressed

func (p *Element) SetBytesUncompressed(buf []byte, trusted bool) error

SetBytesUncompressed deserializes an uncompressed group element from buf. This method does all the proper checks assuming the bytes come from an untrusted source.

func (*Element) SetBytesUnsafe

func (p *Element) SetBytesUnsafe(buf []byte) error

SetBytesUnsafe deserializes a compressed group element from buf. **DO NOT** use this method if the bytes comes from an untrusted source.

func (*Element) SetIdentity

func (p *Element) SetIdentity() *Element

SetIdentity sets p to the identity element.

func (*Element) Sub

func (p *Element) Sub(p1, p2 *Element) *Element

Sub sets p to p1-p2.

type Fr

type Fr = fr.Element

Fr is the scalar field underlying the group.

type MSMPrecomp

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

MSMPrecomp is an engine to calculate 256-MSM on a fixed basis using precomputed tables. This precomputed tables design are biased to support an efficient MSM for Verkle Trees.

Their design involves 16-bit windows for the first window16vs8IndexLimit points, and 8-bit windows for the rest. The motivation for this is that the first points are used to calculate tree keys, which clients heavily rely on compared to "longer" MSMs. This provides a significant boost to tree-key generation without exploding table sizes.

func NewPrecompMSM

func NewPrecompMSM(points []Element) (MSMPrecomp, error)

NewPrecompMSM creates a new MSMPrecomp.

func (*MSMPrecomp) MSM

func (msm *MSMPrecomp) MSM(scalars []fr.Element) Element

MSM calculates the 256-MSM of the given scalars on the fixed basis. It automatically detects how many non-zero scalars there are and parallelizes the computation.

type MultiExpConfig

type MultiExpConfig struct {
	NbTasks     int  // go routines to be used in the multiexp. can be larger than num cpus.
	ScalarsMont bool // indicates if the scalars are in montgomery form. Default to false.
}

MultiExpConfig enables to set optional configuration attribute to a call to MultiExp

type PrecompPoint

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

PrecompPoint is a precomputed table for a single point.

func NewPrecompPoint

func NewPrecompPoint(point Element, windowSize int) (PrecompPoint, error)

NewPrecompPoint creates a new PrecompPoint for the given point and window size.

func (*PrecompPoint) ScalarMul

func (pp *PrecompPoint) ScalarMul(scalar fr.Element, res *bandersnatch.PointExtended)

ScalarMul multiplies the point by the given scalar using the precomputed points. It applies a trick to push a carry between windows since our precomputed tables avoid storing point inverses.

Jump to

Keyboard shortcuts

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