internal

package
v0.0.0-...-f349239 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package internal provides values, structures, and functions to operate FROST that are not part of the public API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidParameters indicates that wrong input has been provided.
	ErrInvalidParameters = errors.New("invalid parameters")

	// ErrInvalidCiphersuite indicates a non-supported ciphersuite is being used.
	ErrInvalidCiphersuite = errors.New("ciphersuite not available")

	// ErrInvalidLength indicates that a provided encoded data piece is not of the expected length.
	ErrInvalidLength = errors.New("invalid encoding length")

	// ErrIdentifierIs0 is returned when the invalid 0 identifier is encountered.
	ErrIdentifierIs0 = errors.New("identifier is 0")

	// ErrEncodingInvalidJSONEncoding is returned when invalid JSON is detected.
	ErrEncodingInvalidJSONEncoding = errors.New("invalid JSON encoding")
)

Functions

func ComputeLambda

func ComputeLambda(g ecc.Group, id uint16, participants []*ecc.Scalar) *ecc.Scalar

ComputeLambda derives the interpolating value for id in the polynomial made by the participant identifiers. This function is not public to protect its usage, as the following conditions MUST be met. - id is non-nil and != 0. - every scalar in participants is non-nil and != 0. - there are no duplicates in participants.

func Concatenate

func Concatenate(input ...[]byte) []byte

Concatenate returns the concatenation of all bytes composing the input elements.

func H1

func H1(g ecc.Group, input []byte) *ecc.Scalar

H1 hashes the input and proves the "rho" DST.

func H2

func H2(g ecc.Group, input []byte) *ecc.Scalar

H2 hashes the input and proves the "chal" DST.

func H3

func H3(g ecc.Group, input []byte) *ecc.Scalar

H3 hashes the input and proves the "nonce" DST.

func H4

func H4(g ecc.Group, msg []byte) []byte

H4 hashes the input and proves the "msg" DST.

func H5

func H5(g ecc.Group, msg []byte) []byte

H5 hashes the input and proves the "com" DST.

func RandomBytes

func RandomBytes(length int) []byte

RandomBytes returns length random bytes (wrapper for crypto/rand).

func UInt64LE

func UInt64LE(i uint64) []byte

UInt64LE returns the 8 byte little endian byte encoding of i.

Types

type Lambda

type Lambda struct {
	// Value is the actual Lambda value.
	Value *ecc.Scalar `json:"value"`

	// Group is necessary so the Value scalar can reliably be decoded in the right group.
	Group ecc.Group `json:"group"`
}

A Lambda is the interpolating value for a given id in the polynomial made by the participant identifiers.

func (*Lambda) UnmarshalJSON

func (l *Lambda) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes data into l, or returns an error.

type LambdaRegistry

type LambdaRegistry map[string]*Lambda

LambdaRegistry holds a signers pre-computed Lambda values, indexed by the list of participants they are associated to. A sorted set of participants will yield the same Lambda.

func (LambdaRegistry) Decode

func (l LambdaRegistry) Decode(g ecc.Group, data []byte) error

Decode populates the receiver from the byte encoded serialization in data.

func (LambdaRegistry) Delete

func (l LambdaRegistry) Delete(participants []uint16)

Delete deletes the Lambda for the given set of participants.

func (LambdaRegistry) Get

func (l LambdaRegistry) Get(participants []uint16) *ecc.Scalar

Get returns the recorded Lambda for the list of participants, or nil if it wasn't found.

func (LambdaRegistry) GetOrNew

func (l LambdaRegistry) GetOrNew(g ecc.Group, id uint16, participants []uint16) *ecc.Scalar

GetOrNew returns the recorded Lambda for the list of participants, or created, records, and returns a new one if it wasn't found. This function assumes that: - id is non-nil and != 0. - every scalar in participants is non-nil and != 0. - there are no duplicates in participants.

func (LambdaRegistry) New

func (l LambdaRegistry) New(g ecc.Group, id uint16, participants []uint16) *ecc.Scalar

New creates a new Lambda and for the participant list for the participant id, and registers it. This function assumes that: - id is non-nil and != 0. - every participant id is != 0. - there are no duplicates in participants.

func (LambdaRegistry) Set

func (l LambdaRegistry) Set(participants []uint16, value *ecc.Scalar)

Set records Lambda for the given set of participants.

Jump to

Keyboard shortcuts

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