polynomial

package
v6.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package polynomial implements a homomorphic polynomial evaluator for the CKKS scheme.

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*bignum.Complex interface.

func (CoefficientGetter) GetSingleCoefficient

func (c CoefficientGetter) GetSingleCoefficient(pol polynomial.Polynomial, k int) (value *bignum.Complex)

GetSingleCoefficient returns the k-th coefficient of Polynomial as the type *bignum.Complex.

func (CoefficientGetter) GetVectorCoefficient

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

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

type Evaluator

type Evaluator struct {
	ckks.Parameters
	polynomial.Evaluator[*bignum.Complex]
}

Evaluator is a wrapper of the polynomial.Evaluator. All fields of this struct are public, enabling custom instantiations.

func NewEvaluator

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

NewEvaluator instantiates a new Evaluator from a ckks.Evaluator. This method is allocation free.

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 levels 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 the user must apply change of basis ct' = scale * ct + offset before the polynomial evaluation to ensure correctness. The values `scale` and `offet` can be obtained from the polynomial with the method .ChangeOfBasis().

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 polynomial.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(poly bignum.Polynomial) Polynomial

NewPolynomial creates a new Polynomial from a bignum.Polynomial.

type PolynomialVector

type PolynomialVector polynomial.PolynomialVector

PolynomialVector is a type wrapping the type polynomial.PolynomialVector.

func NewPolynomialVector

func NewPolynomialVector(polys []bignum.Polynomial, mapping map[int][]int) (PolynomialVector, error)

NewPolynomialVector creates a new PolynomialVector from a list of bignum.Polynomial and a mapping map[poly_index][slots_index] which stores which polynomial has to be evaluated on which slot. Slots that are not referenced in this mapping will be evaluated to zero. User must ensure that a same slot is not referenced twice.

func (PolynomialVector) ChangeOfBasis

func (p PolynomialVector) ChangeOfBasis(slots int) (scalar, constant []*big.Float)

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