ristretto

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ristretto allows simple and abstracted operations in the Ristretto255 group

Package ristretto wraps "github.com/gtank/ristretto255" and exposes a simple prime-order group API with hash-to-curve.

Package ristretto allows simple and abstracted operations in the Ristretto255 group

Index

Constants

View Source
const (

	// H2C represents the hash-to-curve string identifier.
	H2C = "ristretto255_XMD:SHA-512_R255MAP_RO_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct{}

Group represents the Ristretto255 group. It exposes a prime-order group API with hash-to-curve operations.

func (Group) Base

func (r Group) Base() internal.Point

Base returns group's base point a.k.a. canonical generator.

func (Group) ElementLength

func (r Group) ElementLength() int

ElementLength returns the byte size of an encoded element.

func (Group) HashToGroup

func (r Group) HashToGroup(input, dst []byte) internal.Point

HashToGroup allows arbitrary input to be safely mapped to the curve of the group.

func (Group) HashToScalar

func (r Group) HashToScalar(input, dst []byte) internal.Scalar

HashToScalar allows arbitrary input to be safely mapped to the field.

func (Group) Identity

func (r Group) Identity() internal.Point

Identity returns the group's identity element.

func (Group) MultBytes

func (r Group) MultBytes(s, e []byte) (internal.Point, error)

MultBytes allows []byte encodings of a scalar and an element of the group to be multiplied.

func (Group) NewElement

func (r Group) NewElement() internal.Point

NewElement returns a new, empty, element.

func (Group) NewScalar

func (r Group) NewScalar() internal.Scalar

NewScalar returns a new, empty, scalar.

type Point

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

Point implements the Point interface for the Ristretto255 group element.

func (*Point) Add

func (p *Point) Add(element internal.Point) internal.Point

Add adds the argument to the receiver, sets the receiver to the result and returns it.

func (*Point) Base

func (p *Point) Base() internal.Point

Base returns the group's base point.

func (*Point) Bytes

func (p *Point) Bytes() []byte

Bytes returns the compressed byte encoding of the element.

func (*Point) Copy

func (p *Point) Copy() internal.Point

Copy returns a copy of the element.

func (*Point) Decode

func (p *Point) Decode(in []byte) (internal.Point, error)

Decode decodes the input an sets the current element to its value, and returns it.

func (*Point) InvertMult

func (p *Point) InvertMult(scalar internal.Scalar) internal.Point

InvertMult returns the scalar multiplication of the receiver element with the inverse of the given scalar.

func (*Point) IsIdentity

func (p *Point) IsIdentity() bool

IsIdentity returns whether the element is the group's identity element.

func (*Point) Mult

func (p *Point) Mult(scalar internal.Scalar) internal.Point

Mult returns the scalar multiplication of the receiver element with the given scalar.

func (*Point) Sub

func (p *Point) Sub(element internal.Point) internal.Point

Sub subtracts the argument from the receiver, sets the receiver to the result and returns it.

type Scalar

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

Scalar implements the Scalar interface for Ristretto255 group scalars.

func (*Scalar) Add

func (s *Scalar) Add(scalar internal.Scalar) internal.Scalar

Add returns the sum of the scalars, and does not change the receiver.

func (*Scalar) Bytes

func (s *Scalar) Bytes() []byte

Bytes returns the byte encoding of the scalar.

func (*Scalar) Copy

func (s *Scalar) Copy() internal.Scalar

Copy returns a copy of the Scalar.

func (*Scalar) Decode

func (s *Scalar) Decode(in []byte) (internal.Scalar, error)

Decode decodes the input an sets the current scalar to its value, and returns it.

func (*Scalar) Invert

func (s *Scalar) Invert() internal.Scalar

Invert returns the scalar's modular inverse ( 1 / scalar ).

func (*Scalar) Mult

func (s *Scalar) Mult(scalar internal.Scalar) internal.Scalar

Mult returns the multiplication of the scalars, and does not change the receiver.

func (*Scalar) Random

func (s *Scalar) Random() internal.Scalar

Random sets the current scalar to a new random scalar and returns it.

func (*Scalar) Sub

func (s *Scalar) Sub(scalar internal.Scalar) internal.Scalar

Sub returns the difference between the scalars, and does not change the receiver.

Jump to

Keyboard shortcuts

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