rlwe

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const DefaultSigma = 3.2

DefaultSigma is the default error distribution standard deviation

View Source
const GaloisGen uint64 = 5

GaloisGen is an integer of order N=2^d modulo M=2N and that spans Z_M with the integer -1. The j-th ring automorphism takes the root zeta to zeta^(5j).

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.

View Source
const MinLogN = 4

MinLogN is the log2 of the smallest supported polynomial modulus degree (needed to ensure the NTT correctness).

Variables

View Source
var (
	// TestPN12QP109 is a set of default parameters with logN=12 and logQP=109
	TestPN12QP109 = ParametersLiteral{
		LogN:  12,
		Q:     []uint64{0x7ffffec001, 0x40002001},
		P:     []uint64{0x8000016001},
		Sigma: DefaultSigma,
	}
	// TestPN13QP218 is a set of default parameters with logN=13 and logQP=218
	TestPN13QP218 = ParametersLiteral{
		LogN:  13,
		Q:     []uint64{0x3fffffffef8001, 0x4000000011c001, 0x40000000120001},
		P:     []uint64{0x7ffffffffb4001},
		Sigma: DefaultSigma,
	}

	// TestPN14QP438 is a set of default parameters with logN=14 and logQP=438
	TestPN14QP438 = ParametersLiteral{
		LogN: 14,
		Q: []uint64{0x100000000060001, 0x80000000068001, 0x80000000080001,
			0x3fffffffef8001, 0x40000000120001, 0x3fffffffeb8001},
		P:     []uint64{0x80000000130001, 0x7fffffffe90001},
		Sigma: DefaultSigma,
	}

	// TestPN15QP880 is a set of default parameters with logN=15 and logQP=880
	TestPN15QP880 = ParametersLiteral{
		LogN: 15,
		Q: []uint64{0x7ffffffffe70001, 0x7ffffffffe10001, 0x7ffffffffcc0001,
			0x400000000270001, 0x400000000350001, 0x400000000360001,
			0x3ffffffffc10001, 0x3ffffffffbe0001, 0x3ffffffffbd0001,
			0x4000000004d0001, 0x400000000570001, 0x400000000660001},
		P:     []uint64{0xffffffffffc0001, 0x10000000001d0001, 0x10000000006e0001},
		Sigma: DefaultSigma,
	}
)

Functions

func CheckModuli

func CheckModuli(q, p []uint64, logN int) error

CheckModuli checks that the provided q and p correspond to a valid moduli chain

func GenModuli

func GenModuli(logN int, logQ, logP []int) (q, p []uint64, err error)

GenModuli generates a valid moduli chain from the provided moduli sizes.

func PopulateElementRandom

func PopulateElementRandom(prng utils.PRNG, params Parameters, el *Ciphertext)

PopulateElementRandom creates a new rlwe.Element with random coefficients

Types

type AdditiveShare

type AdditiveShare struct {
	Value ring.Poly
}

AdditiveShare is a type for storing additively shared values in Z_Q[X] (RNS domain)

func NewAdditiveShare

func NewAdditiveShare(params Parameters) *AdditiveShare

NewAdditiveShare instantiate a new additive share struct for the ring defined by the given parameters at maximum level.

func NewAdditiveShareAtLevel

func NewAdditiveShareAtLevel(params Parameters, level int) *AdditiveShare

NewAdditiveShareAtLevel instantiate a new additive share struct for the ring defined by the given parameters at level `level`.

type AdditiveShareBigint

type AdditiveShareBigint struct {
	Value []*big.Int
}

AdditiveShareBigint is a type for storing additively shared values in Z (positional domain)

func NewAdditiveShareBigint

func NewAdditiveShareBigint(params Parameters) *AdditiveShareBigint

NewAdditiveShareBigint instantiate a new additive share struct composed of big.Int elements

type Ciphertext

type Ciphertext struct {
	Value []*ring.Poly
}

Ciphertext is a generic type for RLWE ciphertext.

func GetSmallestLargest

func GetSmallestLargest(el0, el1 *Ciphertext) (smallest, largest *Ciphertext, sameDegree bool)

GetSmallestLargest returns the provided element that has the smallest degree as a first returned value and the largest degree as second return value. If the degree match, the order is the same as for the input.

func NewCiphertext

func NewCiphertext(params Parameters, degree, level int) *Ciphertext

