other

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package other wraps an hash-to-curve implementation and exposes functions for operations on points and scalars.

Package other wraps an hash-to-curve implementation and exposes functions for operations on points and scalars.

Package other wraps an hash-to-curve implementation and exposes functions for operations on points and scalars.

Package other wraps an hash-to-curve implementation and exposes functions for operations on points and scalars.

Package other wraps an hash-to-curve implementation and exposes functions for operations on points and scalars.

Package other wraps an hash-to-curve implementation and exposes functions for operations on points and scalars.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash2Curve

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

Hash2Curve implements the Group interface to Hash-to-Curve primitives.

func New

func New(id H2C.SuiteID) *Hash2Curve

New returns a pointer to a Hash2Curve structure instantiated for the given Hash-to-Curve identifier. and the domain separation tag.

func (*Hash2Curve) Base

func (h *Hash2Curve) Base() internal.Point

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

func (*Hash2Curve) ElementLength

func (h *Hash2Curve) ElementLength() int

ElementLength returns the byte size of an encoded element.

func (*Hash2Curve) HashToGroup

func (h *Hash2Curve) HashToGroup(input, dst []byte) internal.Point

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

func (*Hash2Curve) HashToScalar

func (h *Hash2Curve) HashToScalar(input, dst []byte) internal.Scalar

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

func (*Hash2Curve) Identity

func (h *Hash2Curve) Identity() internal.Point

Identity returns the group's identity element.

func (*Hash2Curve) MultBytes

func (h *Hash2Curve) MultBytes(scalar, element []byte) (internal.Point, error)

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

func (*Hash2Curve) NewElement

func (h *Hash2Curve) NewElement() internal.Point

NewElement returns a new, empty, element.

func (*Hash2Curve) NewScalar

func (h *Hash2Curve) NewScalar() internal.Scalar

NewScalar returns a new, empty, scalar.

type Point

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

Point implements the Point interface for Hash-to-Curve points.

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) 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(input []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(s 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 Hash-to-Curve field elements.

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

func (s *Scalar) Equal(s2 *Scalar) bool

Equal returns whether the input scalar is equal to the receiver.

func (*Scalar) Invert

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

Invert returns the scalar's modular inverse ( 1 / scalar ), and does not change the receiver.

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