party

package
v0.0.0-...-5abc84a Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const IDByteSize = 2

IDByteSize is the number of bytes required to store and ID or Size

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID uint16

ID represents the identifier of a particular party, encoded as a 16 bit unsigned integer. The ID 0 is considered invalid.

func FromBytes

func FromBytes(b []byte) (ID, error)

FromBytes reads the first party.IDByteSize bytes from b and creates an ID from it. Returns an error if b is too small to hold an ID

func RandID

func RandID() ID

RandID returns a pseudo-random value as a ID from the default Source.

func (ID) Bytes

func (id ID) Bytes() []byte

Bytes returns a []byte slice of length party.IDByteSize

func (ID) Lagrange

func (id ID) Lagrange(partyIDs IDSlice) (*ristretto.Scalar, error)

Lagrange gives the Lagrange coefficient lⱼ(x) for x = 0.

We iterate over all points in the set. To get the coefficients over a smaller set, you should first get a smaller subset.

The following formulas are taken from https://en.wikipedia.org/wiki/Lagrange_polynomial

( x  - x₀) ... ( x  - xₖ)

lⱼ(x) = ---------------------------

(xⱼ - x₀) ... (xⱼ - xₖ)

        x₀ ... xₖ

lⱼ(0) = ---------------------------

(x₀ - xⱼ) ... (xₖ - xⱼ)

returns an error if id is not included in partyIDs

func (ID) MarshalText

func (id ID) MarshalText() (text []byte, err error)

MarshalText implements encoding/TextMarshaler interface

func (ID) Scalar

func (id ID) Scalar() *ristretto.Scalar

Scalar returns the corresponding ristretto.Scalar

func (ID) String

func (id ID) String() string

String returns a base 10 representation of ID

func (*ID) UnmarshalText

func (id *ID) UnmarshalText(text []byte) error

UnmarshalText implements encoding/TextMarshaler interface Returns an error when the encoded text is too large

type IDSlice

type IDSlice []ID

IDSlice is an alias for []ID

func NewIDSlice

func NewIDSlice(partyIDs []ID) IDSlice

NewIDSlice returns an IDSlice which is the partyIDs sorted

func (IDSlice) Contains

func (ids IDSlice) Contains(id ID) bool

Contains returns true if id is included in the slice.

func (IDSlice) Copy

func (ids IDSlice) Copy() IDSlice

Copy returns a deep copy of ids

func (IDSlice) Equal

func (ids IDSlice) Equal(o IDSlice) bool

Equal returns true if ids == o

func (IDSlice) IsSubsetOf

func (ids IDSlice) IsSubsetOf(o IDSlice) bool

IsSubsetOf is all elements in ids are in o

func (IDSlice) N

func (ids IDSlice) N() Size

N returns the number of ID s in the slice

type Size

type Size = ID

Size is an alias for ID that allows us to differentiate between a party's ID and the threshold for example.

Jump to

Keyboard shortcuts

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