NewCiphertext returns a new Element with zero values.

func NewCiphertextNTT

func NewCiphertextNTT(params Parameters, degree, level int) *Ciphertext

NewCiphertextNTT returns a new Element with zero values and the NTT flags set.

func (*Ciphertext) Copy

func (el *Ciphertext) Copy(ctxCopy *Ciphertext)

Copy copies the input element and its parameters on the target element.

func (*Ciphertext) CopyNew

func (el *Ciphertext) CopyNew() *Ciphertext

CopyNew creates a new element as a copy of the target element.

func (*Ciphertext) Degree

func (el *Ciphertext) Degree() int

Degree returns the degree of the target element.

func (*Ciphertext) El

func (el *Ciphertext) El() *Ciphertext

El returns a pointer to this Element

func (*Ciphertext) Level

func (el *Ciphertext) Level() int

Level returns the level of the target element.

func (*Ciphertext) RLWEElement

func (el *Ciphertext) RLWEElement() *Ciphertext

RLWEElement returns a pointer to this Element

func (*Ciphertext) Resize

func (el *Ciphertext) Resize(params Parameters, degree int)

Resize resizes the degree of the target element. Sets the NTT flag of the added poly equal to the NTT flag to the poly at degree zero.

func (*Ciphertext) SetValue

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

SetValue sets the input slice of polynomials as the value of the target element.

type Decryptor

type Decryptor interface {
	// Decrypt decrypts the ciphertext and write the result in ptOut.
	// The level of the output plaintext is min(ciphertext.Level(), plaintext.Level())
	// Output domain will match plaintext.Value.IsNTT value.
	Decrypt(ciphertext *Ciphertext, plaintext *Plaintext)
}

Decryptor is an interface generic RLWE encryption.

func NewDecryptor

func NewDecryptor(params Parameters, sk *SecretKey) Decryptor

NewDecryptor instantiates a new generic RLWE Decryptor.

type Encryptor

type Encryptor interface {
	// Encrypt encrypts the input plaintext and write the result on ctOut.
	// The encryption algorithm depends on the implementor.
	Encrypt(pt *Plaintext, ctOut *Ciphertext)

	// EncryptFromCRP encrypts the input plaintext and writes the result in ctOut.
	// The encryption algorithm depends on the implementor.
	EncryptFromCRP(pt *Plaintext, crp *ring.Poly, ctOut *Ciphertext)
}

Encryptor a generic RLWE encryption interface.

func NewEncryptor

func NewEncryptor(params Parameters, key interface{}) Encryptor

NewEncryptor instatiates a new generic RLWE Encryptor. The key argument can be either a *rlwe.PublicKey or a *rlwe.SecretKey.

func NewFastEncryptor

func NewFastEncryptor(params Parameters, key *PublicKey) Encryptor

NewFastEncryptor instantiates a new generic RLWE Encryptor. This encryptor's Encrypt method first encrypts zero in Q and then adds the plaintext. This method is faster than the normal encryptor but result in a noisier ciphertext.

type EvaluationKey

type EvaluationKey struct {
	Rlk  *RelinearizationKey
	Rtks *RotationKeySet
}

EvaluationKey is a type for storing generic RLWE public evaluation keys. An evaluation key is a union of a relinearization key and a set of rotation keys.

type KeyGenerator

type KeyGenerator interface {
	GenSecretKey() (sk *SecretKey)
	GenSecretKeyGaussian() (sk *SecretKey)
	GenSecretKeyWithDistrib(p float64) (sk *SecretKey)
	GenSecretKeySparse(hw int) (sk *SecretKey)
	GenPublicKey(sk *SecretKey) (pk *PublicKey)
	GenKeyPair() (sk *SecretKey, pk *PublicKey)
	GenKeyPairSparse(hw int) (sk *SecretKey, pk *PublicKey)
	GenRelinearizationKey(sk *SecretKey, maxDegree int) (evk *RelinearizationKey)
	GenSwitchingKey(skInput, skOutput *SecretKey) (newevakey *SwitchingKey)
	GenSwitchingKeyForGalois(galEl uint64, sk *SecretKey) (swk *SwitchingKey)
	GenRotationKeys(galEls []uint64, sk *SecretKey) (rks *RotationKeySet)
	GenSwitchingKeyForRotationBy(k int, sk *SecretKey) (swk *SwitchingKey)
	GenRotationKeysForRotations(ks []int, inclueSwapRows bool, sk *SecretKey) (rks *RotationKeySet)
	GenSwitchingKeyForRowRotation(sk *SecretKey) (swk *SwitchingKey)
	GenRotationKeysForInnerSum(sk *SecretKey) (rks *RotationKeySet)
}

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 KeySwitcher

