Documentation
¶
Overview ¶
Package bfv implements a RNS-accelerated Fan-Vercauteren version of Brakerski's scale invariant homomorphic encryption scheme. It provides modular arithmetic over the integers.
Index ¶
- Constants
- Variables
- func GenLiftParams(context *ring.Context, t uint64) (deltaMont []uint64)
- func GenModuli(params *Parameters) (Q []uint64, P []uint64, QMul []uint64)
- type Ciphertext
- func (el Ciphertext) Ciphertext() *Ciphertext
- func (el Ciphertext) Copy(ctxCopy *bfvElement)
- func (el Ciphertext) CopyNew() *bfvElement
- func (el Ciphertext) Degree() uint64
- func (el Ciphertext) Element() *bfvElement
- func (ciphertext *Ciphertext) GetDataLen(WithMetaData bool) (dataLen uint64)
- func (el Ciphertext) InvNTT(context *ring.Context, c *bfvElement)
- func (el Ciphertext) IsNTT() bool
- func (ciphertext *Ciphertext) MarshalBinary() (data []byte, err error)
- func (el Ciphertext) NTT(context *ring.Context, c *bfvElement)
- func (el Ciphertext) Plaintext() *Plaintext
- func (el Ciphertext) Resize(params *Parameters, degree uint64)
- func (el Ciphertext) SetIsNTT(value bool)
- func (el Ciphertext) SetValue(value []*ring.Poly)
- func (ciphertext *Ciphertext) UnmarshalBinary(data []byte) (err error)
- func (el Ciphertext) Value() []*ring.Poly
- 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) SetRelinKeys(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) 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 *bfvElement)
- func (el Plaintext) CopyNew() *bfvElement
- func (el Plaintext) Degree() uint64
- func (el Plaintext) Element() *bfvElement
- func (el Plaintext) InvNTT(context *ring.Context, c *bfvElement)
- func (el Plaintext) IsNTT() bool
- func (el Plaintext) NTT(context *ring.Context, c *bfvElement)
- func (el Plaintext) Plaintext() *Plaintext
- func (el Plaintext) Resize(params *Parameters, degree uint64)
- func (el Plaintext) SetIsNTT(value bool)
- 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(rotType Rotation, k uint64, evakey [][2]*ring.Poly)
- func (rotationkey *RotationKeys) UnmarshalBinary(data []byte) (err error)
- type SecretKey
- type SwitchingKey
Constants ¶
const ( RotationRight = iota + 1 RotationLeft RotationRow )
Constants for rotation types
const ( PN12QP109 = iota PN13QP218 PN14QP438 PN15QP880 )
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, T: 65537, LogModuli: LogModuli{ LogQi: []uint64{39, 39}, LogPi: []uint64{30}, LogQiMul: []uint64{60, 60}, }, Sigma: 3.2}, {LogN: 13, T: 65537, LogModuli: LogModuli{ LogQi: []uint64{54, 54, 54}, LogPi: []uint64{55}, LogQiMul: []uint64{60, 60, 60}, }, Sigma: 3.2}, {LogN: 14, T: 65537, LogModuli: LogModuli{ LogQi: []uint64{56, 55, 55, 54, 54, 54}, LogPi: []uint64{55, 55}, LogQiMul: []uint64{60, 60, 60, 60, 60, 60}, }, Sigma: 3.2}, {LogN: 15, T: 65537, LogModuli: LogModuli{ LogQi: []uint64{59, 59, 59, 58, 58, 58, 58, 58, 58, 58, 58, 58}, LogPi: []uint64{60, 60, 60}, LogQiMul: []uint64{60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60}, }, Sigma: 3.2}, }
DefaultParams is a set of default BFV parameters ensuring 128 bit security.
Functions ¶
func GenLiftParams ¶ added in v1.3.0
GenLiftParams generates the lifting parameters.
Types ¶
type Ciphertext ¶
type Ciphertext struct {
// contains filtered or unexported fields
}
Ciphertext is a *ring.Poly array representing a polynomial of degree > 0 with coefficients in R_Q.
func NewCiphertext ¶ added in v1.3.0
func NewCiphertext(params *Parameters, degree uint64) (ciphertext *Ciphertext)
NewCiphertext creates a new ciphertext parameterized by degree, level and scale.
func NewCiphertextRandom ¶ added in v1.3.0
func NewCiphertextRandom(params *Parameters, degree uint64) (ciphertext *Ciphertext)
NewCiphertextRandom generates a new uniformly distributed ciphertext of degree, level and scale.
func (Ciphertext) Ciphertext ¶ added in v1.1.0
func (el Ciphertext) Ciphertext() *Ciphertext
func (Ciphertext) Copy ¶
func (el Ciphertext) Copy(ctxCopy *bfvElement)
Copy copies the value and parameters of the input on the target bfvElement.
func (Ciphertext) CopyNew ¶
func (el Ciphertext) CopyNew() *bfvElement
CopyNew creates a new bfvElement which is a copy of the target bfvElement, and returns the value as a bfvElement.
func (Ciphertext) Degree ¶
func (el Ciphertext) Degree() uint64
Degree returns the degree of the target bfvElement.
func (*Ciphertext) GetDataLen ¶ added in v1.3.0
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 bfvElement 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 true if the target bfvElement is in the NTT domain, and false otherwise.
func (*Ciphertext) MarshalBinary ¶
func (ciphertext *Ciphertext) MarshalBinary() (data []byte, err error)
MarshalBinary encodes a Ciphertext in a byte slice.
func (Ciphertext) NTT ¶
NTT puts the target bfvElement 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(params *Parameters, degree uint64)
Resize resizes the target bfvElement degree to the degree given as input. If the input degree is bigger, then it will append new empty polynomials; if the degree is smaller, it will delete polynomials until the degree matches the input degree.
func (Ciphertext) SetIsNTT ¶
func (el Ciphertext) SetIsNTT(value bool)
SetIsNTT assigns the input Boolean value to the isNTT flag of the target bfvElement.
func (Ciphertext) SetValue ¶
SetValue assigns the input slice of polynomials to the target bfvElement value.
func (*Ciphertext) UnmarshalBinary ¶
func (ciphertext *Ciphertext) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary decodes a previously marshaled Ciphertext in the target Ciphertext.
type Decryptor ¶
type Decryptor interface {
// DecryptNew decrypts the input ciphertext and returns the result on a new
// plaintext.
DecryptNew(ciphertext *Ciphertext) *Plaintext
// Decrypt decrypts the input ciphertext and returns the result on the
// provided receiver plaintext.
Decrypt(ciphertext *Ciphertext, plaintext *Plaintext)
}
Decryptor is an interface for decryptors
func NewDecryptor ¶ added in v1.3.0
func NewDecryptor(params *Parameters, sk *SecretKey) Decryptor
NewDecryptor creates a new Decryptor from the parameters with the secret-key given as input.
type Encoder ¶ added in v1.3.0
type Encoder interface {
EncodeUint(coeffs []uint64, plaintext *Plaintext)
EncodeInt(coeffs []int64, plaintext *Plaintext)
DecodeUint(plaintext *Plaintext) (coeffs []uint64)
DecodeInt(plaintext *Plaintext) (coeffs []int64)
}
Encoder is an interface implementing the encoder.
func NewEncoder ¶ added in v1.3.0
func NewEncoder(params *Parameters) Encoder
NewEncoder creates a new encoder from the provided parameters.
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 receiver ciphertext.
Encrypt(plaintext *Plaintext, ciphertext *Ciphertext)
}
Encryptor is 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 ¶ added in v1.3.0
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 ¶ added in v1.3.0
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 ¶ added in v1.3.0
func NewRelinKey(params *Parameters, maxDegree uint64) (evakey *EvaluationKey)
NewRelinKey creates a new EvaluationKey with zero values.
func (*EvaluationKey) Get ¶
func (evk *EvaluationKey) Get() []*SwitchingKey
Get returns the slice of SwitchingKeys of the target EvaluationKey.
func (*EvaluationKey) GetDataLen ¶ added in v1.3.0
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 EvaluationKey key in a byte slice.
func (*EvaluationKey) SetRelinKeys ¶ added in v1.1.0
func (evk *EvaluationKey) SetRelinKeys(rlk [][][2]*ring.Poly)
SetRelinKeys sets the polynomial of the target EvaluationKey as the input polynomials.
func (*EvaluationKey) UnmarshalBinary ¶ added in v1.3.0
func (evaluationkey *EvaluationKey) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary decodes a previously marshaled EvaluationKey in the target EvaluationKey.
type Evaluator ¶
type Evaluator interface {
Add(op0, op1 Operand, ctOut *Ciphertext)
AddNew(op0, op1 Operand) (ctOut *Ciphertext)
AddNoMod(op0, op1 Operand, ctOut *Ciphertext)
AddNoModNew(op0, op1 Operand) (ctOut *Ciphertext)
Sub(op0, op1 Operand, ctOut *Ciphertext)
SubNew(op0, op1 Operand) (ctOut *Ciphertext)
SubNoMod(op0, op1 Operand, ctOut *Ciphertext)
SubNoModNew(op0, op1 Operand) (ctOut *Ciphertext)
Neg(op Operand, ctOut *Ciphertext)
NegNew(op Operand) (ctOut *Ciphertext)
Reduce(op Operand, ctOut *Ciphertext)
ReduceNew(op Operand) (ctOut *Ciphertext)
MulScalar(op Operand, scalar uint64, ctOut *Ciphertext)
MulScalarNew(op Operand, scalar uint64) (ctOut *Ciphertext)
Mul(op0 *Ciphertext, op1 Operand, ctOut *Ciphertext)
MulNew(op0 *Ciphertext, op1 Operand) (ctOut *Ciphertext)
Relinearize(ct0 *Ciphertext, evakey *EvaluationKey, ctOut *Ciphertext)
RelinearizeNew(ct0 *Ciphertext, evakey *EvaluationKey) (ctOut *Ciphertext)
SwitchKeys(ct0 *Ciphertext, switchKey *SwitchingKey, ctOut *Ciphertext)
SwitchKeysNew(ct0 *Ciphertext, switchkey *SwitchingKey) (ctOut *Ciphertext)
RotateColumnsNew(ct0 *Ciphertext, k uint64, evakey *RotationKeys) (ctOut *Ciphertext)
RotateColumns(ct0 *Ciphertext, k uint64, evakey *RotationKeys, ctOut *Ciphertext)
RotateRows(ct0 *Ciphertext, evakey *RotationKeys, ctOut *Ciphertext)
RotateRowsNew(ct0 *Ciphertext, evakey *RotationKeys) (ctOut *Ciphertext)
InnerSum(ct0 *Ciphertext, evakey *RotationKeys, ctOut *Ciphertext)
}
Evaluator is an interface implementing the public methodes of the evaluator.
func NewEvaluator ¶ added in v1.3.0
func NewEvaluator(params *Parameters) Evaluator
NewEvaluator creates a new Evaluator, that can be used to do homomorphic operations on 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)
GenPublicKey(sk *SecretKey) (pk *PublicKey)
GenKeyPair() (sk *SecretKey, pk *PublicKey)
GenRelinKey(sk *SecretKey, maxDegree uint64) (evk *EvaluationKey)
GenSwitchingKey(skIn, skOut *SecretKey) (evk *SwitchingKey)
GenRot(rotType Rotation, sk *SecretKey, k uint64, rotKey *RotationKeys)
GenRotationKeysPow2(sk *SecretKey) (rotKey *RotationKeys)
}
KeyGenerator is an interface implementing the methods of the keyGenerator.
func NewKeyGenerator ¶ added in v1.3.0
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 ¶ added in v1.3.0
type LogModuli struct {
LogQi []uint64 // Ciphertext prime moduli bit-size
LogPi []uint64 // Keys additional prime moduli bit-size
LogQiMul []uint64 // Ciphertext secondary prime moduli bit-size
}
LogModuli stores the bit-length of the NTT primes of the RNS representation.
type Moduli ¶ added in v1.3.0
type Moduli struct {
Qi []uint64 // Ciphertext prime moduli
Pi []uint64 // Keys additional prime moduli
QiMul []uint64 // Ciphertext secondary prime moduli
}
Moduli stores the NTT primes of the RNS representation.
type Operand ¶ added in v1.1.0
type Operand interface {
Element() *bfvElement
Degree() uint64
}
Operand is a common interface for Ciphertext and Plaintext.
type Parameters ¶
type Parameters struct {
Moduli
LogModuli
LogN uint64 // Ring degree (power of 2)
T uint64 // Plaintext modulus
Sigma float64 // Gaussian sampling standard deviation
// contains filtered or unexported fields
}
Parameters represents a given parameter set for the BFV cryptosystem.
func NewParametersFromLogModuli ¶ added in v1.3.0
func NewParametersFromLogModuli(LogN, T uint64, logModuli LogModuli, sigma float64) (params *Parameters)
NewParametersFromLogModuli generates a new set or BFV parameters from the input parameters.
func NewParametersFromModuli ¶ added in v1.3.0
func NewParametersFromModuli(LogN, T uint64, moduli Moduli, sigma float64) (params *Parameters)
NewParametersFromModuli generates a new set or BFV parameters from the input parameters.
func (*Parameters) Beta ¶ added in v1.3.0
func (p *Parameters) Beta() uint64
Beta returns ceil(#Qi/#Pi).
func (*Parameters) Copy ¶ added in v1.3.0
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 ¶ added in v1.3.0
func (p *Parameters) GenFromLogModuli()
GenFromLogModuli generates a set of parameters, including the actual moduli, from the target bit-sizes of the moduli chain.
func (*Parameters) GenFromModuli ¶ added in v1.3.0
func (p *Parameters) GenFromModuli()
GenFromModuli generates a set of parameters from the moduli chain.
func (*Parameters) IsValid ¶ added in v1.3.0
func (p *Parameters) IsValid() bool
IsValid returns a true if the parameters are complete and valid, and false otherwise.
func (*Parameters) LogQP ¶ added in v1.3.0
func (p *Parameters) LogQP() uint64
LogQP returns the bit-length 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 ¶ added in v1.3.0
func (p *Parameters) NewPolyP() *ring.Poly
NewPolyP returns a new empty polynomial of degree 2^LogN in basis Pi.
func (*Parameters) NewPolyQ ¶ added in v1.3.0
func (p *Parameters) NewPolyQ() *ring.Poly
NewPolyQ returns a new empty polynomial of degree 2^LogN in basis Qi.
func (*Parameters) NewPolyQP ¶ added in v1.3.0
func (p *Parameters) NewPolyQP() *ring.Poly
NewPolyQP returns a new empty polynomial of degree 2^LogN in basis Qi + Pi.
func (*Parameters) UnmarshalBinary ¶ added in v1.3.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 a bfvElement with only one Poly.
func NewPlaintext ¶ added in v1.3.0
func NewPlaintext(params *Parameters) *Plaintext
NewPlaintext creates a new plaintext from the target context.
func (Plaintext) Ciphertext ¶ added in v1.1.0
func (el Plaintext) Ciphertext() *Ciphertext
func (Plaintext) Copy ¶
func (el Plaintext) Copy(ctxCopy *bfvElement)
Copy copies the value and parameters of the input on the target bfvElement.
func (Plaintext) CopyNew ¶
func (el Plaintext) CopyNew() *bfvElement
CopyNew creates a new bfvElement which is a copy of the target bfvElement, and returns the value as a bfvElement.
func (Plaintext) Degree ¶
func (el Plaintext) Degree() uint64
Degree returns the degree of the target bfvElement.
func (Plaintext) InvNTT ¶
InvNTT puts the target bfvElement 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 true if the target bfvElement is in the NTT domain, and false otherwise.
func (Plaintext) NTT ¶
NTT puts the target bfvElement 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(params *Parameters, degree uint64)
Resize resizes the target bfvElement degree to the degree given as input. If the input degree is bigger, then it will append new empty polynomials; if the degree is smaller, it will delete polynomials until the degree matches the input degree.
func (Plaintext) SetIsNTT ¶
func (el Plaintext) SetIsNTT(value bool)
SetIsNTT assigns the input Boolean value to the isNTT flag of the target bfvElement.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is a structure that stores the PublicKey.
func NewPublicKey ¶ added in v1.3.0
func NewPublicKey(params *Parameters) (pk *PublicKey)
NewPublicKey returns a new PublicKey with zero values.
func (*PublicKey) GetDataLen ¶ added in v1.3.0
GetDataLen returns the length in bytes of the target PublicKey.
func (*PublicKey) MarshalBinary ¶
MarshalBinary encodes a PublicKey in a byte slice.
func (*PublicKey) UnmarshalBinary ¶ added in v1.3.0
UnmarshalBinary decodes a previously marshaled PublicKey in the target PublicKey.
type Rotation ¶ added in v1.3.0
type Rotation int
Rotation is a type used to represent the rotations types.
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 ¶ added in v1.3.0
func NewRotationKeys() (rotKey *RotationKeys)
NewRotationKeys returns a new empty RotationKeys struct.
func (*RotationKeys) GetDataLen ¶ added in v1.3.0
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 struct in a byte slice.
func (*RotationKeys) SetRotKey ¶ added in v1.3.0
func (rotKey *RotationKeys) SetRotKey(rotType Rotation, k uint64, evakey [][2]*ring.Poly)
SetRotKey populates the target RotationKeys with a new SwitchingKey using the input polynomials.
func (*RotationKeys) UnmarshalBinary ¶ added in v1.3.0
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 ¶ added in v1.3.0
func NewSecretKey(params *Parameters) *SecretKey
NewSecretKey generates a new SecretKey with zero values.
func (*SecretKey) GetDataLen ¶ added in v1.3.0
GetDataLen returns the length in bytes of the target SecretKey.
func (*SecretKey) MarshalBinary ¶
MarshalBinary encodes a secret key in a byte slice.
func (*SecretKey) UnmarshalBinary ¶ added in v1.3.0
UnmarshalBinary decodes a previously marshaled SecretKey in the target SecretKey.
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 ¶ added in v1.3.0
func NewSwitchingKey(params *Parameters) (evakey *SwitchingKey)
NewSwitchingKey returns a new SwitchingKey with zero values.
func (*SwitchingKey) Get ¶ added in v1.3.0
func (swk *SwitchingKey) Get() [][2]*ring.Poly
Get returns the switching key backing slice.
func (*SwitchingKey) GetDataLen ¶ added in v1.3.0
func (switchkey *SwitchingKey) GetDataLen(WithMetadata bool) (dataLen uint64)
GetDataLen returns the length in bytes of the target SwitchingKey.
func (*SwitchingKey) MarshalBinary ¶ added in v1.1.0
func (switchkey *SwitchingKey) MarshalBinary() (data []byte, err error)
MarshalBinary encodes an SwitchingKey in a byte slice.
func (*SwitchingKey) UnmarshalBinary ¶ added in v1.3.0
func (switchkey *SwitchingKey) UnmarshalBinary(data []byte) (err error)
UnmarshalBinary decode a previously marshaled SwitchingKey in the target SwitchingKey.