eccgroup

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package eccgroup implements prime-order group supported elliptic curves with hash-to-curve operations.

Supported Curves;

  • Ristretto255
  • P256
  • P384
  • P521

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	internal.Element
}

Element represents an element on the curve of the prime-order group.

func (*Element) Add

func (e *Element) Add(element *Element) *Element

Add sets the receiver to the sum of the input and the receiver, and returns the receiver.

func (*Element) Base

func (e *Element) Base() *Element

Base sets the receiver to the group's base point a.k.a. canonical generator, and returns the receiver.

func (*Element) Copy

func (e *Element) Copy() *Element

Copy returns a copy of the receiver.

func (*Element) Decode

func (e *Element) Decode(data []byte) error

Decode sets the receiver to a decoding of the input data, and returns an error on failure.

func (*Element) Double

func (e *Element) Double() *Element

Double sets the receiver to its double, and returns it.

func (*Element) Encode

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

Encode returns the compressed byte encoding of the element.

func (*Element) Equal

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

Equal returns 1 if the receiver and input element are equivalent, and 0 otherwise.

func (*Element) Identity

func (e *Element) Identity() *Element

Identity sets the receiver to the point at infinity of the Group's underlying curve, and returns the reveiver.

func (*Element) IsIdentity

func (e *Element) IsIdentity() bool

IsIdentity returns whether the receiver is the point at infinity of the Group's underlying curve.

func (*Element) MarshalBinary

func (e *Element) MarshalBinary() ([]byte, error)

MarshalBinary returns the compressed byte encoding of the element.

func (*Element) MarshalText

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

MarshalText implements the encoding.MarshalText interface.

func (*Element) Multiply

func (e *Element) Multiply(scalar *Scalar) *Element

Multiply sets the receiver to the scalar multiplication of the receiver with the given Scalar, and returns it.

func (*Element) Negate

func (e *Element) Negate() *Element

Negate sets the receiver to its negation, and returns it.

func (*Element) Set

func (e *Element) Set(element *Element) *Element

Set sets the receiver to the argument, and returns the receiver.

func (*Element) Subtract

func (e *Element) Subtract(element *Element) *Element

Subtract subtracts the input from the receiver, and returns the receiver.

func (*Element) UnmarshalBinary

func (e *Element) UnmarshalBinary(data []byte) error

UnmarshalBinary sets e to the decoding of the byte encoded element.

func (*Element) UnmarshalText

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

UnmarshalText implements the encoding.UnmarshalText interface.

type Group

type Group byte

Group identifies prime-order groups over elliptic curves with hash-to-curve operations

const (
	// Ristretto255Sha512 identifies the Ristretto255 group with SHA2-512 hash-to-group hashing
	Ristretto255Sha512 Group = 1 + iota

	// P256Sha256 identifies a group over P256 with SHA2-512 hash-to-group hashing
	P256Sha256

	// P384Sha384 identifies a group over P384 with SHA2-384 hash-to-group hashing
	P384Sha384

	// P521Sha512 identifies a group over P521 with SHA2-512 hash-to-group hashing
	P521Sha512
)

func (Group) Available

func (g Group) Available() bool

Available reports whether the given Group is linked into the binary.

func (Group) Base

func (g Group) Base() *Element

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

func (Group) ElementLength

func (g Group) ElementLength() uint

ElementLength returns the byte size of an encoded element.

func (Group) EncodeToGroup

func (g Group) EncodeToGroup(input, dst []byte) *Element

EncodeToGroup returns a non-uniform mapping of the arbitrary input to an Element in the Group. The DST must not be empty or nil, and is recommended to be longer than 16 bytes.

func (Group) HashToGroup

func (g Group) HashToGroup(input, dst []byte) *Element

HashToGroup returns a safe mapping of the arbitrary input to an Element in the Group. The DST must not be empty or nil, and is recommended to be longer than 16 bytes.

func (Group) HashToScalar

func (g Group) HashToScalar(input, dst []byte) *Scalar

HashToScalar returns a safe mapping of the arbitrary input to a Scalar. The DST must not be empty or nil, and is recommended to be longer than 16 bytes.

func (Group) NewElement

func (g Group) NewElement() *Element

NewElement returns the identity element (point at infinity).

func (Group) NewScalar

func (g Group) NewScalar() *Scalar

NewScalar returns a new, empty, scalar.

func (Group) RandomElement

func (g Group) RandomElement() *Element

RandomElement returns randomly generated element.

func (Group) RandomScalar

func (g Group) RandomScalar() *Scalar

RandomScalar returns randomly generated scalar.

func (Group) ScalarLength

func (g Group) ScalarLength() uint

ScalarLength returns the byte size of an encoded scalar.

func (Group) String

func (g Group) String() string

String returns the hash-to-curve string identifier of the ciphersuite.

type Scalar

type Scalar struct {
	internal.Scalar
}

Scalar represents a scalar in the prime-order group.

func (*Scalar) Add

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

Add sets the receiver to the sum of the input and the receiver, and returns the receiver.

func (*Scalar) Copy

func (s *Scalar) Copy() *Scalar

Copy returns a copy of the receiver.

func (*Scalar) Decode

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

Decode sets the receiver to a decoding of the input data, and returns an error on failure.

func (*Scalar) Encode

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

Encode returns the compressed byte encoding of the scalar.

func (*Scalar) Equal

func (s *Scalar) Equal(scalar *Scalar) int

Equal returns 1 if the scalars are equal, and 0 otherwise.

func (*Scalar) Invert

func (s *Scalar) Invert() *Scalar

Invert sets the receiver to the scalar's modular inverse ( 1 / scalar ), and returns it.

func (*Scalar) IsZero

func (s *Scalar) IsZero() bool

IsZero returns whether the scalar is 0.

func (*Scalar) MarshalBinary

func (s *Scalar) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*Scalar) MarshalText

func (s *Scalar) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Scalar) Multiply

func (s *Scalar) Multiply(scalar *Scalar) *Scalar

Multiply multiplies the receiver with the input, and returns the receiver.

func (*Scalar) One

func (s *Scalar) One() *Scalar

One sets the scalar to 1, and returns it.

func (*Scalar) Random

func (s *Scalar) Random() *Scalar

Random sets the current scalar to a new random scalar and returns it. The random source is crypto/rand, and this functions is guaranteed to return a non-zero scalar.

func (*Scalar) Set

func (s *Scalar) Set(scalar *Scalar) *Scalar

Set sets the receiver to the value of the argument scalar, and returns the receiver.

func (*Scalar) Subtract

func (s *Scalar) Subtract(scalar *Scalar) *Scalar

Subtract subtracts the input from the receiver, and returns the receiver.

func (*Scalar) UnmarshalBinary

func (s *Scalar) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*Scalar) UnmarshalText

func (s *Scalar) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (*Scalar) Zero

func (s *Scalar) Zero() *Scalar

Zero sets the scalar to 0, and returns it.

Directories

Path Synopsis
Package internal wraps all nist and ristretto255 curves into interfaces
Package internal wraps all nist and ristretto255 curves into interfaces
nist
Package nist implements nist's curves prime-order group
Package nist implements nist's curves prime-order group
r255
Package r255 implements Ristretto255 curve prime-order groups with backend "filippo.io/edwards25519"
Package r255 implements Ristretto255 curve prime-order groups with backend "filippo.io/edwards25519"

Jump to

Keyboard shortcuts

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