Documentation ¶
Index ¶
- Variables
- type Polynomial
- func NewPolynomial(fieldOrder *big.Int, coefficients []*big.Int) (*Polynomial, error)
- func RandomPolynomial(fieldOrder *big.Int, degree uint32) (*Polynomial, error)
- func RandomPolynomialWithSpecialValueAtPoint(x *big.Int, specialValue *big.Int, fieldOrder *big.Int, degree uint32) (*Polynomial, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyCoefficients is returned if the coefficients is empty ErrEmptyCoefficients = errors.New("empty coefficient") )
Functions ¶
This section is empty.
Types ¶
type Polynomial ¶
type Polynomial struct {
// contains filtered or unexported fields
}
Polynomial represents a polynomial of arbitrary degree
func NewPolynomial ¶
NewPolynomial news a polynomial module fieldOrder. Warning: This function may produce modulo bias if applied directly to slices that have not previously undergone rejection sampling.
func RandomPolynomial ¶
func RandomPolynomial(fieldOrder *big.Int, degree uint32) (*Polynomial, error)
RandomPolynomial randoms a polynomial with random coefficient
func RandomPolynomialWithSpecialValueAtPoint ¶ added in v1.0.2
func RandomPolynomialWithSpecialValueAtPoint(x *big.Int, specialValue *big.Int, fieldOrder *big.Int, degree uint32) (*Polynomial, error)
RandomPolynomialWithSpecialValueAtPoint gives a random polynomial f with the given degree with the condition: f(x) = specialValue.
func (*Polynomial) Degree ¶
func (p *Polynomial) Degree() uint32
Degree returns the degree of the polynomial
func (*Polynomial) Differentiate ¶
func (p *Polynomial) Differentiate(diffTime uint32) *Polynomial
Differentiate returns a differentiated function Given f(x) is a polynomial, then output is f^(diffTime)(x) mod field order Ex: f(x)=x^5+2*x^3, diffTime = 1 Then f^(1)(x)= 5*x^4+6*x^2 = 2*x^4.
func (*Polynomial) Evaluate ¶
func (p *Polynomial) Evaluate(x *big.Int) *big.Int
Evaluate returns f(x) mod field order Given a polynomial f(x), then the output is f(x) Ex:f(3)=x^5+2*x^3, x=1, fieldOrder=3 Then f(1)=3=0 mod field order
func (*Polynomial) Get ¶
func (p *Polynomial) Get(i int) *big.Int
Get gets the ith coefficients. If i is out of range, return nil.
func (*Polynomial) SetConstant ¶
func (p *Polynomial) SetConstant(value *big.Int)
SetConstant sets the constant term of the polynomial