banderwagon

package
v0.0.0-...-53bbb0c Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0, MIT Imports: 11 Imported by: 41

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) BytesUncompressedTrusted

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

BytesUncompressedTrusted returns the uncompressed serialized version of the element. The returned bytes can only be used with SetBytesUncompressed with the trusted flag on. This is because this method doesn't do any (x, y) transformation regarding the sign of y.

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