Documentation ¶
Index ¶
- Constants
- Variables
- func BatchMapToScalarField(result []*fr.Element, elements []*Element) error
- func BatchNormalize(elements []*Element) error
- func BatchToBytesUncompressed(elements ...*Element) [][UncompressedSize]byte
- func ElementsToBytes(elements ...*Element) [][CompressedSize]byte
- type Element
- func (p *Element) Add(p1, p2 *Element) *Element
- func (p *Element) AddMixed(p1 *Element, p2 bandersnatch.PointAffine) *Element
- func (p Element) Bytes() [CompressedSize]byte
- func (p Element) BytesUncompressedTrusted() [UncompressedSize]byte
- func (p *Element) Double(p1 *Element) *Element
- func (p *Element) Equal(other *Element) bool
- func (p *Element) IsOnCurve() bool
- func (p Element) MapToScalarField(res *fr.Element)
- func (p *Element) MultiExp(points []Element, scalars []fr.Element, config MultiExpConfig) (*Element, error)
- func (p *Element) Neg(p1 *Element) *Element
- func (p *Element) Normalize() error
- func (p *Element) ScalarMul(p1 *Element, scalarMont *fr.Element) *Element
- func (p *Element) Set(p1 *Element) *Element
- func (p *Element) SetBytes(buf []byte) error
- func (p *Element) SetBytesUncompressed(buf []byte, trusted bool) error
- func (p *Element) SetBytesUnsafe(buf []byte) error
- func (p *Element) SetIdentity() *Element
- func (p *Element) Sub(p1, p2 *Element) *Element
- type Fr
- type MSMPrecomp
- type MultiExpConfig
- type PrecompPoint
Constants ¶
const ( CompressedSize = coordinateSize UncompressedSize = 2 * coordinateSize )
Variables ¶
var Generator = Element{ // contains filtered or unexported fields }
Generator is the generator of the group.
var Identity = Element{ // contains filtered or unexported fields }
Identity is the identity element of the group.
Functions ¶
func BatchMapToScalarField ¶
BatchMapToScalarField maps a slice of group elements to the scalar field.
func BatchNormalize ¶
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) 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) MapToScalarField ¶
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) Normalize ¶
Normalize returns a point in affine form. If the point is at infinity, returns an error.
func (*Element) SetBytes ¶
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 ¶
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 ¶
SetBytesUnsafe deserializes a compressed group element from buf. **DO NOT** use this method if the bytes comes from an untrusted source.
func (*Element) SetIdentity ¶
SetIdentity sets p to the identity element.
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.
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.