lut

package
v0.0.0-...-e525fad Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package lut implements look-up tables evaluation for R-LWE schemes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLUT

func InitLUT(g func(x float64) (y float64), scale float64, ringQ *ring.Ring, a, b float64) (F *ring.Poly)

InitLUT takes a function g, and creates a LUT polynomial for the function in the interval [a, b]. Inputs to the LUT evaluation are assumed to have been normalized with the change of basis (2*x - a - b)/(b-a). Interval [a, b] should take into account the "drift" of the value x, caused by the change of modulus from Q to 2N.

func MulBySmallMonomialMod2N

func MulBySmallMonomialMod2N(mask uint64, pol *ring.Poly, n int)

MulBySmallMonomialMod2N multiplies pol by x^n, with 0 <= n < N

Types

type EvaluationKey

type EvaluationKey struct {
	SkPos []*rgsw.Ciphertext
	SkNeg []*rgsw.Ciphertext
}

EvaluationKey is a struct storing the encryption of the bits of the LWE key.

func GenEvaluationKey

func GenEvaluationKey(paramsRLWE rlwe.Parameters, skRLWE *rlwe.SecretKey, paramsLWE rlwe.Parameters, skLWE *rlwe.SecretKey) (key EvaluationKey)

GenEvaluationKey generates the LUT evaluation key

type Evaluator

type Evaluator struct {
	*rgsw.Evaluator

	Sk *rlwe.SecretKey
	// contains filtered or unexported fields
}

Evaluator is a struct that stores the necessary data to handle LWE <-> RLWE conversion and LUT evaluation.

func NewEvaluator

func NewEvaluator(paramsLUT, paramsLWE rlwe.Parameters, rtks *rlwe.RotationKeySet) (eval *Evaluator)

NewEvaluator creates a new Handler

func (*Evaluator) Evaluate

func (eval *Evaluator) Evaluate(ct *rlwe.Ciphertext, lutPolyWihtSlotIndex map[int]*ring.Poly, key EvaluationKey) (res map[int]*rlwe.Ciphertext)

Evaluate extracts on the fly LWE samples and evaluates the provided LUT on the LWE. ct : a rlwe Ciphertext with coefficient encoded values at level 0 lutPolyWihtSlotIndex : a map with [slot_index] -> LUT lutKey : lut.Key Returns a map[slot_index] -> LUT(ct[slot_index])

func (*Evaluator) EvaluateAndRepack

func (eval *Evaluator) EvaluateAndRepack(ct *rlwe.Ciphertext, lutPolyWihtSlotIndex map[int]*ring.Poly, repackIndex map[int]int, key EvaluationKey) (res *rlwe.Ciphertext)

EvaluateAndRepack extracts on the fly LWE samples, evaluates the provided LUT on the LWE and repacks everything into a single rlwe.Ciphertext. ct : a rlwe Ciphertext with coefficient encoded values at level 0 lutPolyWihtSlotIndex : a map with [slot_index] -> LUT repackIndex : a map with [slot_index_have] -> slot_index_want lutKey : LUTKey Returns a *rlwe.Ciphertext

func (*Evaluator) ModSwitchRLWETo2NLvl

func (eval *Evaluator) ModSwitchRLWETo2NLvl(level int, polQ *ring.Poly, pol2N *ring.Poly)

ModSwitchRLWETo2NLvl applies round(x * 2N / Q) to the coefficients of polQ and returns the result on pol2N.

Jump to

Keyboard shortcuts

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