type KeySwitcher struct {
	*Parameters

	Baseconverter *ring.FastBasisExtender
	Decomposer    *ring.Decomposer
	// contains filtered or unexported fields
}

KeySwitcher is a struct for RLWE key-switching.

func NewKeySwitcher

func NewKeySwitcher(params Parameters) *KeySwitcher

NewKeySwitcher creates a new KeySwitcher.

func (*KeySwitcher) DecomposeNTT

func (ks *KeySwitcher) DecomposeNTT(levelQ int, c2 *ring.Poly, PoolDecompQ, PoolDecompP []*ring.Poly)

DecomposeNTT applies the full RNS basis decomposition for all q_alpha_i on c2. Expects the IsNTT flag of c2 to correctly reflect the domain of c2. PoolDecompQ and PoolDecompQ are vectors of polynomials (mod Q and mod P) that store the special RNS decomposition of c2 (in the NTT domain)

func (*KeySwitcher) DecomposeSingleNTT

func (ks *KeySwitcher) DecomposeSingleNTT(level, beta int, c2NTT, c2InvNTT, c2QiQ, c2QiP *ring.Poly)

DecomposeSingleNTT takes the input polynomial c2 (c2NTT and c2InvNTT, respectively in the NTT and out of the NTT domain) modulo q_alpha_beta, and returns the result on c2QiQ are c2QiP the receiver polynomials respectively mod Q and mod P (in the NTT domain)

func (*KeySwitcher) KeyswitchHoisted

func (ks *KeySwitcher) KeyswitchHoisted(level int, PoolDecompQ, PoolDecompP []*ring.Poly, evakey *SwitchingKey, pool2Q, pool3Q, pool2P, pool3P *ring.Poly)

KeyswitchHoisted applies the key-switch to the decomposed polynomial c2 mod QP (PoolDecompQ and PoolDecompP) and divides the result by P, reducing the basis from QP to Q.

pool2 = dot(PoolDecompQ||PoolDecompP * evakey[0]) mod Q pool3 = dot(PoolDecompQ||PoolDecompP * evakey[1]) mod Q

func (*KeySwitcher) KeyswitchHoistedNoModDown

func (ks *KeySwitcher) KeyswitchHoistedNoModDown(level int, PoolDecompQ, PoolDecompP []*ring.Poly, evakey *SwitchingKey, pool2Q, pool3Q, pool2P, pool3P *ring.Poly)

KeyswitchHoistedNoModDown applies the key-switch to the decomposed polynomial c2 mod QP (PoolDecompQ and PoolDecompP)

pool2 = dot(PoolDecompQ||PoolDecompP * evakey[0]) mod QP pool3 = dot(PoolDecompQ||PoolDecompP * evakey[1]) mod QP

func (*KeySwitcher) ShallowCopy

func (ks *KeySwitcher) ShallowCopy() *KeySwitcher

ShallowCopy creates a copy of a KeySwitcher, only reallocating the memory pool.

func (*KeySwitcher) SwitchKeysInPlace

func (ks *KeySwitcher) SwitchKeysInPlace(level int, cx *ring.Poly, evakey *SwitchingKey, p0, p1 *ring.Poly)

SwitchKeysInPlace applies the general key-switching procedure of the form [c0 + cx*evakey[0], c1 + cx*evakey[1]] Will return the result in the same NTT domain as the input cx.

func (*KeySwitcher) SwitchKeysInPlaceNoModDown

func (ks *KeySwitcher) SwitchKeysInPlaceNoModDown(level int, cx *ring.Poly, evakey *SwitchingKey, pool2Q, pool2P, pool3Q, pool3P *ring.Poly)

SwitchKeysInPlaceNoModDown applies the key-switch to the polynomial cx :

pool2 = dot(decomp(cx) * evakey[0]) mod QP (encrypted input is multiplied by P factor) pool3 = dot(decomp(cx) * evakey[1]) mod QP (encrypted input is multiplied by P factor)

