group

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: BSD-3-Clause Imports: 14 Imported by: 30

Documentation

Overview

Package group provides prime-order groups based on elliptic curves.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrType      = errors.New("type mismatch")
	ErrUnmarshal = errors.New("error unmarshaling")
)

Functions

func HashToField

func HashToField(u []big.Int, b []byte, e Expander, p *big.Int, L uint)

HashToField generates a set of elements {u1,..., uN} = Hash(b) where each u in GF(p) and L is the security parameter.

func NewExpanderMD

func NewExpanderMD(h crypto.Hash, dst []byte) *expanderMD

NewExpanderMD returns a hash function based on a Merkle-Damgård hash function.

func NewExpanderXOF

func NewExpanderXOF(id xof.ID, kSecLevel uint, dst []byte) *expanderXOF

NewExpanderXOF returns an Expander based on an extendable output function. The kSecLevel parameter is the target security level in bits, and dst is a domain separation string.

Types

type Element

type Element interface {
	IsIdentity() bool
	IsEqual(Element) bool
	Add(Element, Element) Element
	Dbl(Element) Element
	Neg(Element) Element
	Mul(Element, Scalar) Element
	MulGen(Scalar) Element
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	MarshalBinaryCompress() ([]byte, error)
}

Element represents an abstract element of a prime-order group.

type Expander

type Expander interface {
	// Expand generates a pseudo-random byte string of a determined length by
	// expanding an input string.
	Expand(in []byte, length uint) (pseudo []byte)
}

type Group

type Group interface {
	Params() *Params // Params returns parameters for the group
	NewElement() Element
	NewScalar() Scalar
	Identity() Element
	Generator() Element
	Order() Scalar
	RandomElement(io.Reader) Element
	RandomScalar(io.Reader) Scalar
	HashToElement(data, dst []byte) Element
	HashToElementNonUniform(b, dst []byte) Element
	HashToScalar(data, dst []byte) Scalar
}

Group represents a prime-order group based on elliptic curves.

var (
	// P256 is the group generated by P-256 elliptic curve.
	P256 Group = wG{elliptic.P256()}
	// P384 is the group generated by P-384 elliptic curve.
	P384 Group = wG{p384.P384()}
	// P521 is the group generated by P-521 elliptic curve.
	P521 Group = wG{elliptic.P521()}
)
var (
	// Ristretto255 is a quotient group generated from edwards25519 curve.
	Ristretto255 Group = ristrettoGroup{}
)

type Params

type Params struct {
	ElementLength           uint // Length in bytes of an element.
	CompressedElementLength uint // Length in bytes of a compressed element.
	ScalarLength            uint // Length in bytes of a scalar.
}

type Scalar

Scalar represents an integer scalar.

Jump to

Keyboard shortcuts

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