Documentation
¶
Index ¶
- func EqualSlice(a, b []uint64) bool
- func GenerateCKKSPrimes(logQ, logN, level uint64) ([]uint64, uint64, error)
- func GenerateNTTPrime(logQ, logN uint64) (uint64, error)
- func GeneratePrimesList(logQ, logN, logP uint64) ([]uint64, error)
- func Hash(data []uint64) (value []byte, err error)
- func PowerOf2(x, n, q, qInv uint64) (r uint64)
- func VerifyHash(hash0, hash1 []byte) bool
- type BigPoly
- type ChebyshevInterpolation
- type Ciphertext
- func (ctx *Ciphertext) CkksContext() *CkksContext
- func (ctx *Ciphertext) Copy(ctxCopy CkksElement) error
- func (ctx *Ciphertext) CopyNew() CkksElement
- func (ctx *Ciphertext) CopyParams(ckkselement CkksElement)
- func (ctx *Ciphertext) CurrentModulus() *ring.Int
- func (ctx *Ciphertext) Degree() uint64
- func (ctx *Ciphertext) InvNTT(ct0 CkksElement)
- func (ctx *Ciphertext) IsNTT() bool
- func (ctx *Ciphertext) Level() uint64
- func (ctx *Ciphertext) MarshalBinary() ([]byte, error)
- func (ctx *Ciphertext) NTT(ct0 CkksElement)
- func (ctx *Ciphertext) Resize(degree uint64)
- func (ctx *Ciphertext) Scale() uint64
- func (ctx *Ciphertext) SetCkksContext(ckkscontext *CkksContext)
- func (ctx *Ciphertext) SetCurrentModulus(modulus *ring.Int)
- func (ctx *Ciphertext) SetIsNTT(isNTT bool)
- func (ctx *Ciphertext) SetScale(scale uint64)
- func (ctx *Ciphertext) SetValue(value []*ring.Poly)
- func (ctx *Ciphertext) UnmarshalBinary(data []byte) error
- func (ctx *Ciphertext) Value() []*ring.Poly
- type CkksContext
- func (ckkscontext *CkksContext) ContextKeys() *ring.Context
- func (ckkscontext *CkksContext) NewCiphertext(degree uint64, level uint64, scale uint64) *Ciphertext
- func (ckkscontext *CkksContext) NewDecryptor(sk *SecretKey) (*Decryptor, error)
- func (ckkscontext *CkksContext) NewEncryptor(pk *PublicKey) (*Encryptor, error)
- func (ckkscontext *CkksContext) NewEvaluator() (evaluator *Evaluator)
- func (ckkscontext *CkksContext) NewKeyGenerator() (keygen *KeyGenerator)
- func (ckkscontext *CkksContext) NewPlaintext(level uint64, scale uint64) *Plaintext
- func (ckkscontext *CkksContext) NewRandomCiphertext(degree, level, scale uint64) *Ciphertext
- func (ckkscontext *CkksContext) Precision() uint64
- func (ckkscontext *CkksContext) Slots() uint64
- type CkksElement
- type Decryptor
- type Encryptor
- type EvaluationKey
- type Evaluator
- func (evaluator *Evaluator) Add(c0 CkksElement, c1 CkksElement, cOut CkksElement) (err error)
- func (evaluator *Evaluator) AddConst(c0 CkksElement, constant interface{}, cOut CkksElement) (err error)
- func (evaluator *Evaluator) AddConstNew(c0 CkksElement, constant interface{}) (cOut CkksElement)
- func (evaluator *Evaluator) AddNew(c0 CkksElement, c1 CkksElement) (cOut CkksElement, err error)
- func (evaluator *Evaluator) AddNoMod(c0 *Ciphertext, c1 CkksElement, cOut *Ciphertext) (err error)
- func (evaluator *Evaluator) AddNoModNew(c0 CkksElement, c1 CkksElement) (cOut CkksElement, err error)
- func (evaluator *Evaluator) Conjugate(c0 CkksElement, evakey *RotationKey, c1 CkksElement) error
- func (evaluator *Evaluator) ConjugateNew(c0 CkksElement, evakey *RotationKey) (cOut CkksElement, err error)
- func (evaluator *Evaluator) DivByi(c0 CkksElement, c1 CkksElement) (err error)
- func (evaluator *Evaluator) DivByiNew(c0 CkksElement) (c1 CkksElement, err error)
- func (evaluator *Evaluator) DropLevel(c0 CkksElement, levels uint64) error
- func (evaluator *Evaluator) DropLevelNew(c0 CkksElement, levels uint64) (cOut CkksElement, err error)
- func (evaluator *Evaluator) EvaluateCheby(ct *Ciphertext, cheby *ChebyshevInterpolation, evakey *EvaluationKey) (res *Ciphertext, err error)
- func (evaluator *Evaluator) ExtractImag(c0 *Ciphertext, evakey *RotationKey, cOut *Ciphertext) (err error)
- func (evaluator *Evaluator) ExtractImagNew(c0 *Ciphertext, evakey *RotationKey) (cOut *Ciphertext, err error)
- func (evaluator *Evaluator) InverseNew(ct0 *Ciphertext, steps uint64, evakey *EvaluationKey) (res *Ciphertext, err error)
- func (evaluator *Evaluator) MulByPow2(c0 CkksElement, pow2 uint64, cOut CkksElement) (err error)
- func (evaluator *Evaluator) MulByPow2New(c0 CkksElement, pow2 uint64) (cOut CkksElement, err error)
- func (evaluator *Evaluator) MulRelin(ct0, ct1 CkksElement, evakey *EvaluationKey, cOut CkksElement) error
- func (evaluator *Evaluator) MulRelinNew(ct0, ct1 CkksElement, evakey *EvaluationKey) (cOut CkksElement, err error)
- func (evaluator *Evaluator) MultByConstAndAdd(c0 CkksElement, constant interface{}, cOut CkksElement) (err error)
- func (evaluator *Evaluator) MultByi(c0 CkksElement, c1 CkksElement) (err error)
- func (evaluator *Evaluator) MultByiNew(c0 CkksElement) (c1 CkksElement, err error)
- func (evaluator *Evaluator) MultConst(c0 CkksElement, constant interface{}, cOut CkksElement) (err error)
- func (evaluator *Evaluator) MultConstNew(c0 CkksElement, constant interface{}) (cOut CkksElement, err error)
- func (evaluator *Evaluator) Neg(c0 CkksElement, cOut CkksElement) (err error)
- func (evaluator *Evaluator) NegNew(c0 CkksElement) (cOut CkksElement)
- func (evaluator *Evaluator) Power(ct0 CkksElement, degree uint64, evakey *EvaluationKey, res CkksElement) error
- func (evaluator *Evaluator) PowerNew(ct0 *Ciphertext, degree uint64, evakey *EvaluationKey) (res *Ciphertext)
- func (evaluator *Evaluator) PowerOf2(ct0 CkksElement, logPow2 uint64, evakey *EvaluationKey, ct1 CkksElement) error
- func (evaluator *Evaluator) Reduce(c0 CkksElement, cOut CkksElement) error
- func (evaluator *Evaluator) ReduceNew(c0 CkksElement) (cOut CkksElement)
- func (evaluator *Evaluator) Relinearize(cIn *Ciphertext, evakey *EvaluationKey, cOut *Ciphertext) (err error)
- func (evaluator *Evaluator) RelinearizeNew(cIn *Ciphertext, evakey *EvaluationKey) (cOut *Ciphertext, err error)
- func (evaluator *Evaluator) RemoveImag(c0 *Ciphertext, evakey *RotationKey, cOut *Ciphertext) (err error)
- func (evaluator *Evaluator) RemoveImagNew(c0 *Ciphertext, evakey *RotationKey) (cOut *Ciphertext, err error)
- func (evaluator *Evaluator) RemoveReal(c0 *Ciphertext, evakey *RotationKey, cOut *Ciphertext) (err error)
- func (evaluator *Evaluator) RemoveRealNew(c0 *Ciphertext, evakey *RotationKey) (cOut *Ciphertext, err error)
- func (evaluator *Evaluator) Rescale(c0, c1 CkksElement) (err error)
- func (evaluator *Evaluator) RescaleNew(c0 CkksElement) (cOut CkksElement, err error)
- func (evaluator *Evaluator) RotateColumns(c0 CkksElement, k uint64, evakey *RotationKey, c1 CkksElement) (err error)
- func (evaluator *Evaluator) RotateColumnsNew(c0 CkksElement, k uint64, evakey *RotationKey) (cOut CkksElement, err error)
- func (evaluator *Evaluator) ScaleUp(c0 CkksElement, scale uint64, cOut CkksElement) (err error)
- func (evaluator *Evaluator) ScaleUpNew(c0 CkksElement, scale uint64) (cOut CkksElement, err error)
- func (evaluator *Evaluator) Square(ct0 CkksElement, evakey *EvaluationKey, ct1 CkksElement) error
- func (evaluator *Evaluator) SquareNew(ct0 CkksElement, evakey *EvaluationKey) (ct1 CkksElement, err error)
- func (evaluator *Evaluator) Sub(c0 CkksElement, c1 CkksElement, cOut CkksElement) (err error)
- func (evaluator *Evaluator) SubNew(c0 CkksElement, c1 CkksElement) (cOut CkksElement, err error)
- func (evaluator *Evaluator) SubNoMod(c0 CkksElement, c1 CkksElement, cOut CkksElement) (err error)
- func (evaluator *Evaluator) SubNoModNew(c0 CkksElement, c1 CkksElement) (cOut CkksElement, err error)
- func (evaluator *Evaluator) SwapRealImag(c0 *Ciphertext, evakey *RotationKey, cOut *Ciphertext) (err error)
- func (evaluator *Evaluator) SwapRealImagNew(c0 *Ciphertext, evakey *RotationKey) (cOut *Ciphertext, err error)
- func (evaluator *Evaluator) SwitchKeys(cIn *Ciphertext, switchingKey *SwitchingKey, cOut *Ciphertext) error
- func (evaluator *Evaluator) SwitchKeysNew(cIn *Ciphertext, switchingKey *SwitchingKey) (cOut *Ciphertext, err error)
- type KeyGenerator
- func (keygen *KeyGenerator) NewKeyPair() (sk *SecretKey, pk *PublicKey, err error)
- func (keygen *KeyGenerator) NewPublicKey(sk *SecretKey) (pk *PublicKey, err error)
- func (keygen *KeyGenerator) NewRelinKey(sk *SecretKey, bitDecomp uint64) (evakey *EvaluationKey, err error)
- func (keygen *KeyGenerator) NewRotationKeys(sk_output *SecretKey, bitDecomp uint64, rotLeft []uint64, rotRight []uint64, ...) (rotKey *RotationKey, err error)
- func (keygen *KeyGenerator) NewRotationKeysPow2(sk_output *SecretKey, bitDecomp uint64, conjugate bool) (rotKey *RotationKey, err error)
- func (keygen *KeyGenerator) NewSecretKey() *SecretKey
- func (keygen *KeyGenerator) NewSwitchingKey(sk_input, sk_output *SecretKey, bitDecomp uint64) (newevakey *SwitchingKey, err error)
- func (keygen *KeyGenerator) SetRelinKeys(rlk [][][2]*ring.Poly, bitDecomp uint64) (*EvaluationKey, error)
- type Plaintext
- func (P *Plaintext) CkksContext() *CkksContext
- func (P *Plaintext) Copy(PCopy CkksElement) error
- func (P *Plaintext) CopyNew() CkksElement
- func (P *Plaintext) CopyParams(ckkselement CkksElement)
- func (P *Plaintext) CurrentModulus() *ring.Int
- func (plaintext *Plaintext) DecodeComplex() (res []complex128)
- func (plaintext *Plaintext) DecodeFloat() (res []float64)
- func (P *Plaintext) Degree() uint64
- func (plaintext *Plaintext) EncodeComplex(coeffs []complex128) error
- func (plaintext *Plaintext) EncodeFloat(coeffs []float64) error
- func (P *Plaintext) InvNTT(ct0 CkksElement)
- func (P *Plaintext) IsNTT() bool
- func (P *Plaintext) Level() uint64
- func (P *Plaintext) NTT(ct0 CkksElement)
- func (P *Plaintext) Resize(degree uint64)
- func (P *Plaintext) Scale() uint64
- func (P *Plaintext) SetCkksContext(ckkscontext *CkksContext)
- func (P *Plaintext) SetCurrentModulus(modulus *ring.Int)
- func (P *Plaintext) SetIsNTT(isNTT bool)
- func (P *Plaintext) SetScale(scale uint64)
- func (P *Plaintext) SetValue(value []*ring.Poly)
- func (P *Plaintext) Value() []*ring.Poly
- type PublicKey
- type RotationKey
- type SecretKey
- type SwitchingKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualSlice ¶
func GenerateCKKSPrimes ¶
Generates CKKS Primes byed on logQ = size of the primes, logN = size of N and level, the number of levels we require. Will return all the appropriate primes, up to the number of level, with the best avaliable precision for the given level. TODO : choose between sorting the primes by size or by precision
func GenerateNTTPrime ¶
func GeneratePrimesList ¶
func VerifyHash ¶
Types ¶
type ChebyshevInterpolation ¶
type ChebyshevInterpolation struct {
// contains filtered or unexported fields
}
func Approximate ¶
func Approximate(function func(complex128) complex128, a, b complex128, degree int) (cheby *ChebyshevInterpolation)
Approximate computes a Chebyshev approximation of the input function, for the tange [-a, b] of degree degree. To be used in conjonction with the function EvaluateCheby.
type Ciphertext ¶
type Ciphertext BigPoly
func (*Ciphertext) CkksContext ¶
func (ctx *Ciphertext) CkksContext() *CkksContext
CkksContext returns the ckkscontext of the ciphertext.
func (*Ciphertext) Copy ¶
func (ctx *Ciphertext) Copy(ctxCopy CkksElement) error
Copy copies the reference ciphertext and its parameters on the receiver ciphertext.
func (*Ciphertext) CopyNew ¶
func (ctx *Ciphertext) CopyNew() CkksElement
CopyNew generates a new copy of the reference ciphertext, with the same value and same parameters.
func (*Ciphertext) CopyParams ¶
func (ctx *Ciphertext) CopyParams(ckkselement CkksElement)
CopyParams copies the reference ciphertext parameters on the receiver ciphertext.
func (*Ciphertext) CurrentModulus ¶
func (ctx *Ciphertext) CurrentModulus() *ring.Int
CurrentModulus returns the current modulus of the ciphertext. This value is only used at the decryption process.
func (*Ciphertext) Degree ¶
func (ctx *Ciphertext) Degree() uint64
Degree returns the current degree of the ciphertext.
func (*Ciphertext) InvNTT ¶
func (ctx *Ciphertext) InvNTT(ct0 CkksElement)
InvNTT computes the inverse NTT of the ciphertext and copies it on the receiver element. Can only be used if the reference ciphertext is in the NTT domain.
func (*Ciphertext) IsNTT ¶
func (ctx *Ciphertext) IsNTT() bool
IsNTT returns true if the ciphertext is in NTT form, else returns false.
func (*Ciphertext) Level ¶
func (ctx *Ciphertext) Level() uint64
Level returns the current level of the ciphertext.
func (*Ciphertext) MarshalBinary ¶
func (ctx *Ciphertext) MarshalBinary() ([]byte, error)
MarshalBinary converts a ciphertext to an array of bytes
func (*Ciphertext) NTT ¶
func (ctx *Ciphertext) NTT(ct0 CkksElement)
NTT computes the NTT of the ciphertext and copies it on the receiver element. Can only be used if the reference ciphertext is not already in the NTT domain.
func (*Ciphertext) Resize ¶
func (ctx *Ciphertext) Resize(degree uint64)
Resize resize the degree of a ciphertext, by allocating or removing polynomial. To be used to format a receiver of the wrong degree to a receiver of the correct degree.
func (*Ciphertext) Scale ¶
func (ctx *Ciphertext) Scale() uint64
Scale returns the current scale of the ciphertext.
func (*Ciphertext) SetCkksContext ¶
func (ctx *Ciphertext) SetCkksContext(ckkscontext *CkksContext)
Set CkksContext assign a new ckkscontext to the ciphertext.
func (*Ciphertext) SetCurrentModulus ¶
func (ctx *Ciphertext) SetCurrentModulus(modulus *ring.Int)
SetCurrentModulus assigns a new modulus to the ciphertext. This value is only used at the decryption process.
func (*Ciphertext) SetIsNTT ¶
func (ctx *Ciphertext) SetIsNTT(isNTT bool)
SetIsNTT assigns a new value to the isNTT variable of the ciphertext.
func (*Ciphertext) SetScale ¶
func (ctx *Ciphertext) SetScale(scale uint64)
SetScale assigns a new scale to the ciphertext. Assagning a new scale to a ciphertext can be used to obtain free division or multiplication by 2^n.
func (*Ciphertext) SetValue ¶
func (ctx *Ciphertext) SetValue(value []*ring.Poly)
SetValue assigns a polynomial to a ciphertext value.
func (*Ciphertext) UnmarshalBinary ¶
func (ctx *Ciphertext) UnmarshalBinary(data []byte) error
UnmarshalBinary converts an array of bytes to a ciphertext
func (*Ciphertext) Value ¶
func (ctx *Ciphertext) Value() []*ring.Poly
Value returns the ciphertext polynomial.
type CkksContext ¶
type CkksContext struct {
// contains filtered or unexported fields
}
func NewCkksContext ¶
func NewCkksContext(logN, logQ, logScale, levels uint64, sigma float64) (*CkksContext, error)
NewCkksContext generates a new ckkscontext, given the parameters logN, logQ, logScale (in base 2), levels and sigma.
func (*CkksContext) ContextKeys ¶
func (ckkscontext *CkksContext) ContextKeys() *ring.Context
func (*CkksContext) NewCiphertext ¶
func (ckkscontext *CkksContext) NewCiphertext(degree uint64, level uint64, scale uint64) *Ciphertext
NewCiphertext creates a new ciphertext parametised by degree, level and scale.
func (*CkksContext) NewDecryptor ¶
func (ckkscontext *CkksContext) NewDecryptor(sk *SecretKey) (*Decryptor, error)
NewDecryptor instanciates a new decryptor that will be able to decrypt ciphertext encrypted under the provided key.
func (*CkksContext) NewEncryptor ¶
func (ckkscontext *CkksContext) NewEncryptor(pk *PublicKey) (*Encryptor, error)
NewEncryptor instanciates a new Encryptor with the provided public key. This encryptor can be used to encrypt plaintexts, using its the stored public key.
func (*CkksContext) NewEvaluator ¶
func (ckkscontext *CkksContext) NewEvaluator() (evaluator *Evaluator)
NewEvaluator instanciates a new Evaluator, that can be used to conduct homomorphic operations on the ciphertexts and/or plaintexts. It stores a small pool of polynomials and ciphertexts that will be used to store intermediate values.
func (*CkksContext) NewKeyGenerator ¶
func (ckkscontext *CkksContext) NewKeyGenerator() (keygen *KeyGenerator)
NewKeyGenerator instantiates a new keygenerator, from which the secret and public keys, as well as the evaluation, rotation and switching keys can be generated.
func (*CkksContext) NewPlaintext ¶
func (ckkscontext *CkksContext) NewPlaintext(level uint64, scale uint64) *Plaintext
NewPlaintext creates a new plaintext of level level and scale scale.
func (*CkksContext) NewRandomCiphertext ¶
func (ckkscontext *CkksContext) NewRandomCiphertext(degree, level, scale uint64) *Ciphertext
NewRandoMCiphertext generates a new uniformely distributed ciphertext of degree, level and scale.
func (*CkksContext) Precision ¶
func (ckkscontext *CkksContext) Precision() uint64
func (*CkksContext) Slots ¶
func (ckkscontext *CkksContext) Slots() uint64
type CkksElement ¶
type CkksElement interface {
Value() []*ring.Poly
SetValue([]*ring.Poly)
CkksContext() *CkksContext
Scale() uint64
SetScale(uint64)
CurrentModulus() *ring.Int
SetCurrentModulus(*ring.Int)
CopyParams(CkksElement)
Resize(uint64)
CopyNew() CkksElement
Copy(CkksElement) error
Degree() uint64
Level() uint64
NTT(CkksElement)
InvNTT(CkksElement)
IsNTT() bool
SetIsNTT(bool)
}
type Decryptor ¶
type Decryptor struct {
// contains filtered or unexported fields
}
func (*Decryptor) Decrypt ¶
func (decryptor *Decryptor) Decrypt(ciphertext *Ciphertext, plaintext *Plaintext) (err error)
Decrypt decrypts the ciphertext and returns the result on the provided receiver plaintext. A Horner methode is used for evaluating the decryption.
func (*Decryptor) DecryptNew ¶
func (decryptor *Decryptor) DecryptNew(ciphertext *Ciphertext) (plaintext *Plaintext, err error)
DecryptNew decrypts the ciphertext and returns a newly created plaintext.
type Encryptor ¶
type Encryptor struct {
// contains filtered or unexported fields
}
func (*Encryptor) Encrypt ¶
func (encryptor *Encryptor) Encrypt(plaintext *Plaintext, ciphertext *Ciphertext) error
Encrypt encrypts the provided plaitnext under the stored public key, and returns the result on the provided reciver ciphertext.
func (*Encryptor) EncryptNew ¶
func (encryptor *Encryptor) EncryptNew(plaintext *Plaintext) (*Ciphertext, error)
EncryptNew encrypts the provided plaintext under the stored public key and returns the ciphertext on a newly created element.
type EvaluationKey ¶
type EvaluationKey struct {
// contains filtered or unexported fields
}
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
func (*Evaluator) Add ¶
func (evaluator *Evaluator) Add(c0 CkksElement, c1 CkksElement, cOut CkksElement) (err error)
Add adds the first element to the second element and returns the result on the third element.
func (*Evaluator) AddConst ¶
func (evaluator *Evaluator) AddConst(c0 CkksElement, constant interface{}, cOut CkksElement) (err error)
AddConstNew adds the provided constant, which can be an uint64, int64, float64 or complex128. The result is returned on the provided receiver element.
func (*Evaluator) AddConstNew ¶
func (evaluator *Evaluator) AddConstNew(c0 CkksElement, constant interface{}) (cOut CkksElement)
AddConstNew adds the provided constant, which can be an uint64, int64, float64 or complex128. The result is returned on a newly created element.
func (*Evaluator) AddNew ¶
func (evaluator *Evaluator) AddNew(c0 CkksElement, c1 CkksElement) (cOut CkksElement, err error)
Add adds the first element to the second element and returns the result on a newly created element.
func (*Evaluator) AddNoMod ¶
func (evaluator *Evaluator) AddNoMod(c0 *Ciphertext, c1 CkksElement, cOut *Ciphertext) (err error)
AddNoMod adds the first element to the second element and returns the result on the third element, without conducting modular reduction.
func (*Evaluator) AddNoModNew ¶
func (evaluator *Evaluator) AddNoModNew(c0 CkksElement, c1 CkksElement) (cOut CkksElement, err error)
Add adds the first element to the second element without conducting modular reduction, and returns the result on a newly created element.
func (*Evaluator) Conjugate ¶
func (evaluator *Evaluator) Conjugate(c0 CkksElement, evakey *RotationKey, c1 CkksElement) error
ConjugateNew conjugates the input element (which is equivalement to a row rotation) and returns the result on the provided receiver element. If the provided element is a ciphertext, a keyswitching operation is necessary and a rotation key for the row rotation needs to be provided.
func (*Evaluator) ConjugateNew ¶
func (evaluator *Evaluator) ConjugateNew(c0 CkksElement, evakey *RotationKey) (cOut CkksElement, err error)
ConjugateNew conjugates the input element (which is equivalement to a row rotation) and returns the result on a newly created element. If the provided element is a ciphertext, a keyswitching operation is necessary and a rotation key for the row rotation needs to be provided.
func (*Evaluator) DivByi ¶
func (evaluator *Evaluator) DivByi(c0 CkksElement, c1 CkksElement) (err error)
MultByiNew multiplies the input element by the imaginary number 1/i, and returns the result on the receiver element. Does not change the scale.
func (*Evaluator) DivByiNew ¶
func (evaluator *Evaluator) DivByiNew(c0 CkksElement) (c1 CkksElement, err error)
MultByiNew multiplies the input element by the imaginary number 1/i, and returns the result on a newly created element. Does not change the scale.
func (*Evaluator) DropLevel ¶
func (evaluator *Evaluator) DropLevel(c0 CkksElement, levels uint64) error
DropLevel reduces the level of the input element by levels and returns the result on the provided receiver element. No rescaling is applied during this procedure.
func (*Evaluator) DropLevelNew ¶
func (evaluator *Evaluator) DropLevelNew(c0 CkksElement, levels uint64) (cOut CkksElement, err error)
DropLevel reduces the level of the input element by levels and returns the result on a newly created element. No rescaling is applied during this procedure.
func (*Evaluator) EvaluateCheby ¶
func (evaluator *Evaluator) EvaluateCheby(ct *Ciphertext, cheby *ChebyshevInterpolation, evakey *EvaluationKey) (res *Ciphertext, err error)
EvaluateCheby evaluates a chebyshev approximation in log(n) + 1 (+1 if 2/(b-a) is not a gaussian integer)
func (*Evaluator) ExtractImag ¶
func (evaluator *Evaluator) ExtractImag(c0 *Ciphertext, evakey *RotationKey, cOut *Ciphertext) (err error)
ExtractImag sets the real part to the imaginary part and sets the imaginary part to zero, i.e. a + b*i -> b + 0*i. The result is returned on the provided receiver element. Requires a rotationkey for which the conjugate key has been generated. Scale is increased by one.
func (*Evaluator) ExtractImagNew ¶
func (evaluator *Evaluator) ExtractImagNew(c0 *Ciphertext, evakey *RotationKey) (cOut *Ciphertext, err error)
ExtractImagNew sets the real part to the imaginary part and sets the imaginary part to zero, i.e. a + b*i -> b + 0*i. The result is returned on a newly created element. Requires a rotationkey for which the conjugate key has been generated. Scale is increased by one.
func (*Evaluator) InverseNew ¶
func (evaluator *Evaluator) InverseNew(ct0 *Ciphertext, steps uint64, evakey *EvaluationKey) (res *Ciphertext, err error)
InverseNew computes 1/x, iterating for n steps and consuming n levels. The algorithm requirese x to be in the range [-1.5 - 1.5i, 1.5 + 1.5i] or the result will be wrong. Each iteration increases the precision.
func (*Evaluator) MulByPow2 ¶
func (evaluator *Evaluator) MulByPow2(c0 CkksElement, pow2 uint64, cOut CkksElement) (err error)
MutByPow2New multiplies the input element by 2^n and returns the result on the provided receiver element.
func (*Evaluator) MulByPow2New ¶
func (evaluator *Evaluator) MulByPow2New(c0 CkksElement, pow2 uint64) (cOut CkksElement, err error)
MutByPow2New multiplies the input element by 2^n and returns the result on a newly created element.
func (*Evaluator) MulRelin ¶
func (evaluator *Evaluator) MulRelin(ct0, ct1 CkksElement, evakey *EvaluationKey, cOut CkksElement) error
MulRelinNew multiplies the two provided elements and returns the result on the provided receiver element. the multiplication between scales of the input elements (addition when the scale is represented in log2). An evaluation key can be provided to apply a relinearization step and reduce the degree of the output element. This evaluation key is only required when the two inputs elements are ciphertexts. If not evaluationkey is provided and the input elements are two ciphertexts, the resulting ciphertext will be of degree two. This function only accepts plaintexts (degree zero) and/or ciphertexts of degree one.
func (*Evaluator) MulRelinNew ¶
func (evaluator *Evaluator) MulRelinNew(ct0, ct1 CkksElement, evakey *EvaluationKey) (cOut CkksElement, err error)
MulRelinNew multiplies the two provided elements and returns the result on a newly created element. The new scale is the multiplication between scales of the input elements (addition when the scale is represented in log2). An evaluation key can be provided to apply a relinearization step and reduce the degree of the output element. This evaluation key is only required when the two inputs elements are ciphertexts. If not evaluationkey is provided and the input elements are two ciphertexts, the resulting ciphertext will be of degree two. This function only accepts plaintexts (degree zero) and/or ciphertexts of degree one.
func (*Evaluator) MultByConstAndAdd ¶
func (evaluator *Evaluator) MultByConstAndAdd(c0 CkksElement, constant interface{}, cOut CkksElement) (err error)
MultByConstAndAdd multiplies the input element by the constant, and adds it to the receiver element (does not modify the input element), i.e. cOut(x) = cOut(x) + c0(x) * (a+bi). This functions removes the need of storing intermediate value c(x) * (a+bi). This function will modifie the level and the scale of the receiver element depending on the level and the scale of the input element and the type of the constant. The level of the receiver element will be set to min(input.level, receiver.level). The scale of the receiver element will be set to the scale that the input element would have after the multiplication by the constant.
func (*Evaluator) MultByi ¶
func (evaluator *Evaluator) MultByi(c0 CkksElement, c1 CkksElement) (err error)
MultByiNew multiplies the input element by the imaginary number i, and returns the result on the receiver element. Does not change the scale.
func (*Evaluator) MultByiNew ¶
func (evaluator *Evaluator) MultByiNew(c0 CkksElement) (c1 CkksElement, err error)
MultByiNew multiplies the input element by the imaginary number i, and returns the result on a newly created element. Does not change the scale.
func (*Evaluator) MultConst ¶
func (evaluator *Evaluator) MultConst(c0 CkksElement, constant interface{}, cOut CkksElement) (err error)
MultConstNew multiplies the input element by a constant and returns the result on the receiver element. The scale of the output element will depend on the scale of the input element and the constant (if the constant needs to be scaled (its rational part is not zero)). The constant can be an uint64, int64, float64 or complex128.
func (*Evaluator) MultConstNew ¶
func (evaluator *Evaluator) MultConstNew(c0 CkksElement, constant interface{}) (cOut CkksElement, err error)
MultConstNew multiplies the input element by a constant and returns the result on a newly created element. The scale of the output element will depend on the scale of the input element and the constant (if the constant needs to be scaled (its rational part is not zero)). The constant can be an uint64, int64, float64 or complex128.
func (*Evaluator) Neg ¶
func (evaluator *Evaluator) Neg(c0 CkksElement, cOut CkksElement) (err error)
Neg negates the input element and returns the result on the provided receiver element.
func (*Evaluator) NegNew ¶
func (evaluator *Evaluator) NegNew(c0 CkksElement) (cOut CkksElement)
Neg negates the input element and returns the result on a newly created element.
func (*Evaluator) Power ¶
func (evaluator *Evaluator) Power(ct0 CkksElement, degree uint64, evakey *EvaluationKey, res CkksElement) error
Power compute x^degree, consuming log(degree) levels, and returns the result on the receiver element. Providing an evaluation key is necessary when degree > 2.
func (*Evaluator) PowerNew ¶
func (evaluator *Evaluator) PowerNew(ct0 *Ciphertext, degree uint64, evakey *EvaluationKey) (res *Ciphertext)
Power compute x^degree, consuming log(degree) levels, and returns the result on a new element. Providing an evaluation key is necessary when degree > 2.
func (*Evaluator) PowerOf2 ¶
func (evaluator *Evaluator) PowerOf2(ct0 CkksElement, logPow2 uint64, evakey *EvaluationKey, ct1 CkksElement) error
PowerOf2 compute x^(2^logPow2), consuming logPow2 levels, and returns the result on the receiver element. Providing an evaluation key is necessary when logPow2 > 1.
func (*Evaluator) Reduce ¶
func (evaluator *Evaluator) Reduce(c0 CkksElement, cOut CkksElement) error
Reduce applies a modular reduction on the input element and returns the result on the receiver element. To be used in conjonction with function not applying modular reduction.
func (*Evaluator) ReduceNew ¶
func (evaluator *Evaluator) ReduceNew(c0 CkksElement) (cOut CkksElement)
Reduce applies a modular reduction on the input element and returns the result on a newly created element. To be used in conjonction with function not applying modular reduction.
func (*Evaluator) Relinearize ¶
func (evaluator *Evaluator) Relinearize(cIn *Ciphertext, evakey *EvaluationKey, cOut *Ciphertext) (err error)
RelinearizeNew applies the relinearization procedure on the provided ciphertext and returns the result on the provided receiver ciphertext. Requirese the input ciphertext to be of degree two.
func (*Evaluator) RelinearizeNew ¶
func (evaluator *Evaluator) RelinearizeNew(cIn *Ciphertext, evakey *EvaluationKey) (cOut *Ciphertext, err error)
RelinearizeNew applies the relinearization procedure on the provided ciphertext and returns the result on a newly created ciphertext. Requirese the input ciphertext to be of degree two.
func (*Evaluator) RemoveImag ¶
func (evaluator *Evaluator) RemoveImag(c0 *Ciphertext, evakey *RotationKey, cOut *Ciphertext) (err error)
RemoveImag sets the imag part to zero and returns the result on the provided receiver element, i.e. a + b*i -> a. Requires a rotationkey for which the conjugate key has been generated. Scale is increased by one.
func (*Evaluator) RemoveImagNew ¶
func (evaluator *Evaluator) RemoveImagNew(c0 *Ciphertext, evakey *RotationKey) (cOut *Ciphertext, err error)
RemoveImagNew sets the imag part to zero and returns the result on a newly created element, i.e. a + b*i -> a. Requires a rotationkey for which the conjugate key has been generated. Scale is increased by one.
func (*Evaluator) RemoveReal ¶
func (evaluator *Evaluator) RemoveReal(c0 *Ciphertext, evakey *RotationKey, cOut *Ciphertext) (err error)
RemoveReal sets the real part to zero and returns the result on the provided receiver element, i.e. a + b*i -> b*i. Requires a rotationkey for which the conjugate key has been generated. Scale is increased by one.
func (*Evaluator) RemoveRealNew ¶
func (evaluator *Evaluator) RemoveRealNew(c0 *Ciphertext, evakey *RotationKey) (cOut *Ciphertext, err error)
RemoveRealNew sets the real part to zero and returns the result on a newly created element, i.e. a + b*i -> b*i. Requires a rotationkey for which the conjugate key has been generated. Scale is increased by one.
func (*Evaluator) Rescale ¶
func (evaluator *Evaluator) Rescale(c0, c1 CkksElement) (err error)
RescaleNew divides the input element by the last modulus in the modulus chain, and repeats this procedure until the scale reaches the original scale or would go below it, and returns the result on the provided receiver element. Since all the modulie in the modulus chain are generated to be close to the original scale, this procedure is equivalement to dividing the input element by the scale and adding some error.
func (*Evaluator) RescaleNew ¶
func (evaluator *Evaluator) RescaleNew(c0 CkksElement) (cOut CkksElement, err error)
RescaleNew divides the input element by the last modulus in the modulus chain, and repeats this procedure until the scale reaches the original scale or would go below it, and returns the result on a newly created element. Since all the modulie in the modulus chain are generated to be close to the original scale, this procedure is equivalement to dividing the input element by the scale and adding some error.
func (*Evaluator) RotateColumns ¶
func (evaluator *Evaluator) RotateColumns(c0 CkksElement, k uint64, evakey *RotationKey, c1 CkksElement) (err error)
RotateColumns rotates the columns of the provided element by k position to the left and returns the result on the provided receiver. If the provided element is a ciphertext, a keyswitching operation is necessary and a rotation key for the specific rotation needs to be provided.
func (*Evaluator) RotateColumnsNew ¶
func (evaluator *Evaluator) RotateColumnsNew(c0 CkksElement, k uint64, evakey *RotationKey) (cOut CkksElement, err error)
RotateColumnsNew rotates the columns of the provided element by k position to the left, and returns the result on a newly created element. If the provided element is a ciphertext, a keyswitching operation is necessary and a rotation key for the specific rotation needs to be provided.
func (*Evaluator) ScaleUp ¶
func (evaluator *Evaluator) ScaleUp(c0 CkksElement, scale uint64, cOut CkksElement) (err error)
ScaleUpNew multiplies the input element by 2^n and sets its scale to its previous scale plus 2^n. Returns the result on the provided receiver element.
func (*Evaluator) ScaleUpNew ¶
func (evaluator *Evaluator) ScaleUpNew(c0 CkksElement, scale uint64) (cOut CkksElement, err error)
ScaleUpNew multiplies the input element by 2^n and sets its scale to its previous scale plus 2^n. Returns the result on a newly created element.
func (*Evaluator) Square ¶
func (evaluator *Evaluator) Square(ct0 CkksElement, evakey *EvaluationKey, ct1 CkksElement) error
Square compute x^2 and returns the result on the receiver element. The input can be either a ciphertext or a plaintext. In the case of a ciphertext input, an optional evaluation key given as input. If done so, a relinearization step will occure after the squaring and the output ciphertext will remain at degree one. If not evaluation key is provided (nil), the output ciphertext will be of degree two.
func (*Evaluator) SquareNew ¶
func (evaluator *Evaluator) SquareNew(ct0 CkksElement, evakey *EvaluationKey) (ct1 CkksElement, err error)
SquareNew compute x^2 and returns the result on a new element. The input can be either a ciphertext or a plaintext. In the case of a ciphertext input, an optional evaluation key given as input. If done so, a relinearization step will occure after the squaring and the output ciphertext will remain at degree one. If not evaluation key is provided (nil), the output ciphertext will be of degree two.
func (*Evaluator) Sub ¶
func (evaluator *Evaluator) Sub(c0 CkksElement, c1 CkksElement, cOut CkksElement) (err error)
Sub subtracts second element to the the first element and returns the result on the third element.
func (*Evaluator) SubNew ¶
func (evaluator *Evaluator) SubNew(c0 CkksElement, c1 CkksElement) (cOut CkksElement, err error)
SubNew subtracts second element to the the first element and returns the result on a newly created element.
func (*Evaluator) SubNoMod ¶
func (evaluator *Evaluator) SubNoMod(c0 CkksElement, c1 CkksElement, cOut CkksElement) (err error)
SubNoMod subtracts second element to the the first element and returns the result on the third element, without conducting modular reduction.
func (*Evaluator) SubNoModNew ¶
func (evaluator *Evaluator) SubNoModNew(c0 CkksElement, c1 CkksElement) (cOut CkksElement, err error)
SubNoModNew subtracts second element to the the first element withotu conducting modular reduction, and returns the result on a newly created element.
func (*Evaluator) SwapRealImag ¶
func (evaluator *Evaluator) SwapRealImag(c0 *Ciphertext, evakey *RotationKey, cOut *Ciphertext) (err error)
SwapRealImagNew swaps the real and imaginary parts and returns the result on the provided receiver element, i.e. a + b*i -> b + a * i. Requires a rotationkey for which the conjugate key has been generated.
func (*Evaluator) SwapRealImagNew ¶
func (evaluator *Evaluator) SwapRealImagNew(c0 *Ciphertext, evakey *RotationKey) (cOut *Ciphertext, err error)
SwapRealImagNew swaps the real and imaginary parts and returns the result on a newly created element, i.e. a + b*i -> b + a * i. Requires a rotationkey for which the conjugate key has been generated.
func (*Evaluator) SwitchKeys ¶
func (evaluator *Evaluator) SwitchKeys(cIn *Ciphertext, switchingKey *SwitchingKey, cOut *Ciphertext) error
Switchkeys re-encrypts the input ciphertext under a different key and returns the result on the receiver element. Requirese a switchinkey, which is computed from the key under which the ciphertext is currently encrypted, and the key under which the ciphertext will be re-encrypted.
func (*Evaluator) SwitchKeysNew ¶
func (evaluator *Evaluator) SwitchKeysNew(cIn *Ciphertext, switchingKey *SwitchingKey) (cOut *Ciphertext, err error)
Switchkeys re-encrypts the input ciphertext under a different key and returns the result on a newly created element. Requirese a switchinkey, which is computed from the key under which the ciphertext is currently encrypted, and the key under which the ciphertext will be re-encrypted.
type KeyGenerator ¶
type KeyGenerator struct {
// contains filtered or unexported fields
}
func (*KeyGenerator) NewKeyPair ¶
func (keygen *KeyGenerator) NewKeyPair() (sk *SecretKey, pk *PublicKey, err error)
NewKeyPair generates a new secretkey and a corresponding public key.
func (*KeyGenerator) NewPublicKey ¶
func (keygen *KeyGenerator) NewPublicKey(sk *SecretKey) (pk *PublicKey, err error)
NewPublicKey generates a new public key from the provided secret key.
func (*KeyGenerator) NewRelinKey ¶
func (keygen *KeyGenerator) NewRelinKey(sk *SecretKey, bitDecomp uint64) (evakey *EvaluationKey, err error)
NewRelinkey generates a new evaluation key that will be used to relinearize the ciphertexts during multiplication. Bitdecomposition aims at reducing the added noise at the expense of more storage needed for the keys and more computation during the relinearization. However for relinearization this bitdecomp value can be set to maximum as the encrypted value are also scaled up during the multiplication.
func (*KeyGenerator) NewRotationKeys ¶
func (keygen *KeyGenerator) NewRotationKeys(sk_output *SecretKey, bitDecomp uint64, rotLeft []uint64, rotRight []uint64, conjugate bool) (rotKey *RotationKey, err error)
NewRotationKeys generates a new instance of rotationkeys, with the provided rotation to the left, right and conjugation if asked. Here bitdecomp plays a role in the added noise if the scale of the input is smaller than the maximum size between the modulies.
func (*KeyGenerator) NewRotationKeysPow2 ¶
func (keygen *KeyGenerator) NewRotationKeysPow2(sk_output *SecretKey, bitDecomp uint64, conjugate bool) (rotKey *RotationKey, err error)
NewRotationkeysPow2 generates a new rotation key with all the power of two rotation to the left and right, as well as the conjugation key if asked. Here bitdecomp plays a role in the added noise if the scale of the input is smaller than the maximum size between the modulies.
func (*KeyGenerator) NewSecretKey ¶
func (keygen *KeyGenerator) NewSecretKey() *SecretKey
NewSecretKey generates a new secret key.
func (*KeyGenerator) NewSwitchingKey ¶
func (keygen *KeyGenerator) NewSwitchingKey(sk_input, sk_output *SecretKey, bitDecomp uint64) (newevakey *SwitchingKey, err error)
NewSwitchingKey generated a new keyswitching key, that will re-encrypt a ciphertext encrypted under the input key to the output key. Here bitdecomp plays a role in the added noise if the scale of the input is smaller than the maximum size between the modulies.
func (*KeyGenerator) SetRelinKeys ¶
func (keygen *KeyGenerator) SetRelinKeys(rlk [][][2]*ring.Poly, bitDecomp uint64) (*EvaluationKey, error)
type Plaintext ¶
type Plaintext BigPoly
func (*Plaintext) CkksContext ¶
func (P *Plaintext) CkksContext() *CkksContext
CkksContext returns the ckkscontext of the plaintext.
func (*Plaintext) Copy ¶
func (P *Plaintext) Copy(PCopy CkksElement) error
Copy copies the value and parameters of the reference plaintext ot the receiver plaintext.
func (*Plaintext) CopyNew ¶
func (P *Plaintext) CopyNew() CkksElement
CopyNew creates a new plaintext with the same value and same parameters.
func (*Plaintext) CopyParams ¶
func (P *Plaintext) CopyParams(ckkselement CkksElement)
CopyParams copies the parameters of the reference plaintext to the receiver plaintext.
func (*Plaintext) CurrentModulus ¶
CurrentModulus returns the current modulus of the plaintext. This variable is only used during the decoding.
func (*Plaintext) DecodeComplex ¶
func (plaintext *Plaintext) DecodeComplex() (res []complex128)
DecodeFloat decodes the plaintext to a slice of complex128 values of size at most N/2.
func (*Plaintext) DecodeFloat ¶
DecodeFloat decodes the plaintext to a slice of float64 values of size at most N/2.
func (*Plaintext) Degree ¶
Degree returns the degree of the plaintext, this value should always be zero.
func (*Plaintext) EncodeComplex ¶
func (plaintext *Plaintext) EncodeComplex(coeffs []complex128) error
EncodeFloat encode a complex128 slice of at most N/2 values.
func (*Plaintext) EncodeFloat ¶
EncodeFloat encode a float64 slice of at most N/2 values.
func (*Plaintext) InvNTT ¶
func (P *Plaintext) InvNTT(ct0 CkksElement)
InvNTT applies the inverse NTT transform to a plaintext and returns the result on the receiver element. Can only be used it the plaintext is in the NTT domain
func (*Plaintext) IsNTT ¶
IsNTT returns true or false depending on if the plaintext is in the NTT domain or not.
func (*Plaintext) NTT ¶
func (P *Plaintext) NTT(ct0 CkksElement)
NTT applies the NTT transform to a plaintext and returns the result on the receiver element. Can only be used if the plaintext is not already in the NTT domain.
func (*Plaintext) SetCkksContext ¶
func (P *Plaintext) SetCkksContext(ckkscontext *CkksContext)
SetCkksContext assigns a new ckkscontext to the plaintext.
func (*Plaintext) SetCurrentModulus ¶
SetCurrentModulus sets the current modulus to the provided values. This variable is only used during the decoding.
func (*Plaintext) SetScale ¶
SetScale sets the scale of the plaintext to the provided value (in log2).
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
type RotationKey ¶
type RotationKey struct {
// contains filtered or unexported fields
}
type SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
type SwitchingKey ¶
type SwitchingKey struct {
// contains filtered or unexported fields
}