Expects the flag IsNTT of cx to correctly reflect the domain of cx.

type Parameters

type Parameters struct {
	// contains filtered or unexported fields
}

Parameters represents a set of generic RLWE parameters. Its fields are private and immutable. See ParametersLiteral for user-specified parameters.

func NewParameters

func NewParameters(logn int, q, p []uint64, sigma float64) (Parameters, error)

NewParameters returns a new set of generic RLWE parameters from the given ring degree logn, moduli q and p, and error distribution parameter sigma. It returns the empty parameters Parameters{} and a non-nil error if the specified parameters are invalid.

func NewParametersFromLiteral

func NewParametersFromLiteral(paramDef ParametersLiteral) (Parameters, error)

NewParametersFromLiteral instantiate a set of generic RLWE parameters from a ParametersLiteral specification. It returns the empty parameters Parameters{} and a non-nil error if the specified parameters are invalid.

func (Parameters) Alpha

func (p Parameters) Alpha() int

Alpha returns the number of moduli in in P

func (Parameters) Beta

func (p Parameters) Beta() int

Beta returns the number of element in the RNS decomposition basis: Ceil(lenQi / lenPi)

func (Parameters) CopyNew

func (p Parameters) CopyNew() Parameters

CopyNew makes a deep copy of the receiver and returns it.

func (Parameters) Equals

func (p Parameters) Equals(other Parameters) bool

Equals checks two Parameter structs for equality.

func (Parameters) GaloisElementForColumnRotationBy

func (p Parameters) GaloisElementForColumnRotationBy(k int) uint64

GaloisElementForColumnRotationBy returns the galois element for plaintext column rotations by k position to the left. Providing a negative k is equivalent to a right rotation.

func (Parameters) GaloisElementForRowRotation

func (p Parameters) GaloisElementForRowRotation() uint64

GaloisElementForRowRotation returns the galois element for generating the row rotation automorphism

func (Parameters) GaloisElementsForRowInnerSum

func (p Parameters) GaloisElementsForRowInnerSum() (galEls []uint64)

GaloisElementsForRowInnerSum returns a list of all galois elements required to perform an InnerSum operation. This corresponds to all the left rotations by k-positions where k is a power of two and the row-rotation element.

func (Parameters) InverseGaloisElement

func (p Parameters) InverseGaloisElement(galEl uint64) uint64

InverseGaloisElement takes a galois element and returns the galois element

corresponding to the inverse automorphism

func (Parameters) LogN

func (p Parameters) LogN() int

LogN returns the log of the degree of the polynomial ring

func (Parameters) LogP

func (p Parameters) LogP() int

LogP returns the size of the extended modulus P in bits

func (Parameters) LogQ

func (p Parameters) LogQ() int

LogQ returns the size of the extended modulus Q in bits

func (Parameters) LogQP

func (p Parameters) LogQP() int

LogQP returns the size of the extended modulus QP in bits

func (Parameters) MarshalBinary

func (p Parameters) MarshalBinary() ([]byte, error)

MarshalBinary returns a []byte representation of the parameter set.

func (Parameters) MarshalBinarySize

func (p Parameters) MarshalBinarySize() int

MarshalBinarySize returns the length of the []byte encoding of the reciever.

func (Parameters) MarshalJSON

func (p Parameters) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON representation of this parameter set. See `Marshal` from the `encoding/json` package.

func (Parameters) MaxLevel

func (p Parameters) MaxLevel() int

MaxLevel returns the maximum level of a ciphertext

func (Parameters) N

func (p Parameters) N() int

N returns the ring degree

func (Parameters) P

func (p Parameters) P() []uint64

P returns a new slice with the factors of the ciphertext modulus extension P

func (Parameters) PBigInt

func (p Parameters) PBigInt() *big.Int

PBigInt return the ciphertext-space extention modulus P in big.Integer, reconstructed, representation.

func (Parameters) PCount

func (p Parameters) PCount() int

PCount returns the number of factors of the ciphertext modulus extension P

func (*Parameters) PiOverflowMargin

func (p *Parameters) PiOverflowMargin() int

PiOverflowMargin returns floor(2^64 / max(Pi)), i.e. the number of times elements of Z_max{Pi} can be added together before overflowing 2^64.

func (Parameters) Q

func (p Parameters) Q() []uint64

