Documentation
¶
Overview ¶
Package ckks implements a RNS-accelerated version of the Homomorphic Encryption for Arithmetic for Approximate Numbers (HEAAN, a.k.a. CKKS) scheme. It provides approximate arithmetic over the complex numbers.
Index ¶
- Constants
- Variables
- func Approximate(function func(complex128) complex128, a, b complex128, degree int) (cheby *chebyshevinterpolation)
- func GenerateCKKSPrimes(logQ, logN, levels uint64) ([]uint64, error)
- type Ciphertext
- func (el Ciphertext) Ciphertext() *Ciphertext
- func (el Ciphertext) Copy(ctxCopy *ckksElement) (err error)
- func (el Ciphertext) CopyNew() *ckksElement
- func (el Ciphertext) CopyParams(ckkselement *ckksElement)
- func (el Ciphertext) CurrentModulus() *ring.Int
- func (el Ciphertext) Degree() uint64
- func (el Ciphertext) Element() *ckksElement
- func (el Ciphertext) InvNTT(ckkscontext *CkksContext, c *ckksElement) error
- func (el Ciphertext) IsNTT() bool
- func (el Ciphertext) Level() uint64
- func (ciphertext *Ciphertext) MarshalBinary() ([]byte, error)
- func (el Ciphertext) NTT(ckkscontext *CkksContext, c *ckksElement) error
- func (el Ciphertext) Plaintext() *Plaintext
- func (el Ciphertext) Resize(ckkscontext *CkksContext, degree uint64)
- func (el Ciphertext) Scale() uint64
- func (el Ciphertext) SetCurrentModulus(modulus *ring.Int)
- func (el Ciphertext) SetIsNTT(value bool)
- func (el Ciphertext) SetScale(scale uint64)
- func (el Ciphertext) SetValue(value []*ring.Poly)
- func (ciphertext *Ciphertext) UnMarshalBinary(data []byte) error
- func (el Ciphertext) Value() []*ring.Poly
- type CkksContext
- func (ckkscontext *CkksContext) ContextKeys() *ring.Context
- func (ckkscontext *CkksContext) Levels() uint64
- func (ckkscontext *CkksContext) LogN() uint64
- func (ckkscontext *CkksContext) LogQ() uint64
- func (ckkscontext *CkksContext) Moduli() []uint64
- func (ckkscontext *CkksContext) NewCiphertext(degree uint64, level uint64, scale uint64) *Ciphertext
- func (ckkscontext *CkksContext) NewCkksElement(degree, level, scale uint64) *ckksElement
- func (ckkscontext *CkksContext) NewDecryptor(sk *SecretKey) (*Decryptor, error)
- func (ckkscontext *CkksContext) NewEncoder() (encoder *Encoder)
- func (ckkscontext *CkksContext) NewEncryptorFromPk(pk *PublicKey) (*Encryptor, error)
- func (ckkscontext *CkksContext) NewEncryptorFromSk(sk *SecretKey) (*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 *Ciphertext)
- func (ckkscontext *CkksContext) Scale() uint64
- func (ckkscontext *CkksContext) Sigma() float64
- func (ckkscontext *CkksContext) Slots() uint64
- type Decryptor
- type Encoder
- func (encoder *Encoder) DecodeComplex(plaintext *Plaintext) (res []complex128)
- func (encoder *Encoder) DecodeFloat(plaintext *Plaintext) (res []float64)
- func (encoder *Encoder) EncodeComplex(plaintext *Plaintext, coeffs []complex128) (err error)
- func (encoder *Encoder) EncodeFloat(plaintext *Plaintext, coeffs []float64) (err error)
- type Encryptor
- type EvaluationKey
- type Evaluator
- func (evaluator *Evaluator) Add(op0, op1 Operand, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) AddConst(ct0 *Ciphertext, constant interface{}, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) AddConstNew(ct0 *Ciphertext, constant interface{}) (ctOut *Ciphertext)
- func (evaluator *Evaluator) AddNew(op0, op1 Operand) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) AddNoMod(op0, op1 Operand, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) AddNoModNew(op0, op1 Operand) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) Conjugate(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) ConjugateNew(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) DivByi(ct0 *Ciphertext, c1 *Ciphertext) (err error)
- func (evaluator *Evaluator) DivByiNew(ct0 *Ciphertext) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) DropLevel(ct0 *ckksElement, levels uint64) error
- func (evaluator *Evaluator) DropLevelNew(ct0 *ckksElement, levels uint64) (ctOut *ckksElement, err error)
- func (evaluator *Evaluator) EvaluateCheby(ct *Ciphertext, cheby *chebyshevinterpolation, evakey *EvaluationKey) (res *Ciphertext, err error)
- func (evaluator *Evaluator) ExtractImag(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) ExtractImagNew(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) InverseNew(ct0 *Ciphertext, steps uint64, evakey *EvaluationKey) (res *Ciphertext, err error)
- func (evaluator *Evaluator) MulByPow2(ct0 *ckksElement, pow2 uint64, ctOut *ckksElement) (err error)
- func (evaluator *Evaluator) MulByPow2New(ct0 *Ciphertext, pow2 uint64) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) MulRelin(op0, op1 Operand, evakey *EvaluationKey, ctOut *Ciphertext) error
- func (evaluator *Evaluator) MulRelinNew(op0, op1 Operand, evakey *EvaluationKey) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) MultByConstAndAdd(ct0 *Ciphertext, constant interface{}, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) MultByi(ct0 *Ciphertext, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) MultByiNew(ct0 *Ciphertext) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) MultConst(ct0 *Ciphertext, constant interface{}, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) MultConstNew(ct0 *Ciphertext, constant interface{}) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) Neg(ct0 *Ciphertext, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) NegNew(ct0 *Ciphertext) (ctOut *Ciphertext)
- func (evaluator *Evaluator) Power(ct0 *Ciphertext, degree uint64, evakey *EvaluationKey, res *Ciphertext) (err error)
- func (evaluator *Evaluator) PowerNew(op *Ciphertext, degree uint64, evakey *EvaluationKey) (opOut *Ciphertext)
- func (evaluator *Evaluator) PowerOf2(el0 *Ciphertext, logPow2 uint64, evakey *EvaluationKey, elOut *Ciphertext) (err error)
- func (evaluator *Evaluator) Reduce(ct0 *Ciphertext, ctOut *Ciphertext) error
- func (evaluator *Evaluator) ReduceNew(ct0 *Ciphertext) (ctOut *Ciphertext)
- func (evaluator *Evaluator) Relinearize(ct0 *Ciphertext, evakey *EvaluationKey, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) RelinearizeNew(ct0 *Ciphertext, evakey *EvaluationKey) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) RemoveImag(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) RemoveImagNew(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) RemoveReal(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) RemoveRealNew(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) Rescale(ct0, c1 *Ciphertext) (err error)
- func (evaluator *Evaluator) RescaleNew(ct0 *Ciphertext) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) RotateColumns(ct0 *Ciphertext, k uint64, evakey *RotationKey, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) RotateColumnsNew(ct0 *Ciphertext, k uint64, evakey *RotationKey) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) ScaleUp(ct0 *Ciphertext, scale uint64, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) ScaleUpNew(ct0 *Ciphertext, scale uint64) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) Sub(op0, op1 Operand, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) SubNew(op0, op1 Operand) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) SubNoMod(op0, op1 Operand, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) SubNoModNew(op0, op1 Operand) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) SwapRealImag(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
- func (evaluator *Evaluator) SwapRealImagNew(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
- func (evaluator *Evaluator) SwitchKeys(ct0 *Ciphertext, switchingKey *SwitchingKey, ctOut *Ciphertext) error
- func (evaluator *Evaluator) SwitchKeysNew(ct0 *Ciphertext, switchingKey *SwitchingKey) (ctOut *Ciphertext, err error)
- type KeyGenerator
- func (keygen *KeyGenerator) NewKeyPair() (sk *SecretKey, pk *PublicKey)
- func (keygen *KeyGenerator) NewPublicKey(sk *SecretKey) (pk *PublicKey, err error)
- func (keygen *KeyGenerator) NewPublicKeyEmpty() (pk *PublicKey)
- func (keygen *KeyGenerator) NewRelinKey(sk *SecretKey, bitDecomp uint64) (evakey *EvaluationKey, err error)
- func (keygen *KeyGenerator) NewRelinKeyEmpty(bitDecomp uint64) (evakey *EvaluationKey)
- func (keygen *KeyGenerator) NewRotationKeys(sk_output *SecretKey, bitDecomp uint64, rotLeft []uint64, rotRight []uint64, ...) (rotKey *RotationKey, err error)
- func (keygen *KeyGenerator) NewRotationKeysEmpty() (rotKey *RotationKey)
- func (keygen *KeyGenerator) NewRotationKeysPow2(sk_output *SecretKey, bitDecomp uint64, conjugate bool) (rotKey *RotationKey, err error)
- func (keygen *KeyGenerator) NewSecretKey() (sk *SecretKey)
- func (keygen *KeyGenerator) NewSecretKeyEmpty() *SecretKey
- func (keygen *KeyGenerator) NewSecretKeyWithDistrib(p float64) (sk *SecretKey, err error)
- func (keygen *KeyGenerator) NewSwitchingKey(sk_input, sk_output *SecretKey, bitDecomp uint64) (newevakey *SwitchingKey, err error)
- func (keygen *KeyGenerator) NewSwitchingKeyEmpty(bitDecomp uint64) (evakey *SwitchingKey)
- func (keygen *KeyGenerator) SetRelinKeys(rlk [][][2]*ring.Poly, bitDecomp uint64) (*EvaluationKey, error)
- type Operand
- type Parameters
- type Plaintext
- func (el Plaintext) Ciphertext() *Ciphertext
- func (el Plaintext) Copy(ctxCopy *ckksElement) (err error)
- func (el Plaintext) CopyNew() *ckksElement
- func (el Plaintext) CopyParams(ckkselement *ckksElement)
- func (el Plaintext) CurrentModulus() *ring.Int
- func (el Plaintext) Degree() uint64
- func (el Plaintext) Element() *ckksElement
- func (el Plaintext) InvNTT(ckkscontext *CkksContext, c *ckksElement) error
- func (el Plaintext) IsNTT() bool
- func (el Plaintext) Level() uint64
- func (el Plaintext) NTT(ckkscontext *CkksContext, c *ckksElement) error
- func (el Plaintext) Plaintext() *Plaintext
- func (el Plaintext) Resize(ckkscontext *CkksContext, degree uint64)
- func (el Plaintext) Scale() uint64
- func (el Plaintext) SetCurrentModulus(modulus *ring.Int)
- func (el Plaintext) SetIsNTT(value bool)
- func (el Plaintext) SetScale(scale uint64)
- func (el Plaintext) SetValue(value []*ring.Poly)
- func (el Plaintext) Value() []*ring.Poly
- type PublicKey
- type RotationKey
- type SecretKey
- type SwitchingKey
Constants ¶
const MaxLogN = 16
MaxN is the largest supported polynomial modulus degree
const MaxModuliCount = 34
MaxModuliCount is the largest supported number of moduli in the RNS representation
Variables ¶
var DefaultParams = map[uint64]*Parameters{ 11: {11, []uint8{54}, 45, 3.2}, 12: {12, []uint8{44, 32, 32}, 32, 3.2}, 13: {13, []uint8{49, 42, 42, 42, 42}, 42, 3.2}, 14: {14, []uint8{50, 43, 43, 43, 43, 43, 43, 43, 43, 43}, 43, 3.2}, 15: {15, []uint8{53, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46}, 46, 3.2}, }
DefaultParams is a set of default CKKS parameters ensuring 128 bit security.
Functions ¶
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.
func GenerateCKKSPrimes ¶
Generates CKKS Primes given 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.
Types ¶
type Ciphertext ¶
type Ciphertext struct {
// contains filtered or unexported fields
}
Ciphertext is a BigPoly of degree > 0.
func (Ciphertext) Ciphertext ¶ added in v1.1.0
func (el Ciphertext) Ciphertext() *Ciphertext
func (Ciphertext) Copy ¶
func (el Ciphertext) Copy(ctxCopy *ckksElement) (err error)
Copy copies the input element and its parameters on the target element.
func (Ciphertext) CopyNew ¶
func (el Ciphertext) CopyNew() *ckksElement
CopyNew creates a new element which is a copy of the target element.
func (Ciphertext) CopyParams ¶
func (el Ciphertext) CopyParams(ckkselement *ckksElement)
CopyParams copies the input element parameters on the target element
func (Ciphertext) CurrentModulus ¶
func (Ciphertext) InvNTT ¶
func (el Ciphertext) InvNTT(ckkscontext *CkksContext, c *ckksElement) error
InvNTT puts the target element outside of the NTT domain, and sets its isNTT flag to false. If it is not in the NTT domain, does nothing.
func (*Ciphertext) MarshalBinary ¶
func (ciphertext *Ciphertext) MarshalBinary() ([]byte, error)
MarshalBinary encodes a ciphertext on a byte slice. The total size in byte is 4 + 2 * 8 * N * (level + 1).
func (Ciphertext) NTT ¶
func (el Ciphertext) NTT(ckkscontext *CkksContext, c *ckksElement) error
NTT puts the target element in the NTT domain and sets its isNTT flag to true. If it is already in the NTT domain, does nothing.
func (Ciphertext) Resize ¶
func (el Ciphertext) Resize(ckkscontext *CkksContext, degree uint64)
func (Ciphertext) SetCurrentModulus ¶
func (*Ciphertext) UnMarshalBinary ¶ added in v1.1.0
func (ciphertext *Ciphertext) UnMarshalBinary(data []byte) error
UnMarshalBinary decodes a previously marshaled ciphertext on the target ciphertext. The target ciphertext must be of the appropriate format and size, it can be created with the methode NewCiphertext(uint64, uin64t, uint64).
type CkksContext ¶
type CkksContext struct {
// contains filtered or unexported fields
}
CkksContext is a struct which contains all the elements required to instantiate the CKKS Scheme. This includes the parameters (N, ciphertext modulus, sampling, polynomial contexts and other parameters required for the homomorphic operations).
func NewCkksContext ¶
func NewCkksContext(params *Parameters) (ckkscontext *CkksContext, err error)
NewCkksContext creates a new CkksContext with the given parameters. Returns an error if one of the parameters would not ensure the correctness of the scheme (however it doesn't check for security).
func (*CkksContext) ContextKeys ¶
func (ckkscontext *CkksContext) ContextKeys() *ring.Context
ContextKeys returns the ring context under which the keys are created.
func (*CkksContext) Levels ¶ added in v1.1.0
func (ckkscontext *CkksContext) Levels() uint64
Levels returns the number of levels of the ckkscontext.
func (*CkksContext) LogN ¶ added in v1.1.0
func (ckkscontext *CkksContext) LogN() uint64
LogN returns logN of the ckkscontext.
func (*CkksContext) LogQ ¶ added in v1.1.0
func (ckkscontext *CkksContext) LogQ() uint64
LogQ returns the log_2(prod(modulie)) of the ckkscontext.
func (*CkksContext) Moduli ¶ added in v1.1.0
func (ckkscontext *CkksContext) Moduli() []uint64
Moduli returns the moduli of the ckkscontext.
func (*CkksContext) NewCiphertext ¶
func (ckkscontext *CkksContext) NewCiphertext(degree uint64, level uint64, scale uint64) *Ciphertext
NewCiphertext creates a new ciphertext parameterized by degree, level and scale.
func (*CkksContext) NewCkksElement ¶ added in v1.1.0
func (ckkscontext *CkksContext) NewCkksElement(degree, level, scale uint64) *ckksElement
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 secret-key.
func (*CkksContext) NewEncoder ¶ added in v1.1.0
func (ckkscontext *CkksContext) NewEncoder() (encoder *Encoder)
NewEncoder creates a new Encoder that is used to encode a slice of complex values of size at most N/2 (the number of slots) on a plaintext.
func (*CkksContext) NewEncryptorFromPk ¶ added in v1.1.0
func (ckkscontext *CkksContext) NewEncryptorFromPk(pk *PublicKey) (*Encryptor, error)
NewEncryptorFromPk creates a new Encryptor with the provided public-key. This encryptor can be used to encrypt plaintexts, using the stored key.
func (*CkksContext) NewEncryptorFromSk ¶ added in v1.1.0
func (ckkscontext *CkksContext) NewEncryptorFromSk(sk *SecretKey) (*Encryptor, error)
NewEncryptorFromSk creates a new Encryptor with the provided secret-key. This encryptor can be used to encrypt plaintexts, using the stored key.
func (*CkksContext) NewEvaluator ¶
func (ckkscontext *CkksContext) NewEvaluator() (evaluator *Evaluator)
NewEvaluator creates a new Evaluator, that can be used to do homomorphic operations on the ciphertexts and/or plaintexts. It stores a small pool of polynomials and ciphertexts that will be used for intermediate values.
func (*CkksContext) NewKeyGenerator ¶
func (ckkscontext *CkksContext) NewKeyGenerator() (keygen *KeyGenerator)
NewKeyGenerator creates 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 *Ciphertext)
NewRandoMCiphertext generates a new uniformely distributed ciphertext of degree, level and scale.
func (*CkksContext) Scale ¶ added in v1.1.0
func (ckkscontext *CkksContext) Scale() uint64
Scale returns the default scalt of the ckkscontext.
func (*CkksContext) Sigma ¶ added in v1.1.0
func (ckkscontext *CkksContext) Sigma() float64
Sigma returns the variance used by the target context to sample gaussian polynomials.
func (*CkksContext) Slots ¶
func (ckkscontext *CkksContext) Slots() uint64
Slots returns the number of slots that the scheme can encrypt at the same time.
type Decryptor ¶
type Decryptor struct {
// contains filtered or unexported fields
}
Decryptor is a structure used to decrypt ciphertext. It stores the secret-key.
func (*Decryptor) Decrypt ¶
func (decryptor *Decryptor) Decrypt(ciphertext *Ciphertext, plaintext *Plaintext)
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)
DecryptNew decrypts the ciphertext and returns a newly created plaintext. A Horner methode is used for evaluating the decryption.
type Encoder ¶ added in v1.1.0
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a struct storing the necessary parameters to encode a slice of complex number on a plaintext.
func (*Encoder) DecodeComplex ¶ added in v1.1.0
func (encoder *Encoder) DecodeComplex(plaintext *Plaintext) (res []complex128)
DecodeFloat decodes the plaintext values to a slice of complex128 values of size at most N/2.
func (*Encoder) DecodeFloat ¶ added in v1.1.0
DecodeFloat decodes the plaintext values to a slice of float64 values of size at most N/2.
func (*Encoder) EncodeComplex ¶ added in v1.1.0
func (encoder *Encoder) EncodeComplex(plaintext *Plaintext, coeffs []complex128) (err error)
EncodeFloat takes a slice of complex128 values of size at most N/2 (the number of slots) and encodes it on the receiver plaintext.
type Encryptor ¶
type Encryptor struct {
// contains filtered or unexported fields
}
Encreyptor is a struct used to encrypt plaintext and storing the public-key and/or secret-key.
func (*Encryptor) Encrypt ¶
func (encryptor *Encryptor) Encrypt(plaintext *Plaintext, ciphertext *Ciphertext) (err error)
EncryptFromPk encrypts the input plaintext using the stored public-key, and returns the result on the reciver ciphertext. It will encrypt the plaintext with the stored key, which can be private or public, a private-key encryption puts initial noise.
encrypt with pk : ciphertext = [pk[0]*u + m + e_0, pk[1]*u + e_1] encrypt with sk : ciphertext = [-a*sk + m + e, a]
func (*Encryptor) EncryptNew ¶
func (encryptor *Encryptor) EncryptNew(plaintext *Plaintext) (ciphertext *Ciphertext, err error)
EncryptFromPkNew encrypts the input plaintext using the stored public-key and returns the result on a newly created ciphertext. It will encrypt the plaintext with the stored key, which can be private or public, a private-key encryption puts initial noise.
encrypt with pk : ciphertext = [pk[0]*u + m + e_0, pk[1]*u + e_1] encrypt with sk : ciphertext = [-a*sk + m + e, a]
type EvaluationKey ¶
type EvaluationKey struct {
// contains filtered or unexported fields
}
Evaluationkey is a structure that stores the switching-keys required during the relinearization.
func (*EvaluationKey) MarshalBinary ¶ added in v1.1.0
func (evaluationkey *EvaluationKey) MarshalBinary() (data []byte, err error)
MarshalBinary encodes an evaluation key on a byte slice. The total size depends on each modulus size and the bit decomp. It will approximately be 5 + (level + 1) * ( 1 + 2 * 8 * N * (level + 1) * logQi/bitDecomp).
func (*EvaluationKey) UnMarshalBinary ¶ added in v1.1.0
func (evaluationkey *EvaluationKey) UnMarshalBinary(data []byte) (err error)
UnMarshalBinary decodes a previously marshaled evaluation-key on the target evaluation-key. The target evaluation-key must have the appropriate format and size, it can be created with the methode NewRelinKeyEmpty(uint64, uint64).
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator is a struct holding the necessary elements to operates the homomorphic operations between ciphertext and/or plaintexts. It also holds a small memory pool used to store intermediate computations.
func (*Evaluator) Add ¶
func (evaluator *Evaluator) Add(op0, op1 Operand, ctOut *Ciphertext) (err error)
Add adds op0 to op1 and returns the result on ctOut.
func (*Evaluator) AddConst ¶
func (evaluator *Evaluator) AddConst(ct0 *Ciphertext, constant interface{}, ctOut *Ciphertext) (err error)
AddConstNew adds the input constant (which can be an uint64, int64, float64 or complex128) to ct0 and returns the result on ctOut.
func (*Evaluator) AddConstNew ¶
func (evaluator *Evaluator) AddConstNew(ct0 *Ciphertext, constant interface{}) (ctOut *Ciphertext)
AddConstNew adds the input constant (which can be an uint64, int64, float64 or complex128) to ct0 and returns the result on a new element.
func (*Evaluator) AddNew ¶
func (evaluator *Evaluator) AddNew(op0, op1 Operand) (ctOut *Ciphertext, err error)
Add adds op0 to op1 and returns the result on a newly created element.
func (*Evaluator) AddNoMod ¶
func (evaluator *Evaluator) AddNoMod(op0, op1 Operand, ctOut *Ciphertext) (err error)
AddNoMod adds op0 to op1 and returns the result on ctOut, without modular reduction.
func (*Evaluator) AddNoModNew ¶
func (evaluator *Evaluator) AddNoModNew(op0, op1 Operand) (ctOut *Ciphertext, err error)
Add adds op0 to op1 without modular reduction, and returns the result on a newly created element.
func (*Evaluator) Conjugate ¶
func (evaluator *Evaluator) Conjugate(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
ConjugateNew conjugates c0 (which is equivalement to a row rotation) and returns the result on c1. 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(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
ConjugateNew conjugates ct0 (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(ct0 *Ciphertext, c1 *Ciphertext) (err error)
DivByi multiplies ct0 by the imaginary number 1/i = -i, and returns the result on c1. Does not change the scale.
func (*Evaluator) DivByiNew ¶
func (evaluator *Evaluator) DivByiNew(ct0 *Ciphertext) (ctOut *Ciphertext, err error)
DivByiNew multiplies ct0 by the imaginary number 1/i = -i, and returns the result on a newly created element. Does not change the scale.
func (*Evaluator) DropLevel ¶
DropLevel reduces the level of ct0 by levels and returns the result on ct0. No rescaling is applied during this procedure.
func (*Evaluator) DropLevelNew ¶
func (evaluator *Evaluator) DropLevelNew(ct0 *ckksElement, levels uint64) (ctOut *ckksElement, err error)
DropLevel reduces the level of ct0 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) levels.
func (*Evaluator) ExtractImag ¶
func (evaluator *Evaluator) ExtractImag(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
ExtractImag sets the real part of ct0 to the imaginary part of ct0 and sets the imaginary part of ct0 to zero, and returns the result on ctOut. ex. f(a + b*i) = b. Requires a rotationkey for which the conjugate key has been generated. Scale is increased by one.
func (*Evaluator) ExtractImagNew ¶
func (evaluator *Evaluator) ExtractImagNew(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
ExtractImagNew sets the real part of ct0 to the imaginary part of ct0 and sets the imaginary part of ct0 to zero, and returns the result on a new element. ex. f(a + b*i) = b. 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/ct0 and returns the result on a new element, iterating for n steps and consuming n levels. The algorithm requires the encrypted values 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(ct0 *ckksElement, pow2 uint64, ctOut *ckksElement) (err error)
MutByPow2New multiplies ct0 by 2^pow2 and returns the result on ctOut.
func (*Evaluator) MulByPow2New ¶
func (evaluator *Evaluator) MulByPow2New(ct0 *Ciphertext, pow2 uint64) (ctOut *Ciphertext, err error)
MutByPow2New multiplies the ct0 by 2^pow2 and returns the result on a newly created element.
func (*Evaluator) MulRelin ¶
func (evaluator *Evaluator) MulRelin(op0, op1 Operand, evakey *EvaluationKey, ctOut *Ciphertext) error
MulRelinNew multiplies ct0 by ct1 and returns the result on ctOut. 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) MulRelinNew ¶
func (evaluator *Evaluator) MulRelinNew(op0, op1 Operand, evakey *EvaluationKey) (ctOut *Ciphertext, err error)
MulRelinNew multiplies ct0 by ct1 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(ct0 *Ciphertext, constant interface{}, ctOut *Ciphertext) (err error)
MultByConstAndAdd multiplies ct0 by the input constant, and adds it to the receiver element (does not modify the input element), ex. ctOut(x) = ctOut(x) + ct0(x) * (a+bi). This functions removes the need of storing the 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(ct0 *Ciphertext, ctOut *Ciphertext) (err error)
MultByiNew multiplies ct0 by the imaginary number i, and returns the result on c1. Does not change the scale.
func (*Evaluator) MultByiNew ¶
func (evaluator *Evaluator) MultByiNew(ct0 *Ciphertext) (ctOut *Ciphertext, err error)
MultByiNew multiplies ct0 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(ct0 *Ciphertext, constant interface{}, ctOut *Ciphertext) (err error)
MultConstNew multiplies ct0 by the input constant and returns the result on ctOut. 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(ct0 *Ciphertext, constant interface{}) (ctOut *Ciphertext, err error)
MultConstNew multiplies ct0 by the input 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(ct0 *Ciphertext, ctOut *Ciphertext) (err error)
Neg negates the ct0 and returns the result on ctOut.
func (*Evaluator) NegNew ¶
func (evaluator *Evaluator) NegNew(ct0 *Ciphertext) (ctOut *Ciphertext)
Neg negates ct0 and returns the result on a newly created element.
func (*Evaluator) Power ¶
func (evaluator *Evaluator) Power(ct0 *Ciphertext, degree uint64, evakey *EvaluationKey, res *Ciphertext) (err error)
Power compute ct0^degree, consuming log(degree) levels, and returns the result on res. Providing an evaluation key is necessary when degree > 2.
func (*Evaluator) PowerNew ¶
func (evaluator *Evaluator) PowerNew(op *Ciphertext, degree uint64, evakey *EvaluationKey) (opOut *Ciphertext)
Power compute ct0^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(el0 *Ciphertext, logPow2 uint64, evakey *EvaluationKey, elOut *Ciphertext) (err error)
PowerOf2 compute ct0^(2^logPow2), consuming logPow2 levels, and returns the result on ct1. Providing an evaluation key is necessary when logPow2 > 1.
func (*Evaluator) Reduce ¶
func (evaluator *Evaluator) Reduce(ct0 *Ciphertext, ctOut *Ciphertext) error
Reduce applies a modular reduction ct0 and returns the result on ctOut. To be used in conjonction with function not applying modular reduction.
func (*Evaluator) ReduceNew ¶
func (evaluator *Evaluator) ReduceNew(ct0 *Ciphertext) (ctOut *Ciphertext)
Reduce applies a modular reduction ct0 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(ct0 *Ciphertext, evakey *EvaluationKey, ctOut *Ciphertext) (err error)
RelinearizeNew applies the relinearization procedure on ct0 and returns the result on ctOut. Requires the input ciphertext to be of degree two.
func (*Evaluator) RelinearizeNew ¶
func (evaluator *Evaluator) RelinearizeNew(ct0 *Ciphertext, evakey *EvaluationKey) (ctOut *Ciphertext, err error)
RelinearizeNew applies the relinearization procedure on ct0 and returns the result on a newly created ciphertext. Requires the input ciphertext to be of degree two.
func (*Evaluator) RemoveImag ¶
func (evaluator *Evaluator) RemoveImag(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
RemoveImag sets the imaginary part of ct0 to zero and returns the result on ctOut, ex. f(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(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
RemoveImagNew sets the imaginary part of ct0 to zero and returns the result on a newly created element, ex. f(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(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
RemoveReal sets the real part of ct0 to zero and returns the result on ctOut, ex. f(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(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
RemoveRealNew sets the real part of ct0 to zero and returns the result on a newly created element, ex. f(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(ct0, c1 *Ciphertext) (err error)
RescaleNew divides ct0 by the last modulus in the modulus chain, repeats this procedure (each time consuming a level) until the scale reaches the original scale or would go below it, and returns the result on c1. Since all the moduli 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(ct0 *Ciphertext) (ctOut *Ciphertext, err error)
RescaleNew divides ct0 by the last modulus in the modulus chain, repeats this procedure (each time consuming a level) until the scale reaches the original scale or would go below it, and returns the result on a newly created element. Since all the moduli 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(ct0 *Ciphertext, k uint64, evakey *RotationKey, ctOut *Ciphertext) (err error)
RotateColumns rotates the columns of ct0 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(ct0 *Ciphertext, k uint64, evakey *RotationKey) (ctOut *Ciphertext, err error)
RotateColumnsNew rotates the columns of ct0 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(ct0 *Ciphertext, scale uint64, ctOut *Ciphertext) (err error)
ScaleUpNew multiplies ct0 by 2^scale and sets its scale to its previous scale plus 2^n. Returns the result on ctOut.
func (*Evaluator) ScaleUpNew ¶
func (evaluator *Evaluator) ScaleUpNew(ct0 *Ciphertext, scale uint64) (ctOut *Ciphertext, err error)
ScaleUpNew multiplies ct0 by 2^scale and sets its scale to its previous scale plus 2^n. Returns the result on a newly created element.
func (*Evaluator) Sub ¶
func (evaluator *Evaluator) Sub(op0, op1 Operand, ctOut *Ciphertext) (err error)
Sub subtracts op0 to op1 and returns the result on ctOut.
func (*Evaluator) SubNew ¶
func (evaluator *Evaluator) SubNew(op0, op1 Operand) (ctOut *Ciphertext, err error)
SubNew subtracts op0 to op1 and returns the result on a newly created element.
func (*Evaluator) SubNoMod ¶
func (evaluator *Evaluator) SubNoMod(op0, op1 Operand, ctOut *Ciphertext) (err error)
SubNoMod subtracts op0 to op1 and returns the result on ctOut, without modular reduction.
func (*Evaluator) SubNoModNew ¶
func (evaluator *Evaluator) SubNoModNew(op0, op1 Operand) (ctOut *Ciphertext, err error)
SubNoModNew subtracts op0 to op1 without modular reduction, and returns the result on a newly created element.
func (*Evaluator) SwapRealImag ¶
func (evaluator *Evaluator) SwapRealImag(ct0 *Ciphertext, evakey *RotationKey, ctOut *Ciphertext) (err error)
SwapRealImagNew swaps the real and imaginary parts of ct0 and returns the result on ctOut, ex. f(a + b*i) = b + a * i. Requires a rotationkey for which the conjugate key has been generated.
func (*Evaluator) SwapRealImagNew ¶
func (evaluator *Evaluator) SwapRealImagNew(ct0 *Ciphertext, evakey *RotationKey) (ctOut *Ciphertext, err error)
SwapRealImagNew swaps the real and imaginary parts of ct0 and returns the result on a newly created element, ex. f(a + b*i) = b + a * i. Requires a rotationkey for which the conjugate key has been generated.
func (*Evaluator) SwitchKeys ¶
func (evaluator *Evaluator) SwitchKeys(ct0 *Ciphertext, switchingKey *SwitchingKey, ctOut *Ciphertext) error
Switchkeys re-encrypts ct0 under a different key and returns the result on ctOut. Requires 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(ct0 *Ciphertext, switchingKey *SwitchingKey) (ctOut *Ciphertext, err error)
Switchkeys re-encrypts ct0 under a different key and returns the result on a newly created element. Requires 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
}
Keygenerator is a structure that stores the elements required to create new keys, as well as a small memory pool for intermediate values.
func (*KeyGenerator) NewKeyPair ¶
func (keygen *KeyGenerator) NewKeyPair() (sk *SecretKey, pk *PublicKey)
NewKeyPair generates a new secretkey with distribution [1/3, 1/3, 1/3] 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) NewPublicKeyEmpty ¶ added in v1.1.0
func (keygen *KeyGenerator) NewPublicKeyEmpty() (pk *PublicKey)
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) NewRelinKeyEmpty ¶ added in v1.1.0
func (keygen *KeyGenerator) NewRelinKeyEmpty(bitDecomp uint64) (evakey *EvaluationKey)
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) NewRotationKeysEmpty ¶ added in v1.1.0
func (keygen *KeyGenerator) NewRotationKeysEmpty() (rotKey *RotationKey)
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() (sk *SecretKey)
NewSecretKey generates a new secret key with the distribution [1/3, 1/3, 1/3].
func (*KeyGenerator) NewSecretKeyEmpty ¶ added in v1.1.0
func (keygen *KeyGenerator) NewSecretKeyEmpty() *SecretKey
func (*KeyGenerator) NewSecretKeyWithDistrib ¶ added in v1.1.0
func (keygen *KeyGenerator) NewSecretKeyWithDistrib(p float64) (sk *SecretKey, err error)
NewSecretKey generates a new secret key with the distribution [(p-1)/2, p, (p-1)/2].
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) NewSwitchingKeyEmpty ¶ added in v1.1.0
func (keygen *KeyGenerator) NewSwitchingKeyEmpty(bitDecomp uint64) (evakey *SwitchingKey)
func (*KeyGenerator) SetRelinKeys ¶
func (keygen *KeyGenerator) SetRelinKeys(rlk [][][2]*ring.Poly, bitDecomp uint64) (*EvaluationKey, error)
type Parameters ¶ added in v1.1.0
Parameters is a struct storing the necessary parameters to instantiate a new ckkscontext.
logN : the ring degree such that N = 2^logN
modulichain : a list of moduli in bit size, such that prod(moduli) <= logQ, where logQ is the maximum bit size of the product of all the moduli for a given security parameter. This moduli chain allows to customize the value by which the ciphertexts will be rescaled allong the homomorphic computations, and can enhance performances for optimized applications.
logScale : the default scale of the scheme such that scale = 2^logScale
sigma : the variance used by the ckkscontext to sample gaussian polynomials.
func (*Parameters) Equals ¶ added in v1.1.0
func (p *Parameters) Equals(other *Parameters) bool
Equals compares two sets of parameters for equality
func (*Parameters) MarshalBinary ¶ added in v1.1.0
func (p *Parameters) MarshalBinary() ([]byte, error)
MarshalBinary returns a []byte representation of the parameter set
func (*Parameters) UnMarshalBinary ¶ added in v1.1.0
func (p *Parameters) UnMarshalBinary(data []byte) error
UnMarshalBinary decodes a []byte into a parameter set struct
type Plaintext ¶
type Plaintext struct {
// contains filtered or unexported fields
}
Plaintext is BigPoly of degree 0.
func (Plaintext) Ciphertext ¶ added in v1.1.0
func (el Plaintext) Ciphertext() *Ciphertext
func (Plaintext) Copy ¶
func (el Plaintext) Copy(ctxCopy *ckksElement) (err error)
Copy copies the input element and its parameters on the target element.
func (Plaintext) CopyNew ¶
func (el Plaintext) CopyNew() *ckksElement
CopyNew creates a new element which is a copy of the target element.
func (Plaintext) CopyParams ¶
func (el Plaintext) CopyParams(ckkselement *ckksElement)
CopyParams copies the input element parameters on the target element
func (Plaintext) CurrentModulus ¶
func (Plaintext) InvNTT ¶
func (el Plaintext) InvNTT(ckkscontext *CkksContext, c *ckksElement) error
InvNTT puts the target element outside of the NTT domain, and sets its isNTT flag to false. If it is not in the NTT domain, does nothing.
func (Plaintext) NTT ¶
func (el Plaintext) NTT(ckkscontext *CkksContext, c *ckksElement) error
NTT puts the target element in the NTT domain and sets its isNTT flag to true. If it is already in the NTT domain, does nothing.
func (Plaintext) Resize ¶
func (el Plaintext) Resize(ckkscontext *CkksContext, degree uint64)
func (Plaintext) SetCurrentModulus ¶
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
Publickey is a structure that stores the public-key
func (*PublicKey) MarshalBinary ¶ added in v1.1.0
MarshalBinary encodes a public-key on a byte slice. The total size is 2 + 16 * N * (level + 1).
func (*PublicKey) UnMarshalBinary ¶ added in v1.1.0
UnMarshalBinary decodes a previously marshaled public-key on the target public-key. The target public-key must have the appropriate format and size, it can be created with the methode NewPublicKeyEmpty().
type RotationKey ¶
type RotationKey struct {
// contains filtered or unexported fields
}
Rotationkeys is a structure that stores the switching-keys required during the homomorphic rotations.
func (*RotationKey) MarshalBinary ¶ added in v1.1.0
func (rotationkey *RotationKey) MarshalBinary() (data []byte, err error)
MarshalBinary encodes a rotationkeys structure on a byte slice. The total size in byte is approximately 5 + 4*(nb left rot + num right rot) + (nb left rot + num right rot + 1 (if rotate row)) * (level + 1) * ( 1 + 2 * 8 * N * (level + 1) * logQi/bitDecomp).
func (*RotationKey) UnMarshalBinary ¶ added in v1.1.0
func (rotationkey *RotationKey) UnMarshalBinary(data []byte) (err error)
UnMarshalBinary decodes a previously marshaled rotation-keys on the target rotation-keys. In contrary to all the other structures, the unmarshaling for rotationkeys only need an empty receiver, as it is not possible to create receiver of the correct format and size without knowing all the content of the marshaled rotationkeys. The memory will be allocated on the fly.
type SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
Secretkey is a structure that stores the secret-key
func (*SecretKey) MarshalBinary ¶ added in v1.1.0
MarshalBinary encodes a secret-key on a byte slice. The total size in byte is 1 + N/4.
func (*SecretKey) UnMarshalBinary ¶ added in v1.1.0
UnMarshalBinary decode a previously marshaled secret-key on the target secret-key. The target secret-key must be of the appropriate format, it can be created with the methode NewSecretKeyEmpty().
type SwitchingKey ¶
type SwitchingKey struct {
// contains filtered or unexported fields
}
Switchingkey is a structure that stores the switching-keys required during the key-switching.
func (*SwitchingKey) MarshalBinary ¶ added in v1.1.0
func (switchingkey *SwitchingKey) MarshalBinary() (data []byte, err error)
MarshalBinary encodes an switching-key on a byte slice. The total size in byte will be approximately 5 + (level + 1) * ( 1 + 2 * 8 * N * (level + 1) * logQi/bitDecomp).
func (*SwitchingKey) UnMarshalBinary ¶ added in v1.1.0
func (switchingkey *SwitchingKey) UnMarshalBinary(data []byte) (err error)
UnMarshalBinary decode a previously marshaled switching-key on the target switching-key. The target switching-key must have the appropriate format and size, it can be created with the methode NewSwitchingKeyEmpty(uint64).