polynomial

package
v6.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package polynomial implements a homomorphic polynomial evaluator for the BFV/BGV schemes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CoefficientGetter

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

CoefficientGetter is a struct that implements the polynomial.CoefficientGetter[uint64] interface.

func (CoefficientGetter) GetSingleCoefficient

func (c CoefficientGetter) GetSingleCoefficient(pol polynomial.Polynomial, k int) (value uint64)

GetSingleCoefficient should return the k-th coefficient of Polynomial as the type uint64.

func (CoefficientGetter) GetVectorCoefficient

func (c CoefficientGetter) GetVectorCoefficient(pol polynomial.PolynomialVector, k int) (values []uint64)

GetVectorCoefficient return a slice []uint64 containing the k-th coefficient of each polynomial of PolynomialVector indexed by its Mapping. See PolynomialVector for additional information about the Mapping.

type Evaluator

type Evaluator struct {
	bgv.Parameters
	polynomial.Evaluator[uint64]
	InvariantTensoring bool
}

func NewEvaluator

func NewEvaluator(params bgv.Parameters, eval *bgv.Evaluator) *Evaluator

NewEvaluator instantiates a new PolynomialEvaluator from a bgv.Evaluator.

func (Evaluator) Evaluate

func (eval Evaluator) Evaluate(ct *rlwe.Ciphertext, p interface{}, targetScale rlwe.Scale) (opOut *rlwe.Ciphertext, err error)

Evaluate evaluates a polynomial on the input Ciphertext in ceil(log2(deg+1)) levels. Returns an error if the input ciphertext does not have enough level to carry out the full polynomial evaluation. Returns an error if something is wrong with the scale. If the polynomial is given in Chebyshev basis, then a change of basis ct' = (2/(b-a)) * (ct + (-a-b)/(b-a)) is necessary before the polynomial evaluation to ensure correctness. pol: a *bignum.Polynomial, *Polynomial or *PolynomialVector targetScale: the desired output scale. This value shouldn't differ too much from the original ciphertext scale. It can for example be used to correct small deviations in the ciphertext scale and reset it to the default scale.

func (Evaluator) EvaluateFromPowerBasis

func (eval Evaluator) EvaluateFromPowerBasis(pb polynomial.PowerBasis, p interface{}, targetScale rlwe.Scale) (opOut *rlwe.Ciphertext, err error)

EvaluateFromPowerBasis evaluates a polynomial using the provided polynomial.PowerBasis, holding pre-computed powers of X. This method is the same as Evaluate except that the encrypted input is a PowerBasis. See [Evaluate] for additional information.

type Polynomial

type Polynomial polynomial.Polynomial

Polynomial is a type wrapping the type polynomial.Polynomial.

func NewPolynomial

func NewPolynomial[T bgv.Integer](coeffs []T) Polynomial

NewPolynomial creates a new Polynomial from a list of coefficients []T.

type PolynomialVector

type PolynomialVector polynomial.PolynomialVector

PolynomialVector is a type wrapping the type polynomial.PolynomialVector.

func NewPolynomialVector

func NewPolynomialVector[T bgv.Integer](polys [][]T, mapping map[int][]int) (PolynomialVector, error)

func (PolynomialVector) Depth

func (p PolynomialVector) Depth() int

Depth returns the depth of the target PolynomialVector.

Jump to

Keyboard shortcuts

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