lintrans

package
v6.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package lintrans implements homomorphic linear transformations for the CKKS scheme.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode[T ckks.Float](ecd schemes.Encoder, diagonals Diagonals[T], allocated LinearTransformation) (err error)

Encode is a method used to encode a transformation and a wrapper of lintrans.Encode.

func GaloisElements

func GaloisElements(params rlwe.ParameterProvider, lt Parameters) (galEls []uint64)

GaloisElements returns the list of Galois elements required to evaluate the linear transformation.

Types

type Diagonals

type Diagonals[T ckks.Float] lintrans.Diagonals[T]

Diagonals is a wrapper of lintrans.Diagonals.

func (Diagonals[T]) DiagonalsIndexList

func (m Diagonals[T]) DiagonalsIndexList() (indexes []int)

DiagonalsIndexList returns the list of the non-zero diagonals of the square matrix. A non zero diagonals is a diagonal with a least one non-zero element.

func (Diagonals[T]) Evaluate

func (m Diagonals[T]) Evaluate(vector []T, newVec func(size int) []T, add func(a, b, c []T), muladd func(a, b, c []T)) (res []T)

Evaluate evaluates the linear transformation on the provided vector. add: c = a + b muladd: c = c + a * b

type Evaluator

type Evaluator struct {
	lintrans.Evaluator
}

Evaluator is an evaluator providing an API to evaluate linear transformations on rlwe.Ciphertexts. All fields of this struct are public, enabling custom instantiations.

func NewEvaluator

func NewEvaluator(eval schemes.Evaluator) (linTransEval *Evaluator)

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

func (Evaluator) Evaluate

func (eval Evaluator) Evaluate(ctIn *rlwe.Ciphertext, linearTransformation LinearTransformation, opOut *rlwe.Ciphertext) (err error)

Evaluate takes as input a ciphertext ctIn, a linear transformation M and evaluates opOut: M(ctIn).

func (Evaluator) EvaluateMany

func (eval Evaluator) EvaluateMany(ctIn *rlwe.Ciphertext, linearTransformations []LinearTransformation, opOut []*rlwe.Ciphertext) (err error)

EvaluateMany takes as input a ciphertext ctIn, a list of linear transformations [M0, M1, M2, ...] and a list of pre-allocated receiver opOut and evaluates opOut: [M0(ctIn), M1(ctIn), M2(ctIn), ...]

func (Evaluator) EvaluateManyNew

func (eval Evaluator) EvaluateManyNew(ctIn *rlwe.Ciphertext, linearTransformations []LinearTransformation) (opOut []*rlwe.Ciphertext, err error)

EvaluateManyNew takes as input a ciphertext ctIn and a list of linear transformations [M0, M1, M2, ...] and returns opOut:[M0(ctIn), M1(ctIn), M2(ctInt), ...].

func (Evaluator) EvaluateNew

func (eval Evaluator) EvaluateNew(ctIn *rlwe.Ciphertext, linearTransformation LinearTransformation) (opOut *rlwe.Ciphertext, err error)

EvaluateNew takes as input a ciphertext ctIn and a linear transformation M and evaluate and returns opOut: M(ctIn).

func (Evaluator) EvaluateSequential

func (eval Evaluator) EvaluateSequential(ctIn *rlwe.Ciphertext, linearTransformations []LinearTransformation, opOut *rlwe.Ciphertext) (err error)

EvaluateSequential takes as input a ciphertext ctIn and a list of linear transformations [M0, M1, M2, ...] and returns opOut:...M2(M1(M0(ctIn))

func (Evaluator) EvaluateSequentialNew

func (eval Evaluator) EvaluateSequentialNew(ctIn *rlwe.Ciphertext, linearTransformations []LinearTransformation) (opOut *rlwe.Ciphertext, err error)

EvaluateSequentialNew takes as input a ciphertext ctIn and a list of linear transformations [M0, M1, M2, ...] and returns opOut:...M2(M1(M0(ctIn))

type LinearTransformation

type LinearTransformation lintrans.LinearTransformation

LinearTransformation is a wrapper of lintrans.LinearTransformation.

func NewTransformation

func NewTransformation(params rlwe.ParameterProvider, lt Parameters) LinearTransformation

NewTransformation instantiates a new LinearTransformation and is a wrapper of lintrans.LinearTransformation.

func (LinearTransformation) GaloisElements

func (lt LinearTransformation) GaloisElements(params rlwe.ParameterProvider) []uint64

GaloisElements returns the list of Galois elements required to evaluate the linear transformation.

type Parameters

type Parameters lintrans.Parameters

Parameters is a wrapper of lintrans.Parameters.

type Permutation

type Permutation[T ckks.Float] []PermutationMapping[T]

Permutation is a struct that defines generic permutations over vectors.

For example, given the vector [a, b, c, d] that would be mapped to the vector [1b, 2c, 3d, 4a] then the Permutation would contain the following map: {0: {3, 4}, 1:{0, 1}, 2:{1, 2}, 3:{2, 3}}

func (Permutation[T]) GetDiagonals

func (p Permutation[T]) GetDiagonals(logSlots int) Diagonals[T]

GetDiagonals returns the non-zero diagonals of the matrix representation of the permutation, which can be used to instantiate Parameters.

type PermutationMapping

type PermutationMapping[T ckks.Float] struct {
	From    int
	To      int
	Scaling T
}

PermutationMapping is a struct storing a mapping: From -> To and a scaling value.

Jump to

Keyboard shortcuts

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