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 GenModuli(params *Parameters) (Q []uint64, P []uint64)
- func GenSwitchkeysRescalingParams(Q, P []uint64) (params []uint64)
- type ChebyshevInterpolation
- 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) Degree() uint64
- func (el Ciphertext) DivScale(scale float64)
- func (el Ciphertext) Element() *ckksElement
- func (ciphertext *Ciphertext) GetDataLen(WithMetaData bool) (dataLen uint64)
- func (el Ciphertext) InvNTT(context *ring.Context, c *ckksElement) error
- func (el Ciphertext) IsNTT() bool
- func (el Ciphertext) Level() uint64
- func (ciphertext *Ciphertext) MarshalBinary() (data []byte, err error)
- func (el Ciphertext) MulScale(scale float64)
- func (el Ciphertext) NTT(context *ring.Context, c *ckksElement) error
- func (el Ciphertext) Plaintext() *Plaintext
- func (el Ciphertext) Resize(params *Parameters, degree uint64)
- func (el Ciphertext) Scale() float64
- func (el Ciphertext) SetIsNTT(value bool)
- func (el Ciphertext) SetScale(scale float64)
- func (el Ciphertext) SetValue(value []*ring.Poly)
- func (ciphertext *Ciphertext) UnmarshalBinary(data []byte) (err error)
- func (el Ciphertext) Value() []*ring.Poly
- type Context
- type Decryptor
- type Encoder
- type Encryptor
- type EvaluationKey
- func (evk *EvaluationKey) Get() *SwitchingKey
- func (evaluationkey *EvaluationKey) GetDataLen(WithMetaData bool) (dataLen uint64)
- func (evaluationkey *EvaluationKey) MarshalBinary() (data []byte, err error)
- func (evk *EvaluationKey) Set(rlk [][2]*ring.Poly)
- func (evaluationkey *EvaluationKey) UnmarshalBinary(data []byte) (err error)
- type Evaluator
- type KeyGenerator
- type LogModuli
- type Moduli
- type Operand
- type Parameters
- func (p *Parameters) Alpha() uint64
- func (p *Parameters) Beta() uint64
- func (p *Parameters) Copy() (paramsCopy *Parameters)
- func (p *Parameters) Equals(other *Parameters) (res bool)
- func (p *Parameters) GenFromLogModuli()
- func (p *Parameters) GenFromModuli()
- func (p *Parameters) IsValid() bool
- func (p *Parameters) LogQP() uint64
- func (p *Parameters) MarshalBinary() ([]byte, error)
- func (p *Parameters) MaxLevel() uint64
- func (p *Parameters) NewPolyP() *ring.Poly
- func (p *Parameters) NewPolyQ() *ring.Poly
- func (p *Parameters) NewPolyQP() *ring.Poly
- func (p *Parameters) UnmarshalBinary(data []byte) error
- 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) Degree() uint64
- func (el Plaintext) DivScale(scale float64)
- func (el Plaintext) Element() *ckksElement
- func (el Plaintext) InvNTT(context *ring.Context, c *ckksElement) error
- func (el Plaintext) IsNTT() bool
- func (el Plaintext) Level() uint64
- func (el Plaintext) MulScale(scale float64)
- func (el Plaintext) NTT(context *ring.Context, c *ckksElement) error
- func (el Plaintext) Plaintext() *Plaintext
- func (el Plaintext) Resize(params *Parameters, degree uint64)
- func (el Plaintext) Scale() float64
- func (el Plaintext) SetIsNTT(value bool)
- func (el Plaintext) SetScale(scale float64)
- func (el Plaintext) SetValue(value []*ring.Poly)
- func (el Plaintext) Value() []*ring.Poly
- type PublicKey
- type Rotation
- type RotationKeys
- func (rotationkey *RotationKeys) GetDataLen(WithMetaData bool) (dataLen uint64)
- func (rotationkey *RotationKeys) MarshalBinary() (data []byte, err error)
- func (rotKey *RotationKeys) SetRotKey(params *Parameters, evakey [][2]*ring.Poly, rotType Rotation, k uint64)
- func (rotationkey *RotationKeys) UnmarshalBinary(data []byte) (err error)
- type SecretKey
- type SwitchingKey
Constants ¶
const ( RotationRight = iota + 1 RotationLeft Conjugate )
Constants for rotation types
const ( PN12QP109 = iota PN13QP218 PN14QP438 PN15QP880 PN16QP1761 )
const GaloisGen uint64 = 5
GaloisGen is an integer of order N/2 modulo M and that spans Z_M with the integer -1. The j-th ring automorphism takes the root zeta to zeta^(5j). Any other integer or order N/2 modulo M and congruent with 1 modulo 4 could be used instead.
const MaxLogN = 16
MaxLogN is the log2 of the largest supported polynomial modulus degree.
const MaxModuliCount = 34
MaxModuliCount is the largest supported number of moduli in the RNS representation.
const MaxModuliSize = 60
MaxModuliSize is the largest bit-length supported for the moduli in the RNS representation.
Variables ¶
var DefaultParams = []*Parameters{ {LogN: 12, LogSlots: 11, LogModuli: LogModuli{ LogQi: []uint64{37, 32}, LogPi: []uint64{38}, }, Scale: 1 << 32, Sigma: 3.2}, {LogN: 13, LogSlots: 12, LogModuli: LogModuli{ LogQi: []uint64{33, 30, 30, 30, 30, 30}, LogPi: []uint64{35}, }, Scale: 1 << 30, Sigma: 3.2}, {LogN: 14, LogSlots: 13, LogModuli: LogModuli{ LogQi: []uint64{45, 34, 34, 34, 34, 34, 34, 34, 34, 34}, LogPi: []uint64{43, 43}, }, Scale: 1 << 34, Sigma: 3.2}, {LogN: 15, LogSlots: 14, LogModuli: LogModuli{ LogQi: []uint64{50, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}, LogPi: []uint64{50, 50, 50}, }, Scale: 1 << 40, Sigma: 3.2}, {LogN: 16, LogSlots: 15, LogModuli: LogModuli{ LogQi: []uint64{55, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45}, LogPi: []uint64{55, 55, 55, 55}, }, Scale: 1 << 45, Sigma: 3.2}, }
DefaultParams is a set of default CKKS parameters ensuring 128 bit security.
Functions ¶
func GenModuli ¶
func GenModuli(params *Parameters) (Q []uint64, P []uint64)
GenModuli generates the appropriate primes from the parameters using generateCKKSPrimes, such that all the primes are different.
func GenSwitchkeysRescalingParams ¶
GenSwitchkeysRescalingParams generates the parameters for rescaling the switching keys
Types ¶
type ChebyshevInterpolation ¶
type ChebyshevInterpolation struct {
// contains filtered or unexported fields
}
ChebyshevInterpolation is a struct storing the coefficients, degree and range of a Chebyshev interpolation polynomial.
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 range [-a, b] of degree degree. To be used in conjunction with the function EvaluateCheby.
type Ciphertext ¶
type Ciphertext struct {
// contains filtered or unexported fields
}
Ciphertext is *ring.Poly array representing a polynomial of degree > 0 with coefficients in R_Q.
func NewCiphertext ¶
func NewCiphertext(params *Parameters, degree uint64, level uint64, scale float64) (ciphertext *Ciphertext)
NewCiphertext creates a new Ciphertext parameterized by degree, level and scale.
func NewCiphertextRandom ¶
func NewCiphertextRandom(params *Parameters, degree, level uint64, scale float64) (ciphertext *Ciphertext)
NewCiphertextRandom generates a new uniformly distributed Ciphertext of degree, level and scale.
func (Ciphertext) Ciphertext ¶
func (el Ciphertext) Ciphertext() *Ciphertext
Ciphertext sets the target element type to 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 as 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) Degree ¶
func (el Ciphertext) Degree() uint64
Degree returns the degree of the target element.
func (Ciphertext) DivScale ¶
func (el Ciphertext) DivScale(scale float64)
DivScale divides the scale of the target element by the input scale.
func (Ciphertext) Element ¶
func (el Ciphertext) Element() *ckksElement
Element sets the target element type to Element.
func (*Ciphertext) GetDataLen ¶
func (ciphertext *Ciphertext) GetDataLen(WithMetaData bool) (dataLen uint64)
GetDataLen returns the length in bytes of the target Ciphertext.
func (Ciphertext) InvNTT ¶
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, it does nothing.
func (Ciphertext) IsNTT ¶
func (el Ciphertext) IsNTT() bool
IsNTT returns the value of the NTT flag of the target element.
func (Ciphertext) Level ¶
func (el Ciphertext) Level() uint64
Level returns the level of the target element.
func (*Ciphertext) MarshalBinary ¶
func (ciphertext *Ciphertext) MarshalBinary() (data []byte, err error)
MarshalBinary encodes a Ciphertext on a byte slice. The total size in byte is 4 + 8* N * numberModuliQ * (degree + 1).
func (Ciphertext) MulScale ¶
func (el Ciphertext) MulScale(scale float64)
MulScale multiplies the scale of the target element with the input scale.
func (Ciphertext) NTT ¶
NTT puts the target element in the NTT domain and sets its isNTT flag to true. If it is already in the NTT domain, it does nothing.
func (Ciphertext) Plaintext ¶
func (el Ciphertext) Plaintext() *Plaintext
Plaintext sets the target element type to Plaintext.
func (Ciphertext) Resize ¶
func (el Ciphertext) Resize(params *Parameters, degree uint64)
Resize resizes the degree of the target element.
func (Ciphertext) Scale ¶
func (el Ciphertext) Scale() float64
Scale returns the scale of the target element.
func (Ciphertext) SetIsNTT ¶
func (el Ciphertext) SetIsNTT(value bool)
SetIsNTT sets the value of the NTT flag of the target element with the input value.
func (Ciphertext) SetScale ¶
func (el Ciphertext) SetScale(scale float64)
SetScale sets the scale of the the target element to the input scale.
func (Ciphertext) SetValue ¶
SetValue sets the input slice of polynomials as the value of the target element.
func (*Ciphertext) UnmarshalBinary ¶
func (ciphertext *Ciphertext) UnmarshalBinary(data []byte) (err 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 method NewCiphertext(uint64).
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is a struct that contains all the elements required to instantiate the CKKS Scheme. This includes the parameters (polynomial degree, ciphertext modulus, Gaussian sampler, polynomial contexts and other parameters required for the homomorphic operations).
type Decryptor ¶
type Decryptor interface { // DecryptNew decrypts the ciphertext and returns a newly created // plaintext. A Horner method is used for evaluating the decryption. DecryptNew(ciphertext *Ciphertext) (plaintext *Plaintext) // Decrypt decrypts the ciphertext and returns the result on the provided // receiver plaintext. A Horner method is used for evaluating the // decryption. Decrypt(ciphertext *Ciphertext, plaintext *Plaintext) }
Decryptor is an interface for decrypting Ciphertexts. A Decryptor stores the secret-key.
func NewDecryptor ¶
func NewDecryptor(params *Parameters, sk *SecretKey) Decryptor
NewDecryptor instantiates a new Decryptor that will be able to decrypt ciphertexts encrypted under the provided secret-key.
type Encoder ¶
type Encoder interface { Encode(plaintext *Plaintext, values []complex128, slots uint64) EncodeNew(values []complex128, slots uint64) (plaintext *Plaintext) Decode(plaintext *Plaintext, slots uint64) (res []complex128) }
Encoder is an interface implenting the encoding algorithms.
func NewEncoder ¶
func NewEncoder(params *Parameters) 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.
type Encryptor ¶
type Encryptor interface { // EncryptNew encrypts the input plaintext using the stored key and returns // the result on a newly created ciphertext. EncryptNew(plaintext *Plaintext) *Ciphertext // Encrypt encrypts the input plaintext using the stored key, and returns // the result on the reciver ciphertext. Encrypt(plaintext *Plaintext, ciphertext *Ciphertext) }
Encryptor in an interface for encryptors
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 NewEncryptorFromPk ¶
func NewEncryptorFromPk(params *Parameters, pk *PublicKey) Encryptor
NewEncryptorFromPk creates a new Encryptor with the provided public-key. This Encryptor can be used to encrypt Plaintexts, using the stored key.
func NewEncryptorFromSk ¶
func NewEncryptorFromSk(params *Parameters, sk *SecretKey) Encryptor
NewEncryptorFromSk creates a new Encryptor with the provided secret-key. This Encryptor can be used to encrypt Plaintexts, using the stored key.
type EvaluationKey ¶
type EvaluationKey struct {
// contains filtered or unexported fields
}
EvaluationKey is a structure that stores the switching-keys required during the relinearization.
func NewRelinKey ¶
func NewRelinKey(params *Parameters) (evakey *EvaluationKey)
NewRelinKey returns a new EvaluationKey with zero values.
func (*EvaluationKey) Get ¶
func (evk *EvaluationKey) Get() *SwitchingKey
Get returns the slice of switching keys of the evaluation-key.
func (*EvaluationKey) GetDataLen ¶
func (evaluationkey *EvaluationKey) GetDataLen(WithMetaData bool) (dataLen uint64)
GetDataLen returns the length in bytes of the target EvaluationKey.
func (*EvaluationKey) MarshalBinary ¶
func (evaluationkey *EvaluationKey) MarshalBinary() (data []byte, err error)
MarshalBinary encodes an evaluation key in a byte slice.
func (*EvaluationKey) Set ¶
func (evk *EvaluationKey) Set(rlk [][2]*ring.Poly)
Set sets the target Evaluation key with the input polynomials.
func (*EvaluationKey) UnmarshalBinary ¶
func (evaluationkey *EvaluationKey) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary decodes a previously marshaled evaluation-key in the target evaluation-key.
type Evaluator ¶
type Evaluator interface { Add(op0, op1 Operand, ctOut *Ciphertext) AddNoMod(op0, op1 Operand, ctOut *Ciphertext) AddNew(op0, op1 Operand) (ctOut *Ciphertext) AddNoModNew(op0, op1 Operand) (ctOut *Ciphertext) Sub(op0, op1 Operand, ctOut *Ciphertext) SubNoMod(op0, op1 Operand, ctOut *Ciphertext) SubNew(op0, op1 Operand) (ctOut *Ciphertext) SubNoModNew(op0, op1 Operand) (ctOut *Ciphertext) Neg(ct0 *Ciphertext, ctOut *Ciphertext) NegNew(ct0 *Ciphertext) (ctOut *Ciphertext) AddConstNew(ct0 *Ciphertext, constant interface{}) (ctOut *Ciphertext) AddConst(ct0 *Ciphertext, constant interface{}, ctOut *Ciphertext) MultByConstAndAdd(ct0 *Ciphertext, constant interface{}, ctOut *Ciphertext) MultByConstNew(ct0 *Ciphertext, constant interface{}) (ctOut *Ciphertext) MultByConst(ct0 *Ciphertext, constant interface{}, ctOut *Ciphertext) MultByiNew(ct0 *Ciphertext) (ctOut *Ciphertext) MultByi(ct0 *Ciphertext, ct1 *Ciphertext) DivByiNew(ct0 *Ciphertext) (ctOut *Ciphertext) DivByi(ct0 *Ciphertext, ct1 *Ciphertext) ScaleUpNew(ct0 *Ciphertext, scale float64) (ctOut *Ciphertext) ScaleUp(ct0 *Ciphertext, scale float64, ctOut *Ciphertext) MulByPow2New(ct0 *Ciphertext, pow2 uint64) (ctOut *Ciphertext) MulByPow2(ct0 *ckksElement, pow2 uint64, ctOut *ckksElement) ReduceNew(ct0 *Ciphertext) (ctOut *Ciphertext) Reduce(ct0 *Ciphertext, ctOut *Ciphertext) error DropLevelNew(ct0 *Ciphertext, levels uint64) (ctOut *Ciphertext) DropLevel(ct0 *Ciphertext, levels uint64) (err error) Rescale(ct0 *Ciphertext, threshold float64, c1 *Ciphertext) (err error) RescaleMany(ct0 *Ciphertext, nbRescales uint64, c1 *Ciphertext) (err error) MulRelinNew(op0, op1 Operand, evakey *EvaluationKey) (ctOut *Ciphertext) MulRelin(op0, op1 Operand, evakey *EvaluationKey, ctOut *Ciphertext) RelinearizeNew(ct0 *Ciphertext, evakey *EvaluationKey) (ctOut *Ciphertext) Relinearize(ct0 *Ciphertext, evakey *EvaluationKey, ctOut *Ciphertext) SwitchKeysNew(ct0 *Ciphertext, switchingKey *SwitchingKey) (ctOut *Ciphertext) SwitchKeys(ct0 *Ciphertext, switchingKey *SwitchingKey, ctOut *Ciphertext) RotateColumnsNew(ct0 *Ciphertext, k uint64, evakey *RotationKeys) (ctOut *Ciphertext) RotateColumns(ct0 *Ciphertext, k uint64, evakey *RotationKeys, ctOut *Ciphertext) RotateHoisted(ctIn *Ciphertext, rotations []uint64, rotkeys *RotationKeys) (cOut map[uint64]*Ciphertext) ConjugateNew(ct0 *Ciphertext, evakey *RotationKeys) (ctOut *Ciphertext) Conjugate(ct0 *Ciphertext, evakey *RotationKeys, ctOut *Ciphertext) PowerOf2(el0 *Ciphertext, logPow2 uint64, evakey *EvaluationKey, elOut *Ciphertext) PowerNew(op *Ciphertext, degree uint64, evakey *EvaluationKey) (opOut *Ciphertext) Power(ct0 *Ciphertext, degree uint64, evakey *EvaluationKey, res *Ciphertext) InverseNew(ct0 *Ciphertext, steps uint64, evakey *EvaluationKey) (res *Ciphertext) EvaluatePolyFast(ct *Ciphertext, coeffs interface{}, evakey *EvaluationKey) (res *Ciphertext) EvaluatePolyEco(ct *Ciphertext, coeffs interface{}, evakey *EvaluationKey) (res *Ciphertext) EvaluateChebyFast(ct *Ciphertext, cheby *ChebyshevInterpolation, evakey *EvaluationKey) (res *Ciphertext) EvaluateChebyEco(ct *Ciphertext, cheby *ChebyshevInterpolation, evakey *EvaluationKey) (res *Ciphertext) }
Evaluator is an interface implementing the methodes to conduct homomorphic operations between ciphertext and/or plaintexts.
func NewEvaluator ¶
func NewEvaluator(params *Parameters) 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.
type KeyGenerator ¶
type KeyGenerator interface { GenSecretKey() (sk *SecretKey) GenSecretKeyWithDistrib(p float64) (sk *SecretKey) GenSecretKeySparse(hw uint64) (sk *SecretKey) GenPublicKey(sk *SecretKey) (pk *PublicKey) GenKeyPair() (sk *SecretKey, pk *PublicKey) GenKeyPairSparse(hw uint64) (sk *SecretKey, pk *PublicKey) GenRelinKey(sk *SecretKey) (evakey *EvaluationKey) GenSwitchingKey(skInput, skOutput *SecretKey) (newevakey *SwitchingKey) GenRotationKeysPow2(skOutput *SecretKey) (rotKey *RotationKeys) GenRot(rotType Rotation, sk *SecretKey, k uint64, rotKey *RotationKeys) }
KeyGenerator is an interface implementing the methods of the KeyGenerator.
func NewKeyGenerator ¶
func NewKeyGenerator(params *Parameters) 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.
type LogModuli ¶
type LogModuli struct { LogQi []uint64 // Ciphertext prime moduli bit-size LogPi []uint64 // Keys additional prime moduli bit-size }
LogModuli stores the bit-length of the NTT primes of the RNS representation.
type Moduli ¶
type Moduli struct { Qi []uint64 // Ciphertext prime moduli Pi []uint64 // Keys additional prime moduli }
Moduli stores the NTT primes of the RNS representation.
type Parameters ¶
type Parameters struct { Moduli LogModuli LogN uint64 // Ring degree (power of 2) LogSlots uint64 Scale float64 Sigma float64 // Gaussian sampling variance // contains filtered or unexported fields }
Parameters represents a given parameter set for the BFV cryptosystem.
func NewParametersFromLogModuli ¶
func NewParametersFromLogModuli(LogN, LogSlots uint64, Scale float64, logModuli LogModuli, Sigma float64) (params *Parameters)
NewParametersFromLogModuli generates a new set or bfv parameters from the input parameters.
func NewParametersFromModuli ¶
func NewParametersFromModuli(LogN, LogSlots uint64, Scale float64, moduli Moduli, Sigma float64) (params *Parameters)
NewParametersFromModuli generates a new set or bfv parameters from the input parameters.
func (*Parameters) Copy ¶
func (p *Parameters) Copy() (paramsCopy *Parameters)
Copy creates a copy of the target parameters.
func (*Parameters) Equals ¶
func (p *Parameters) Equals(other *Parameters) (res bool)
Equals compares two sets of parameters for equality.
func (*Parameters) GenFromLogModuli ¶
func (p *Parameters) GenFromLogModuli()
GenFromLogModuli generates the parameters using the given bit-size for the moduli.
func (*Parameters) GenFromModuli ¶
func (p *Parameters) GenFromModuli()
GenFromModuli generates the parameters using the provided moduli.
func (*Parameters) IsValid ¶
func (p *Parameters) IsValid() bool
IsValid returns a true if the parameters are complete and valid, else false.
func (*Parameters) LogQP ¶
func (p *Parameters) LogQP() uint64
LogQP returns the bitlength of prod(Qi) * prod(Pi)
func (*Parameters) MarshalBinary ¶
func (p *Parameters) MarshalBinary() ([]byte, error)
MarshalBinary returns a []byte representation of the parameter set.
func (*Parameters) NewPolyP ¶
func (p *Parameters) NewPolyP() *ring.Poly
NewPolyP returns a new empty polynomial of degree 2^LogN in basis Pi.
func (*Parameters) NewPolyQ ¶
func (p *Parameters) NewPolyQ() *ring.Poly
NewPolyQ returns a new empty polynomial of degree 2^LogN in basis Qi.
func (*Parameters) NewPolyQP ¶
func (p *Parameters) NewPolyQP() *ring.Poly
NewPolyQP returns a new empty polynomial of degree 2^LogN in basis Qi + Pi.
func (*Parameters) UnmarshalBinary ¶
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 is a ckksElement with only one Poly.
func NewPlaintext ¶
func NewPlaintext(params *Parameters, level uint64, scale float64) *Plaintext
NewPlaintext creates a new Plaintext of level level and scale scale.
func (Plaintext) Ciphertext ¶
func (el Plaintext) Ciphertext() *Ciphertext
Ciphertext sets the target element type to 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 as 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) Degree ¶
func (el Plaintext) Degree() uint64
Degree returns the degree of the target element.
func (Plaintext) DivScale ¶
func (el Plaintext) DivScale(scale float64)
DivScale divides the scale of the target element by the input scale.
func (Plaintext) Element ¶
func (el Plaintext) Element() *ckksElement
Element sets the target element type to Element.
func (Plaintext) InvNTT ¶
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, it does nothing.
func (Plaintext) IsNTT ¶
func (el Plaintext) IsNTT() bool
IsNTT returns the value of the NTT flag of the target element.
func (Plaintext) Level ¶
func (el Plaintext) Level() uint64
Level returns the level of the target element.
func (Plaintext) MulScale ¶
func (el Plaintext) MulScale(scale float64)
MulScale multiplies the scale of the target element with the input scale.
func (Plaintext) NTT ¶
NTT puts the target element in the NTT domain and sets its isNTT flag to true. If it is already in the NTT domain, it does nothing.
func (Plaintext) Plaintext ¶
func (el Plaintext) Plaintext() *Plaintext
Plaintext sets the target element type to Plaintext.
func (Plaintext) Resize ¶
func (el Plaintext) Resize(params *Parameters, degree uint64)
Resize resizes the degree of the target element.
func (Plaintext) Scale ¶
func (el Plaintext) Scale() float64
Scale returns the scale of the target element.
func (Plaintext) SetIsNTT ¶
func (el Plaintext) SetIsNTT(value bool)
SetIsNTT sets the value of the NTT flag of the target element with the input value.
func (Plaintext) SetScale ¶
func (el Plaintext) SetScale(scale float64)
SetScale sets the scale of the the target element to the input scale.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is a structure that stores the PublicKey
func NewPublicKey ¶
func NewPublicKey(params *Parameters) (pk *PublicKey)
NewPublicKey returns a new PublicKey with zero values.
func (*PublicKey) GetDataLen ¶
GetDataLen returns the length in bytes of the target PublicKey.
func (*PublicKey) MarshalBinary ¶
MarshalBinary encodes a PublicKey in a byte slice.
func (*PublicKey) UnmarshalBinary ¶
UnmarshalBinary decodes a previously marshaled PublicKey in the target PublicKey.
type RotationKeys ¶
type RotationKeys struct {
// contains filtered or unexported fields
}
RotationKeys is a structure that stores the switching-keys required during the homomorphic rotations.
func NewRotationKeys ¶
func NewRotationKeys() (rotKey *RotationKeys)
NewRotationKeys generates a new instance of RotationKeys, with the provided rotation to the left, right and conjugation if requested.
func (*RotationKeys) GetDataLen ¶
func (rotationkey *RotationKeys) GetDataLen(WithMetaData bool) (dataLen uint64)
GetDataLen returns the length in bytes of the target RotationKeys.
func (*RotationKeys) MarshalBinary ¶
func (rotationkey *RotationKeys) MarshalBinary() (data []byte, err error)
MarshalBinary encodes a RotationKeys structure in a byte slice.
func (*RotationKeys) SetRotKey ¶
func (rotKey *RotationKeys) SetRotKey(params *Parameters, evakey [][2]*ring.Poly, rotType Rotation, k uint64)
SetRotKey sets the target RotationKeys' SwitchingKey for the specified rotation type and amount with the input polynomials.
func (*RotationKeys) UnmarshalBinary ¶
func (rotationkey *RotationKeys) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary decodes a previously marshaled RotationKeys in the target RotationKeys.
type SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
SecretKey is a structure that stores the SecretKey
func NewSecretKey ¶
func NewSecretKey(params *Parameters) *SecretKey
NewSecretKey generates a new SecretKey with zero values.
func (*SecretKey) GetDataLen ¶
GetDataLen returns the length in bytes of the target SecretKey.
func (*SecretKey) MarshalBinary ¶
MarshalBinary encodes a SecretKey in a byte slice.
func (*SecretKey) UnmarshalBinary ¶
UnmarshalBinary decodes a previously marshaled SecretKey on the target secret-key.
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 NewSwitchingKey ¶
func NewSwitchingKey(params *Parameters) (evakey *SwitchingKey)
NewSwitchingKey returns a new SwitchingKey with zero values.
func (*SwitchingKey) Get ¶
func (swk *SwitchingKey) Get() [][2]*ring.Poly
Get returns the switching key backing slice
func (*SwitchingKey) GetDataLen ¶
func (switchkey *SwitchingKey) GetDataLen(WithMetaData bool) (dataLen uint64)
GetDataLen returns the length in bytes of the target SwitchingKey.
func (*SwitchingKey) MarshalBinary ¶
func (switchkey *SwitchingKey) MarshalBinary() (data []byte, err error)
MarshalBinary encodes an SwitchingKey in a byte slice.
func (*SwitchingKey) UnmarshalBinary ¶
func (switchkey *SwitchingKey) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary decode a previously marshaled SwitchingKey in the target SwitchingKey.