Documentation
¶
Index ¶
- Constants
- Variables
- func EqualSlice(a, b []uint64) bool
- func Hash(data []uint64) (value []byte, err error)
- func PowerOf2(x, n, q, qInv uint64) (r uint64)
- func VerifyHash(hash0, hash1 []byte) bool
- type BatchEncoder
- func (batchencoder *BatchEncoder) DecodeInt(plaintext *Plaintext) ([]int64, error)
- func (batchencoder *BatchEncoder) DecodeUint(plaintext *Plaintext) ([]uint64, error)
- func (batchencoder *BatchEncoder) EncodeInt(coeffs []int64, plaintext *Plaintext) error
- func (batchencoder *BatchEncoder) EncodeUint(coeffs []uint64, plaintext *Plaintext) error
- type BfvContext
- func (bfvContext *BfvContext) GetContextP() *ring.Context
- func (bfvContext *BfvContext) GetContextQ() *ring.Context
- func (bfvContext *BfvContext) GetContextQP() *ring.Context
- func (bfvContext *BfvContext) GetContextT() *ring.Context
- func (bfvContext *BfvContext) GetDelta() []uint64
- func (bfvContext *BfvContext) GetN() uint64
- func (bfvContext *BfvContext) GetPlaintextModulus() uint64
- func (bfvContext *BfvContext) GetSigma() float64
- func (bfvContext *BfvContext) MarshalBinary() ([]byte, error)
- func (bfvcontext *BfvContext) NewBatchEncoder() *BatchEncoder
- func (bfvcontext *BfvContext) NewCiphertext(degree uint64) *Ciphertext
- func (bfvcontext *BfvContext) NewCiphertextBig(degree uint64) *Ciphertext
- func (bfvcontext *BfvContext) NewDecryptor(sk *SecretKey) (*Decryptor, error)
- func (bfvcontext *BfvContext) NewEncryptor(pk *PublicKey) (*Encryptor, error)
- func (bfvcontext *BfvContext) NewEvaluator() (*Evaluator, error)
- func (bfvcontext *BfvContext) NewIntEncoder(base int64) *IntEncoder
- func (bfvcontext *BfvContext) NewKeyGenerator() (keygen *KeyGenerator)
- func (bfvcontext *BfvContext) NewPlaintext() *Plaintext
- func (bfvcontext *BfvContext) NewRandomCiphertext(degree uint64) *Ciphertext
- func (bfvcontext *BfvContext) NewRandomPlaintextCoeffs() (coeffs []uint64)
- func (bfvContext *BfvContext) SetParameters(N, t uint64, ModulieQ, ModulieP []uint64, sigma float64) (err error)
- func (bfvContext *BfvContext) UnMarshalBinary(data []byte) error
- type BfvElement
- type BigPoly
- type Ciphertext
- func (ctx *Ciphertext) BfvContext() *BfvContext
- func (ctx *Ciphertext) Copy(ctxCopy BfvElement) error
- func (ctx *Ciphertext) CopyNew() BfvElement
- func (ctx *Ciphertext) Degree() uint64
- func (ctx *Ciphertext) InvNTT(c BfvElement) error
- func (ctx *Ciphertext) IsNTT() bool
- func (ciphertext *Ciphertext) MarshalBinary() ([]byte, error)
- func (ctx *Ciphertext) NTT(c BfvElement) error
- func (ctx *Ciphertext) Resize(degree uint64)
- func (ctx *Ciphertext) SetIsNTT(value bool)
- func (ctx *Ciphertext) SetValue(value []*ring.Poly)
- func (ciphertext *Ciphertext) UnmarshalBinary(data []byte) error
- func (ctx *Ciphertext) Value() []*ring.Poly
- type Decryptor
- type Encryptor
- type EvaluationKey
- type Evaluator
- func (evaluator *Evaluator) Add(c0, c1, cOut BfvElement) (err error)
- func (evaluator *Evaluator) AddNew(c0, c1 BfvElement) (cOut BfvElement, err error)
- func (evaluator *Evaluator) AddNoMod(c0, c1, cOut BfvElement) (err error)
- func (evaluator *Evaluator) AddNoModNew(c0, c1 BfvElement) (cOut BfvElement, err error)
- func (evaluator *Evaluator) InnerSum(c0 *Ciphertext, evakey *RotationKeys, c1 *Ciphertext) error
- func (evaluator *Evaluator) Mul(c0, c1, cOut BfvElement) (err error)
- func (evaluator *Evaluator) MulNew(c0, c1 BfvElement) (cOut BfvElement)
- func (evaluator *Evaluator) MulScalar(c0 BfvElement, scalar uint64, cOut BfvElement) error
- func (evaluator *Evaluator) MulScalarNew(c0 BfvElement, scalar uint64) (cOut BfvElement)
- func (evaluator *Evaluator) Neg(c0, cOut BfvElement) error
- func (evaluator *Evaluator) NegNew(c0 BfvElement) (cOut BfvElement)
- func (evaluator *Evaluator) Reduce(c0, cOut BfvElement) error
- func (evaluator *Evaluator) ReduceNew(c0 BfvElement) (cOut BfvElement)
- func (evaluator *Evaluator) Relinearize(cIn *Ciphertext, evakey *EvaluationKey, cOut *Ciphertext) error
- func (evaluator *Evaluator) RelinearizeNew(cIn *Ciphertext, evakey *EvaluationKey) (*Ciphertext, error)
- func (evaluator *Evaluator) RotateColumns(c0 BfvElement, k uint64, evakey *RotationKeys, c1 BfvElement) (err error)
- func (evaluator *Evaluator) RotateRows(c0 BfvElement, evakey *RotationKeys, c1 BfvElement) error
- func (evaluator *Evaluator) Sub(c0, c1, cOut BfvElement) (err error)
- func (evaluator *Evaluator) SubNew(c0, c1 BfvElement) (cOut BfvElement, err error)
- func (evaluator *Evaluator) SubNoMod(c0, c1, cOut BfvElement) (err error)
- func (evaluator *Evaluator) SubNoModNew(c0, c1 BfvElement) (cOut BfvElement, err error)
- func (evaluator *Evaluator) SwitchKeys(cIn *Ciphertext, switchingKey *SwitchingKey, cOut *Ciphertext) error
- func (evaluator *Evaluator) SwitchKeysNew(cIn *Ciphertext, switchingKey *SwitchingKey) (*Ciphertext, error)
- type IntEncoder
- type KeyGenerator
- func (keygen *KeyGenerator) NewKeyPair() (sk *SecretKey, pk *PublicKey, err error)
- func (keygen *KeyGenerator) NewPublicKey(sk *SecretKey) (*PublicKey, error)
- func (keygen *KeyGenerator) NewRelinKey(sk *SecretKey, maxDegree, bitDecomp uint64) (newEvakey *EvaluationKey, err error)
- func (keygen *KeyGenerator) NewRotationKeys(sk_output *SecretKey, bitDecomp uint64, rotLeft []uint64, rotRight []uint64, ...) (rotKey *RotationKeys, err error)
- func (keygen *KeyGenerator) NewRotationKeysPow2(sk_output *SecretKey, bitDecomp uint64, conjugate bool) (rotKey *RotationKeys, 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) SetPublicKey(p [2]*ring.Poly) (*PublicKey, error)
- func (keygen *KeyGenerator) SetRelinKeys(rlk [][][][2]*ring.Poly, bitDecomp uint64) (*EvaluationKey, error)
- type Parameters
- type Plaintext
- func (P *Plaintext) Add(p0, p1 *Plaintext)
- func (P *Plaintext) BfvContext() *BfvContext
- func (P *Plaintext) Copy(PCopy BfvElement) error
- func (P *Plaintext) CopyNew() BfvElement
- func (P *Plaintext) Degree() uint64
- func (P *Plaintext) EMB() error
- func (P *Plaintext) EMBInv() error
- func (P *Plaintext) GetCoefficients() [][]uint64
- func (P *Plaintext) InvNTT(p BfvElement) error
- func (P *Plaintext) IsNTT() bool
- func (P *Plaintext) Lift()
- func (P *Plaintext) MarshalBinary() ([]byte, error)
- func (P *Plaintext) Mul(p0, p1 *Plaintext)
- func (P *Plaintext) NTT(p BfvElement) error
- func (P *Plaintext) Resize(degree uint64)
- func (P *Plaintext) SetCoefficientsInt64(coeffs []int64)
- func (P *Plaintext) SetCoefficientsUint64(coeffs []uint64)
- func (P *Plaintext) SetIsNTT(value bool)
- func (P *Plaintext) SetValue(value []*ring.Poly)
- func (P *Plaintext) Sub(p0, p1 *Plaintext)
- func (P *Plaintext) UnMarshalBinary(data []byte) error
- func (P *Plaintext) Value() []*ring.Poly
- type PublicKey
- type RotationKeys
- type SecretKey
- type SwitchingKey
Constants ¶
const MaxModuliCount = 34
MaxModuliCount is the largest supported number of 60 moduli in the RNS representation
const MaxN = 1 << 16
MaxN is the largest supported polynomial modulus degree
Variables ¶
var DefaultParams = []Parameters{ {4096, 65537, logN12Q110, Pi60[len(Pi60)-3:], 3.19}, {8192, 65537, logN13Q219, Pi60[len(Pi60)-5:], 3.19}, {16384, 65537, logN14Q441, Pi60[len(Pi60)-9:], 3.19}, {32768, 65537, logN15Q885, Pi60[len(Pi60)-17:], 3.19}, }
DefaultParams is an array default parameters with increasing homomorphic capacity. These parameters correspond to 128 bit security level for secret keys in the ternary distribution (see //https://projects.csail.mit.edu/HEWorkshop/HomomorphicEncryptionStandard2018.pdf).
var Pi60 = []uint64{576460752308273153, 576460752315482113, 576460752319021057, 576460752319414273, 576460752321642497,
576460752325705729, 576460752328327169, 576460752329113601, 576460752329506817, 576460752329900033,
576460752331210753, 576460752337502209, 576460752340123649, 576460752342876161, 576460752347201537,
576460752347332609, 576460752352837633, 576460752354017281, 576460752355065857, 576460752355459073,
576460752358604801, 576460752364240897, 576460752368435201, 576460752371187713, 576460752373547009,
576460752374333441, 576460752376692737, 576460752378003457, 576460752378396673, 576460752380755969,
576460752381411329, 576460752386129921, 576460752395173889, 576460752395960321, 576460752396091393,
576460752396484609, 576460752399106049, 576460752405135361, 576460752405921793, 576460752409722881,
576460752410116097, 576460752411033601, 576460752412082177, 576460752416145409, 576460752416931841,
576460752421257217, 576460752427548673, 576460752429514753, 576460752435281921, 576460752437248001,
576460752438558721, 576460752441966593, 576460752449044481, 576460752451141633, 576460752451534849,
576460752462938113, 576460752465952769, 576460752468705281, 576460752469491713, 576460752472375297,
576460752473948161, 576460752475389953, 576460752480894977, 576460752483254273, 576460752484827137,
576460752486793217, 576460752486924289, 576460752492691457, 576460752498589697, 576460752498720769,
576460752499507201, 576460752504225793, 576460752505405441, 576460752507240449, 576460752507764737,
576460752509206529, 576460752510124033, 576460752510779393, 576460752511959041, 576460752514449409,
576460752516284417, 576460752519168001, 576460752520347649, 576460752520609793, 576460752522969089,
576460752523100161, 576460752524279809, 576460752525852673, 576460752526245889, 576460752526508033,
576460752532013057, 576460752545120257, 576460752550100993, 576460752551804929, 576460752567402497,
576460752568975361, 576460752573431809, 576460752580902913, 576460752585490433, 576460752586407937}
var TBatching = map[uint64][]uint64{
4096: {40961, 114689, 188417, 417793, 1032193, 2056193, 4169729, 8380417, 16760833, 33538049, 67084289, 134176769,
268369921, 536813569, 1073692673, 2147377153, 4294828033},
8192: {65537, 114689, 163841, 1032193, 1785857, 4079617, 8273921, 16760833, 33538049, 67043329, 133857281,
268369921, 536690689, 1073692673, 2147352577, 4294475777},
16384: {65537, 163841, 786433, 1769473, 3735553, 8257537, 16580609, 33292289, 67043329, 133857281, 268369921,
536641537, 1073643521, 2147352577, 4294475777},
32768: {65537, 786433, 1769473, 3735553, 8257537, 16580609, 33292289, 67043329, 132710401, 268369921, 536608769,
1073479681, 2147352577, 4293918721},
}
Plaintext modulus allowing batching for the corresponding N in ascending bitsize.
var Tpow2 = []uint64{2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144,
524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912,
1073741824, 2147483648, 4294967296}
Power of 2 plaintext modulus
Functions ¶
func EqualSlice ¶
func VerifyHash ¶
Types ¶
type BatchEncoder ¶
type BatchEncoder struct {
// contains filtered or unexported fields
}
func (*BatchEncoder) DecodeInt ¶
func (batchencoder *BatchEncoder) DecodeInt(plaintext *Plaintext) ([]int64, error)
func (*BatchEncoder) DecodeUint ¶
func (batchencoder *BatchEncoder) DecodeUint(plaintext *Plaintext) ([]uint64, error)
func (*BatchEncoder) EncodeInt ¶
func (batchencoder *BatchEncoder) EncodeInt(coeffs []int64, plaintext *Plaintext) error
func (*BatchEncoder) EncodeUint ¶
func (batchencoder *BatchEncoder) EncodeUint(coeffs []uint64, plaintext *Plaintext) error
type BfvContext ¶
type BfvContext struct {
// floor(Q/T) mod each Qi in montgomeryform
DeltaMont []uint64
Delta []uint64
// contains filtered or unexported fields
}
func NewBfvContext ¶
func NewBfvContext() *BfvContext
func NewBfvContextWithParam ¶
func NewBfvContextWithParam(N, t uint64, ModulieQ, ModulieP []uint64, sigma float64) (newbfvcontext *BfvContext, err error)
func (*BfvContext) GetContextP ¶
func (bfvContext *BfvContext) GetContextP() *ring.Context
func (*BfvContext) GetContextQ ¶
func (bfvContext *BfvContext) GetContextQ() *ring.Context
func (*BfvContext) GetContextQP ¶
func (bfvContext *BfvContext) GetContextQP() *ring.Context
func (*BfvContext) GetContextT ¶
func (bfvContext *BfvContext) GetContextT() *ring.Context
func (*BfvContext) GetDelta ¶
func (bfvContext *BfvContext) GetDelta() []uint64
func (*BfvContext) GetN ¶
func (bfvContext *BfvContext) GetN() uint64
func (*BfvContext) GetPlaintextModulus ¶
func (bfvContext *BfvContext) GetPlaintextModulus() uint64
func (*BfvContext) GetSigma ¶
func (bfvContext *BfvContext) GetSigma() float64
func (*BfvContext) MarshalBinary ¶
func (bfvContext *BfvContext) MarshalBinary() ([]byte, error)
func (*BfvContext) NewBatchEncoder ¶
func (bfvcontext *BfvContext) NewBatchEncoder() *BatchEncoder
func (*BfvContext) NewCiphertext ¶
func (bfvcontext *BfvContext) NewCiphertext(degree uint64) *Ciphertext
NewCiphertext creates a new ciphertext of degree n
func (*BfvContext) NewCiphertextBig ¶
func (bfvcontext *BfvContext) NewCiphertextBig(degree uint64) *Ciphertext
NewCiphertext creates a new ciphertext of degree n
func (*BfvContext) NewDecryptor ¶
func (bfvcontext *BfvContext) NewDecryptor(sk *SecretKey) (*Decryptor, error)
func (*BfvContext) NewEncryptor ¶
func (bfvcontext *BfvContext) NewEncryptor(pk *PublicKey) (*Encryptor, error)
func (*BfvContext) NewEvaluator ¶
func (bfvcontext *BfvContext) NewEvaluator() (*Evaluator, error)
func (*BfvContext) NewIntEncoder ¶
func (bfvcontext *BfvContext) NewIntEncoder(base int64) *IntEncoder
func (*BfvContext) NewKeyGenerator ¶
func (bfvcontext *BfvContext) NewKeyGenerator() (keygen *KeyGenerator)
func (*BfvContext) NewPlaintext ¶
func (bfvcontext *BfvContext) NewPlaintext() *Plaintext
NewCiphertext creates a new ciphertext
func (*BfvContext) NewRandomCiphertext ¶
func (bfvcontext *BfvContext) NewRandomCiphertext(degree uint64) *Ciphertext
func (*BfvContext) NewRandomPlaintextCoeffs ¶
func (bfvcontext *BfvContext) NewRandomPlaintextCoeffs() (coeffs []uint64)
func (*BfvContext) SetParameters ¶
func (bfvContext *BfvContext) SetParameters(N, t uint64, ModulieQ, ModulieP []uint64, sigma float64) (err error)
func (*BfvContext) UnMarshalBinary ¶
func (bfvContext *BfvContext) UnMarshalBinary(data []byte) error
type BfvElement ¶
type BfvElement interface {
Value() []*ring.Poly
SetValue([]*ring.Poly)
BfvContext() *BfvContext
Resize(uint64)
CopyNew() BfvElement
Copy(BfvElement) error
Degree() uint64
NTT(BfvElement) error
InvNTT(BfvElement) error
IsNTT() bool
SetIsNTT(bool)
}
type Ciphertext ¶
type Ciphertext BigPoly
func (*Ciphertext) BfvContext ¶
func (ctx *Ciphertext) BfvContext() *BfvContext
func (*Ciphertext) Copy ¶
func (ctx *Ciphertext) Copy(ctxCopy BfvElement) error
Copies the value of the ciphertext on a reciever ciphertext of the same format
func (*Ciphertext) CopyNew ¶
func (ctx *Ciphertext) CopyNew() BfvElement
Creates a new ciphertext of the same format and coefficients.
func (*Ciphertext) Degree ¶
func (ctx *Ciphertext) Degree() uint64
func (*Ciphertext) InvNTT ¶
func (ctx *Ciphertext) InvNTT(c BfvElement) error
func (*Ciphertext) IsNTT ¶
func (ctx *Ciphertext) IsNTT() bool
func (*Ciphertext) MarshalBinary ¶
func (ciphertext *Ciphertext) MarshalBinary() ([]byte, error)
func (*Ciphertext) NTT ¶
func (ctx *Ciphertext) NTT(c BfvElement) error
func (*Ciphertext) Resize ¶
func (ctx *Ciphertext) Resize(degree uint64)
func (*Ciphertext) SetIsNTT ¶
func (ctx *Ciphertext) SetIsNTT(value bool)
func (*Ciphertext) SetValue ¶
func (ctx *Ciphertext) SetValue(value []*ring.Poly)
func (*Ciphertext) UnmarshalBinary ¶
func (ciphertext *Ciphertext) UnmarshalBinary(data []byte) error
func (*Ciphertext) Value ¶
func (ctx *Ciphertext) Value() []*ring.Poly
type Decryptor ¶
type Decryptor struct {
// contains filtered or unexported fields
}
func (*Decryptor) Decrypt ¶
func (decryptor *Decryptor) Decrypt(ciphertext *Ciphertext, plaintext *Plaintext) (err error)
func (*Decryptor) DecryptNew ¶
func (decryptor *Decryptor) DecryptNew(ciphertext *Ciphertext) (*Plaintext, error)
type Encryptor ¶
type Encryptor struct {
// contains filtered or unexported fields
}
func (*Encryptor) Encrypt ¶
func (encryptor *Encryptor) Encrypt(plaintext *Plaintext, ciphertext *Ciphertext) error
func (*Encryptor) EncryptNew ¶
func (encryptor *Encryptor) EncryptNew(plaintext *Plaintext) (*Ciphertext, error)
type EvaluationKey ¶
type EvaluationKey struct {
// contains filtered or unexported fields
}
func (*EvaluationKey) Get ¶
func (evk *EvaluationKey) Get() []*SwitchingKey
func (*EvaluationKey) MarshalBinary ¶
func (evaluationkey *EvaluationKey) MarshalBinary() ([]byte, error)
func (*EvaluationKey) UnMarshalBinary ¶
func (evaluationkey *EvaluationKey) UnMarshalBinary(data []byte) error
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
func (*Evaluator) Add ¶
func (evaluator *Evaluator) Add(c0, c1, cOut BfvElement) (err error)
AddNoMod adds the second element to the first element. Requires a receiver of correct type and degree.
func (*Evaluator) AddNew ¶
func (evaluator *Evaluator) AddNew(c0, c1 BfvElement) (cOut BfvElement, err error)
AddNew adds the second elements to the first element and creates a new element storing the result. Be aware that an element of type ciphertext is always returned, even if two plaintexts where given as input.
func (*Evaluator) AddNoMod ¶
func (evaluator *Evaluator) AddNoMod(c0, c1, cOut BfvElement) (err error)
AddNoMod adds the second element to the first element without modular reduction. Requires a receiver of correct type and degree.
func (*Evaluator) AddNoModNew ¶
func (evaluator *Evaluator) AddNoModNew(c0, c1 BfvElement) (cOut BfvElement, err error)
AddNoModNew adds the second elements to the first element without modular reduction and creates a new element storing the result. Be aware that an element of type ciphertext is always returned, even if two plaintexts where given as input.
func (*Evaluator) InnerSum ¶
func (evaluator *Evaluator) InnerSum(c0 *Ciphertext, evakey *RotationKeys, c1 *Ciphertext) error
func (*Evaluator) Mul ¶
func (evaluator *Evaluator) Mul(c0, c1, cOut BfvElement) (err error)
Mul multiplies the first element by the second element. Requirese a receiver of the correct type and degree.
func (*Evaluator) MulNew ¶
func (evaluator *Evaluator) MulNew(c0, c1 BfvElement) (cOut BfvElement)
MulNew multiplies the first element by the second element and returns the result in a new element. Be aware that an element of type ciphertext is always returned, even if two plaintexts where given as input.
func (*Evaluator) MulScalar ¶
func (evaluator *Evaluator) MulScalar(c0 BfvElement, scalar uint64, cOut BfvElement) error
MulScalar multiplies the input by the given scalar. Requirese a receiver of the correct type and degree.
func (*Evaluator) MulScalarNew ¶
func (evaluator *Evaluator) MulScalarNew(c0 BfvElement, scalar uint64) (cOut BfvElement)
MulScalar multiplies the input by the given scalar and returns an new elemnent storing the result. Be aware that an element of type ciphertext is always returned, even if two plaintexts where given as input.
func (*Evaluator) Neg ¶
func (evaluator *Evaluator) Neg(c0, cOut BfvElement) error
Neg negates the input element. Requiers a receiver of the correct type and degree.
func (*Evaluator) NegNew ¶
func (evaluator *Evaluator) NegNew(c0 BfvElement) (cOut BfvElement)
NegNew negates the input element and returns a new element storing the result. Be aware that an element of type ciphertext is always returned, even if two plaintexts where given as input.
func (*Evaluator) Reduce ¶
func (evaluator *Evaluator) Reduce(c0, cOut BfvElement) error
Reduce applies a modular reduction on the input element. Requires a receiver element of the correct type and degree.
func (*Evaluator) ReduceNew ¶
func (evaluator *Evaluator) ReduceNew(c0 BfvElement) (cOut BfvElement)
Reduce applies a modular reduction on the input element and returns a new element storing the result. Be aware that an element of type ciphertext is always returned, even if two plaintexts where given as input.
func (*Evaluator) Relinearize ¶
func (evaluator *Evaluator) Relinearize(cIn *Ciphertext, evakey *EvaluationKey, cOut *Ciphertext) error
func (*Evaluator) RelinearizeNew ¶
func (evaluator *Evaluator) RelinearizeNew(cIn *Ciphertext, evakey *EvaluationKey) (*Ciphertext, error)
func (*Evaluator) RotateColumns ¶
func (evaluator *Evaluator) RotateColumns(c0 BfvElement, k uint64, evakey *RotationKeys, c1 BfvElement) (err error)
RotateColumns homomorphically rotates the columns of the ciphertext to the left
func (*Evaluator) RotateRows ¶
func (evaluator *Evaluator) RotateRows(c0 BfvElement, evakey *RotationKeys, c1 BfvElement) error
Applies the Galois Endomorphism on the Ciphertext, using the Plaintext Primitive Roots
func (*Evaluator) Sub ¶
func (evaluator *Evaluator) Sub(c0, c1, cOut BfvElement) (err error)
Sub subtract the second element to the first element. Requires a receiver of correct type and degree.
func (*Evaluator) SubNew ¶
func (evaluator *Evaluator) SubNew(c0, c1 BfvElement) (cOut BfvElement, err error)
SubNew subtracts the second elements to the first element and creates a new element storing the result. Be aware that an element of type ciphertext is always returned, even if two plaintexts where given as input.
func (*Evaluator) SubNoMod ¶
func (evaluator *Evaluator) SubNoMod(c0, c1, cOut BfvElement) (err error)
Sub subtract the second element to the first element without modular reduction. Requires a receiver of correct type and degree.
func (*Evaluator) SubNoModNew ¶
func (evaluator *Evaluator) SubNoModNew(c0, c1 BfvElement) (cOut BfvElement, err error)
SubNoModNew subtracts the second elements to the first element without modular reduction and creates a new element storing the result. Be aware that an element of type ciphertext is always returned, even if two plaintexts where given as input.
func (*Evaluator) SwitchKeys ¶
func (evaluator *Evaluator) SwitchKeys(cIn *Ciphertext, switchingKey *SwitchingKey, cOut *Ciphertext) error
func (*Evaluator) SwitchKeysNew ¶
func (evaluator *Evaluator) SwitchKeysNew(cIn *Ciphertext, switchingKey *SwitchingKey) (*Ciphertext, error)
type IntEncoder ¶
type IntEncoder struct {
// contains filtered or unexported fields
}
func (*IntEncoder) Decode ¶
func (encoder *IntEncoder) Decode(plaintext *Plaintext) int64
func (*IntEncoder) Encode ¶
func (encoder *IntEncoder) Encode(msg int64, plaintext *Plaintext)
type KeyGenerator ¶
type KeyGenerator struct {
// contains filtered or unexported fields
}
func (*KeyGenerator) NewKeyPair ¶
func (keygen *KeyGenerator) NewKeyPair() (sk *SecretKey, pk *PublicKey, err error)
func (*KeyGenerator) NewPublicKey ¶
func (keygen *KeyGenerator) NewPublicKey(sk *SecretKey) (*PublicKey, error)
func (*KeyGenerator) NewRelinKey ¶
func (keygen *KeyGenerator) NewRelinKey(sk *SecretKey, maxDegree, bitDecomp uint64) (newEvakey *EvaluationKey, err error)
func (*KeyGenerator) NewRotationKeys ¶
func (keygen *KeyGenerator) NewRotationKeys(sk_output *SecretKey, bitDecomp uint64, rotLeft []uint64, rotRight []uint64, conjugate bool) (rotKey *RotationKeys, err error)
func (*KeyGenerator) NewRotationKeysPow2 ¶
func (keygen *KeyGenerator) NewRotationKeysPow2(sk_output *SecretKey, bitDecomp uint64, conjugate bool) (rotKey *RotationKeys, err error)
func (*KeyGenerator) NewSecretKey ¶
func (keygen *KeyGenerator) NewSecretKey() *SecretKey
func (*KeyGenerator) NewSwitchingKey ¶
func (keygen *KeyGenerator) NewSwitchingKey(sk_input, sk_output *SecretKey, bitDecomp uint64) (newevakey *SwitchingKey, err error)
func (*KeyGenerator) SetPublicKey ¶
func (keygen *KeyGenerator) SetPublicKey(p [2]*ring.Poly) (*PublicKey, error)
func (*KeyGenerator) SetRelinKeys ¶
func (keygen *KeyGenerator) SetRelinKeys(rlk [][][][2]*ring.Poly, bitDecomp uint64) (*EvaluationKey, error)
type Parameters ¶
Parameters represents a given parameter set for the BFV cryptosystem.
func (*Parameters) Equals ¶
func (p *Parameters) Equals(other *Parameters) bool
Equals compares two sets of parameters for equality
func (*Parameters) MarshalBinary ¶
func (p *Parameters) MarshalBinary() ([]byte, error)
MarshalBinary returns a []byte representation of the parameter set
func (*Parameters) UnMarshalBinary ¶
func (p *Parameters) UnMarshalBinary(data []byte) error
UnMarshalBinary decodes a []byte into a parameter set struct
type Plaintext ¶
type Plaintext BigPoly
func (*Plaintext) BfvContext ¶
func (P *Plaintext) BfvContext() *BfvContext
func (*Plaintext) Copy ¶
func (P *Plaintext) Copy(PCopy BfvElement) error
Copies the value of the ciphertext on a reciever ciphertext of the same format
func (*Plaintext) CopyNew ¶
func (P *Plaintext) CopyNew() BfvElement
Creates a new ciphertext of the same format and coefficients.
func (*Plaintext) GetCoefficients ¶
func (*Plaintext) InvNTT ¶
func (P *Plaintext) InvNTT(p BfvElement) error
func (*Plaintext) MarshalBinary ¶
func (*Plaintext) NTT ¶
func (P *Plaintext) NTT(p BfvElement) error
func (*Plaintext) SetCoefficientsInt64 ¶
func (*Plaintext) SetCoefficientsUint64 ¶
func (*Plaintext) UnMarshalBinary ¶
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func (*PublicKey) UnMarshalBinary ¶
type RotationKeys ¶
type RotationKeys struct {
// contains filtered or unexported fields
}
func (*RotationKeys) MarshalBinary ¶
func (rotationkey *RotationKeys) MarshalBinary() ([]byte, error)
func (*RotationKeys) UnMarshalBinary ¶
func (rotationkey *RotationKeys) UnMarshalBinary(data []byte) error
type SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
func (*SecretKey) MarshalBinary ¶
func (*SecretKey) UnMarshalBinary ¶
type SwitchingKey ¶
type SwitchingKey struct {
// contains filtered or unexported fields
}