polynomial

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalEq

func EvalEq(api frontend.API, x, y []frontend.Variable) (eq frontend.Variable)

EvalEq returns Πⁿ₁ Eq(xᵢ, yᵢ) = Πⁿ₁ xᵢyᵢ + (1-xᵢ)(1-yᵢ) = Πⁿ₁ (1 + 2xᵢyᵢ - xᵢ - yᵢ). Is assumes len(x) = len(y) =: n

func InterpolateLDE

func InterpolateLDE(api frontend.API, at frontend.Variable, values []frontend.Variable) frontend.Variable

InterpolateLDE fits a polynomial f of degree len(values)-1 such that f(i) = values[i] whenever defined. Returns f(at)

Types

type MultiLin

type MultiLin []frontend.Variable

func (MultiLin) Clone

func (m MultiLin) Clone() MultiLin

func (MultiLin) Evaluate

func (m MultiLin) Evaluate(api frontend.API, at []frontend.Variable) frontend.Variable

Evaluate assumes len(m) = 1 << len(at) it doesn't modify m

Example
const logSize = 20
const size = 1 << logSize
m := MultiLin(make([]frontend.Variable, size))
e := MultiLin(make([]frontend.Variable, logSize))

cs, err := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &evalMultiLinCircuit{M: m, At: e, Evaluation: 0})
if err != nil {
	panic(err)
}
fmt.Println("r1cs size:", cs.GetNbConstraints())

cs, err = frontend.Compile(ecc.BN254.ScalarField(), scs.NewBuilder, &evalMultiLinCircuit{M: m, At: e, Evaluation: 0})
if err != nil {
	panic(err)
}
fmt.Println("scs size:", cs.GetNbConstraints())
Output:

r1cs size: 1048627
scs size: 2097226

func (MultiLin) NumVars

func (m MultiLin) NumVars() int

type Polynomial

type Polynomial []frontend.Variable

func (Polynomial) Eval

func (p Polynomial) Eval(api frontend.API, at frontend.Variable) (pAt frontend.Variable)

Jump to

Keyboard shortcuts

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