ristretto

package
v0.0.0-...-5abc84a Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ristretto implements the group of prime order

2**252 + 27742317777372353535851937790883648493

as specified in draft-hdevalence-cfrg-ristretto-01.

All operations are constant time unless otherwise specified.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

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

Element is an element of the ristretto prime-order group.

func NewGeneratorElement

func NewGeneratorElement() *Element

NewGeneratorElement returns a new Element set to the canonical generator.

func NewIdentityElement

func NewIdentityElement() *Element

NewIdentityElement returns a new Element set to the identity value.

func (*Element) Add

func (e *Element) Add(p, q *Element) *Element

Add sets e = p + q, and returns e.

func (*Element) Bytes

func (e *Element) Bytes() []byte

Bytes returns the 32 bytes canonical encoding of e.

func (*Element) BytesEd25519

func (e *Element) BytesEd25519() []byte

BytesEd25519 returns the canonical byte representation of the underlying edwards25519.Point, normalized with regard to the cofactor.

func (*Element) Equal

func (e *Element) Equal(ee *Element) int

Equal returns 1 if e is equivalent to ee, and 0 otherwise.

Note that Elements must not be compared in any other way.

func (*Element) MarshalText

func (e *Element) MarshalText() (text []byte, err error)

MarshalText implements encoding/TextMarshaler interface

func (*Element) MultiScalarMult

func (e *Element) MultiScalarMult(s []*Scalar, p []*Element) *Element

MultiScalarMult sets e = sum(s[i] * p[i]), and returns e.

Execution time depends only on the lengths of the two slices, which must match.

func (*Element) Negate

func (e *Element) Negate(p *Element) *Element

Negate sets e = -p, and returns e.

func (*Element) ScalarBaseMult

func (e *Element) ScalarBaseMult(s *Scalar) *Element

ScalarBaseMult sets e = s * B, where B is the canonical generator, and returns e.

func (*Element) ScalarMult

func (e *Element) ScalarMult(s *Scalar, p *Element) *Element

ScalarMult sets e = s * p, and returns e.

func (*Element) Set

func (e *Element) Set(x *Element) *Element

Set sets the value of e to x and returns e.

func (*Element) SetCanonicalBytes

func (e *Element) SetCanonicalBytes(in []byte) (*Element, error)

SetCanonicalBytes sets e to the decoded value of in. If in is not a canonical encoding of s, SetCanonicalBytes returns nil and an error and the receiver is unchanged.

func (*Element) SetUniformBytes

func (e *Element) SetUniformBytes(b []byte) (*Element, error)

SetUniformBytes deterministically sets e to an uniformly distributed value given 64 uniformly distributed random bytes.

This can be used for hash-to-group operations or to obtain a random element.

func (*Element) String

func (e *Element) String() string

String implements the Stringer interface

func (*Element) Subtract

func (e *Element) Subtract(p, q *Element) *Element

Subtract sets e = p - q, and returns e.

func (*Element) UnmarshalText

func (e *Element) UnmarshalText(text []byte) error

UnmarshalText implements encoding/TextMarshaler interface

func (*Element) VarTimeDoubleScalarBaseMult

func (e *Element) VarTimeDoubleScalarBaseMult(a *Scalar, A *Element, b *Scalar) *Element

VarTimeDoubleScalarBaseMult sets e = a * A + b * B, where B is the canonical generator, and returns e.

Execution time depends on the inputs.

func (*Element) VarTimeMultiScalarMult

func (e *Element) VarTimeMultiScalarMult(s []*Scalar, p []*Element) *Element

VarTimeMultiScalarMult sets e = sum(s[i] * p[i]), and returns e.

Execution time depends on the inputs.

type Scalar

type Scalar = edwards25519.Scalar

func NewScalar

func NewScalar() *Scalar

Jump to

Keyboard shortcuts

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