Q returns a new slice with the factors of the ciphertext modulus q

func (Parameters) QBigInt

func (p Parameters) QBigInt() *big.Int

QBigInt return the ciphertext-space modulus Q in big.Integer, reconstructed, representation.

func (Parameters) QCount

func (p Parameters) QCount() int

QCount returns the number of factors of the ciphertext modulus Q

func (Parameters) QP

func (p Parameters) QP() []uint64

QP return the extended ciphertext-space modulus QP in RNS representation.

func (Parameters) QPBigInt

func (p Parameters) QPBigInt() *big.Int

QPBigInt return the extended ciphertext-space modulus QP in big.Integer, reconstructed, representation.

func (Parameters) QPCount

func (p Parameters) QPCount() int

QPCount returns the number of factors of the ciphertext modulus + the modulus extension P

func (*Parameters) QiOverflowMargin

func (p *Parameters) QiOverflowMargin(level int) int

QiOverflowMargin returns floor(2^64 / max(Qi)), i.e. the number of times elements of Z_max{Qi} can be added together before overflowing 2^64.

func (Parameters) RingP

func (p Parameters) RingP() *ring.Ring

RingP returns a pointer to ringP

func (Parameters) RingQ

func (p Parameters) RingQ() *ring.Ring

RingQ returns a pointer to ringQ

func (Parameters) RingQP

func (p Parameters) RingQP() *ring.Ring

RingQP returns a pointer to ringQP

func (Parameters) Sigma

func (p Parameters) Sigma() float64

Sigma returns standard deviation of the noise distribution

func (*Parameters) UnmarshalBinary

func (p *Parameters) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes a []byte into a parameter set struct.

func (*Parameters) UnmarshalJSON

func (p *Parameters) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON reads a JSON representation of a parameter set into the receiver Parameter. See `Unmarshal` from the `encoding/json` package.

type ParametersLiteral

type ParametersLiteral struct {
	LogN  int
	Q     []uint64
	P     []uint64
	LogQ  []int `json:",omitempty"`
	LogP  []int `json:",omitempty"`
	Sigma float64
}

ParametersLiteral is a literal representation of BFV parameters. It has public fields and is used to express unchecked user-defined parameters literally into Go programs. The NewParametersFromLiteral function is used to generate the actual checked parameters from the literal representation.

type Plaintext

type Plaintext struct {
	Value *ring.Poly
}

Plaintext is a common base type for RLWE plaintexts.

func NewPlaintext

func NewPlaintext(params Parameters, level int) *Plaintext

NewPlaintext creates a new Plaintext at level `level` from the parameters.

func (*Plaintext) Copy

func (pt *Plaintext) Copy(other *Plaintext)

Copy copies the `other` plaintext value into the reciever plaintext.

func (Plaintext) Degree

func (pt Plaintext) Degree() int

Degree returns the degree of the target element.

func (Plaintext) El

func (pt Plaintext) El() *Ciphertext

El returns the plaintext as a new `Element` for which the value points to the receiver `Value` field.

func (Plaintext) Level

func (pt Plaintext) Level() int

Level returns the level of the target element.

type PublicKey

type PublicKey struct {
	Value [2]*ring.Poly
}

PublicKey is a type for generic RLWE public keys.

func NewPublicKey

func NewPublicKey(params Parameters) (pk *PublicKey)

NewPublicKey returns a new PublicKey with zero values.

func (*PublicKey) CopyNew

func (pk *PublicKey) CopyNew() *PublicKey

CopyNew creates a deep copy of the receiver PublicKey and returns it.

func (*PublicKey) Equals

func (pk *PublicKey) Equals(other *PublicKey) bool

Equals checks two PublicKey struct for equality.

func (*PublicKey) GetDataLen

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

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

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

UnmarshalBinary decodes a previously marshaled PublicKey in the target PublicKey.

type RelinearizationKey

type RelinearizationKey struct {
	Keys []*SwitchingKey
}

RelinearizationKey is a type for generic RLWE public relinearization keys. It stores a slice with a switching key per relinearizable degree. The switching key at index i is used to relinearize a degree i+2 ciphertexts back to a degree i + 1 one.

func NewRelinKey

func NewRelinKey(params Parameters, maxRelinDegree int) (evakey *RelinearizationKey)

NewRelinKey creates a new EvaluationKey with zero values.

