bfv

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

BFV

The package BFV is an RNS-accelerated implementation of the Fan-Vercauteren version of Brakerski's scale invariant homomorphic encryption scheme. It provides modular arithmetic over the integers.

Brief description

This scheme can be used to do arithmetic over   equation.

The plaintext space and the ciphertext space share the same domain

,

with a power of 2.

The batch encoding of this scheme

maps an array of integers to a polynomial with the property:

,

where represents   ![equation](https://latex.codecogs.com/gif.latex?%24%5Codot%24)   a component-wise product,and   ![equation](https://latex.codecogs.com/gif.latex?%24%5Cotimes%24)   represents a nega-cyclic convolution.

Security parameters

equation: the ring dimension, which defines the degree of the cyclotomic polynomial, and the number of coefficients of the plaintext/ciphertext polynomials; it should always be a power of two. This parameter has an impact on both security and performance (security increases with N and performance decreases with N). It should be chosen carefully to suit the intended use of the scheme.

equation: the ciphertext modulus. In Lattigo, it is chosen to be the product of small coprime moduli equation verifying equation in order to enable both the RNS and NTT representation. The used moduli equation are chosen to be of size 50 to 60 bits for the best performance. This parameter has an impact on both security and performance (for a fixed equation, a higher equation implies both lower security and lower performance). It is closely related to equation and should be chosen carefully to suit the intended use of the scheme.

equation: the variance used for the error polynomials. This parameter is closely tied to the security of the scheme (a higher equation implies higher security).

Other parameters

equation: the extended ciphertext modulus. This modulus is used during the multiplication, and it has no impact on the security. It is also defined as the product of small coprime moduli equation and should be chosen such that equation by a small margin (~20 bits). This can be done by using one more small coprime modulus than equation.

equation: the plaintext modulus. This parameter defines the maximum value that a plaintext coefficient can take. If a computation leads to a higher value, this value will be reduced modulo the plaintext modulus. It can be initialized with any value, but in order to enable batching, it must be prime and verify equation. It has no impact on the security.

Choosing security parameters

The BFV scheme supports the standard recommended parameters chosen to offer a security of 128 bits for a secret key with uniform ternary distribution equation, according to the Homomorphic Encryption Standards group (https://homomorphicencryption.org/standard/).

Each set of parameters is defined by the tuple equation:

  • {11, 54, 3.2}
  • {12, 109, 3.2}
  • {13, 218, 3.2}
  • {14, 438, 3.2}
  • {15, 881, 3.2}

These parameter sets are hard-coded in the file params.go. By default the variance should always be set to 3.2 unless the user is perfectly aware of the security implications of changing this parameter.

Finally, it is worth noting that these security parameters are computed for fully entropic ternary keys (with probability distribution {1/3,1/3,1/3} for values {-1,0,1}). Lattigo uses this fully-entropic key configuration by default. It is possible, though, to generate keys with lower entropy, by modifying their distribution to {(1-p)/2, p, (1-p)/2}, for any p between 0 and 1, which for p>>1/3 can result in low Hamming weight keys (sparse keys). We recall that it has been shown that the security of sparse keys can be considerably lower than that of fully entropic keys, and the BFV security parameters should be re-evaluated if sparse keys are used.

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

View Source
const (
	RotationRight = iota + 1
	RotationLeft
	RotationRow
)

Constants for rotation types

View Source
const (
	PN12QP109 = iota
	PN13QP218
	PN14QP438
	PN15QP880
)
View Source
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.

View Source
const MaxLogN = 16

MaxLogN is the log2 of the largest supported polynomial modulus degree.

View Source
const MaxModuliCount = 34

MaxModuliCount is the largest supported number of moduli in the RNS representation.

View Source
const MaxModuliSize = 60

MaxModuliSize is the largest bit-length supported for the moduli in the RNS representation.

Variables

View Source
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

func GenLiftParams(context *ring.Context, t uint64) (deltaMont []uint64)

GenLiftParams generates the lifting parameters.

func GenModuli added in v1.3.0

func GenModuli(params *Parameters) (Q []uint64, P []uint64, QMul []uint64)

GenModuli generates the appropriate primes from the parameters using generateCKKSPrimes such that all primes are different.

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) Element added in v1.1.0

func (el Ciphertext) Element() *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

func (el Ciphertext) InvNTT(context *ring.Context, c *bfvElement)

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

func (el Ciphertext) NTT(context *ring.Context, c *bfvElement)

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) Plaintext added in v1.1.0

func (el Ciphertext) Plaintext() *Plaintext

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

func (el Ciphertext) SetValue(value []*ring.Poly)

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.

func (Ciphertext) Value

func (el Ciphertext) Value() []*ring.Poly

Value returns the value of the target bfvElement (as a slice of polynomials in CRT form).

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.

func (*LogModuli) Copy added in v1.3.0

func (m *LogModuli) Copy() LogModuli

Copy creates a copy of the target LogModuli.

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.

func (*Moduli) Copy added in v1.3.0

func (m *Moduli) Copy() Moduli

Copy creates a copy of the target Moduli.

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) Alpha added in v1.3.0

func (p *Parameters) Alpha() uint64

Alpha returns #Pi.

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) Element added in v1.1.0

func (el Plaintext) Element() *bfvElement

func (Plaintext) InvNTT

func (el Plaintext) InvNTT(context *ring.Context, c *bfvElement)

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

func (el Plaintext) NTT(context *ring.Context, c *bfvElement)

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) Plaintext added in v1.1.0

func (el Plaintext) Plaintext() *Plaintext

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.

func (Plaintext) SetValue

func (el Plaintext) SetValue(value []*ring.Poly)

SetValue assigns the input slice of polynomials to the target bfvElement value.

func (Plaintext) Value

func (el Plaintext) Value() []*ring.Poly

Value returns the value of the target bfvElement (as a slice of polynomials in CRT form).

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) Get

func (pk *PublicKey) Get() [2]*ring.Poly

Get returns the polynomials of the PublicKey.

func (*PublicKey) GetDataLen added in v1.3.0

func (pk *PublicKey) GetDataLen(WithMetadata bool) (dataLen uint64)

GetDataLen returns the length in bytes of the target PublicKey.

func (*PublicKey) MarshalBinary

func (pk *PublicKey) MarshalBinary() (data []byte, err error)

MarshalBinary encodes a PublicKey in a byte slice.

func (*PublicKey) Set

func (pk *PublicKey) Set(p [2]*ring.Poly)

Set sets the polynomial of the PublicKey as the input polynomials.

func (*PublicKey) UnmarshalBinary added in v1.3.0

func (pk *PublicKey) UnmarshalBinary(data []byte) (err error)

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) Get

func (sk *SecretKey) Get() *ring.Poly

Get returns the polynomial of the target SecretKey.

func (*SecretKey) GetDataLen added in v1.3.0

func (sk *SecretKey) GetDataLen(WithMetadata bool) (dataLen uint64)

GetDataLen returns the length in bytes of the target SecretKey.

func (*SecretKey) MarshalBinary

func (sk *SecretKey) MarshalBinary() (data []byte, err error)

MarshalBinary encodes a secret key in a byte slice.

func (*SecretKey) Set

func (sk *SecretKey) Set(poly *ring.Poly)

Set sets the polynomial of the target secret key as the input polynomial.

func (*SecretKey) UnmarshalBinary added in v1.3.0

func (sk *SecretKey) UnmarshalBinary(data []byte) (err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL