poly

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lagrange

func Lagrange(shares []Share) (*big.Int, error)

Types

type Element

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

func (*Element) Add

func (e *Element) Add(e2 *Element) *Element

func (*Element) Clone

func (e *Element) Clone() *Element

func (*Element) Exp

func (e *Element) Exp(i *big.Int) *Element

func (*Element) Inverse

func (e *Element) Inverse() *Element

func (*Element) Mul

func (e *Element) Mul(e2 *Element) *Element

func (*Element) Neg

func (e *Element) Neg() *Element

func (*Element) Value

func (e *Element) Value() *big.Int

type Field

type Field struct {
	N *big.Int
}

func (*Field) NewElement

func (f *Field) NewElement(i *big.Int) *Element

func (*Field) NewElementInt

func (f *Field) NewElementInt(i int) *Element

func (*Field) NewPoly

func (f *Field) NewPoly(deg int, zVal *big.Int) (*Poly, error)

The field elements are assumed NOT to be in Montgomery form

func (*Field) RandomElement

func (f *Field) RandomElement(rd io.Reader) (*Element, error)

type Poly

type Poly struct {
	Coefficients []Element
	Field        *Field
}

func (Poly) EvalAt

func (pol Poly) EvalAt(x *Element) *Element

Evaluate the polynomial at x

func (Poly) EvalAtInt

func (pol Poly) EvalAtInt(x int) *Element

Evaluate the polynomial at x

func (*Poly) GenerateShares

func (p *Poly) GenerateShares(nshares int) ([]Share, error)

type Share

type Share struct {
	Point *big.Int
	Value *big.Int
	N     *big.Int
	D     int //one day this may be not enough of a degree
}

A Share represents an evaluatio of a polynomial of degree D at Point with the resulting Value. All calculations are over a prime field of N

func SplitBytes

func SplitBytes(sec []byte, n, t int, prime big.Int) ([]Share, error)

Jump to

Keyboard shortcuts

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