func (*RelinearizationKey) CopyNew

func (rlk *RelinearizationKey) CopyNew() *RelinearizationKey

CopyNew creates a deep copy of the receiver RelinearizationKey and returns it.

func (*RelinearizationKey) Equals

func (rlk *RelinearizationKey) Equals(other *RelinearizationKey) bool

Equals checks two RelinearizationKeys for equality.

func (*RelinearizationKey) GetDataLen

func (rlk *RelinearizationKey) GetDataLen(WithMetadata bool) (dataLen int)

GetDataLen returns the length in bytes of the target EvaluationKey.

func (*RelinearizationKey) MarshalBinary

func (rlk *RelinearizationKey) MarshalBinary() (data []byte, err error)

MarshalBinary encodes an EvaluationKey key in a byte slice.

func (*RelinearizationKey) UnmarshalBinary

func (rlk *RelinearizationKey) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary decodes a previously marshaled EvaluationKey in the target EvaluationKey.

type RotationKeySet

type RotationKeySet struct {
	Keys map[uint64]*SwitchingKey
}

RotationKeySet is a type for storing generic RLWE public rotation keys. It stores a map indexed by the galois element defining the automorphism.

func NewRotationKeySet

func NewRotationKeySet(params Parameters, galoisElement []uint64) (rotKey *RotationKeySet)

NewRotationKeySet returns a new RotationKeySet with pre-allocated switching keys for each distinct galoisElement value.

func (*RotationKeySet) Equals

func (rtks *RotationKeySet) Equals(other *RotationKeySet) bool

Equals checks to RotationKeySets for equality.

func (*RotationKeySet) GetDataLen

func (rtks *RotationKeySet) GetDataLen(WithMetaData bool) (dataLen int)

GetDataLen returns the length in bytes of the target RotationKeys.

func (*RotationKeySet) GetRotationKey

func (rtks *RotationKeySet) GetRotationKey(galoisEl uint64) (*SwitchingKey, bool)

GetRotationKey return the rotation key for the given galois element or nil if such key is not in the set. The second argument is true iff the first one is non-nil.

func (*RotationKeySet) Includes

func (rtks *RotationKeySet) Includes(other *RotationKeySet) bool

Includes checks whether the receiver RotationKeySet includes the given other RotationKeySet.

func (*RotationKeySet) MarshalBinary

func (rtks *RotationKeySet) MarshalBinary() (data []byte, err error)

MarshalBinary encodes a RotationKeys struct in a byte slice.

func (*RotationKeySet) UnmarshalBinary

func (rtks *RotationKeySet) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary decodes a previously marshaled RotationKeys in the target RotationKeys.

type SecretKey

type SecretKey struct {
	Value *ring.Poly
}

SecretKey is a type for generic RLWE secret keys.

func NewSecretKey

func NewSecretKey(params Parameters) *SecretKey

NewSecretKey generates a new SecretKey with zero values.

func (*SecretKey) CopyNew

func (sk *SecretKey) CopyNew() *SecretKey

CopyNew creates a deep copy of the receiver secret key and returns it.

func (*SecretKey) GetDataLen

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

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

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

UnmarshalBinary decodes a previously marshaled SecretKey in the target SecretKey.

type SwitchingKey

type SwitchingKey struct {
	Value [][2]*ring.Poly
}

SwitchingKey is a type for generic RLWE public switching keys.

func NewSwitchingKey

func NewSwitchingKey(params Parameters) *SwitchingKey

NewSwitchingKey returns a new public switching key with pre-allocated zero-value

func (*SwitchingKey) CopyNew

func (swk *SwitchingKey) CopyNew() *SwitchingKey

CopyNew creates a deep copy of the receiver SwitchingKey and returns it.

func (*SwitchingKey) Equals

func (swk *SwitchingKey) Equals(other *SwitchingKey) bool

Equals checks two SwitchingKeys for equality.

func (*SwitchingKey) GetDataLen

func (swk *SwitchingKey) GetDataLen(WithMetadata bool) (dataLen int)

GetDataLen returns the length in bytes of the target SwitchingKey.

func (*SwitchingKey) MarshalBinary

func (swk *SwitchingKey) MarshalBinary() (data []byte, err error)

MarshalBinary encodes an SwitchingKey in a byte slice.

func (*SwitchingKey) UnmarshalBinary

func (swk *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