Class LWEEncryptionScheme
Defined in File lwe-pke.h
Page Contents
Class Documentation
-
class lbcrypto::LWEEncryptionScheme
Additive public-key LWE scheme.
Public Functions
-
LWEEncryptionScheme() = default
-
LWEPrivateKey KeyGen(usint size, const NativeInteger &modulus) const
Generates a secret key of dimension n using modulus q
- Parameters
size – lattice parameter for the additive LWE scheme
modulus – the modulus for the secret key
- Returns
a shared pointer to the secret key
-
LWEPrivateKey KeyGenGaussian(usint size, const NativeInteger &modulus) const
Generates a secret key of dimension n using modulus q
- Parameters
size – lattice parameter for the additive LWE scheme
modulus – the modulus for the secret key
- Returns
a shared pointer to the secret key
Generates a public key of dimension N and modulus Q, secret key of dimension n using modulus q pair
- Parameters
params – a shared pointer to LWE scheme parameters
- Returns
a shared pointer to the public key, secret key pair
Generates a public key corresponding to a secret key of dimension N using modulus Q
- Parameters
params – a shared pointer to LWE scheme parameters
skN – a secret key of dimension N
- Returns
a shared pointer to the public key
Encrypts a bit using a secret key (symmetric key encryption)
- Parameters
params – a shared pointer to LWE scheme parameters
sk – the secret key
m – the plaintext
p – the plaintext space
mod – the ciphertext modulus to encrypt with; by default m_q in params
- Returns
a shared pointer to the ciphertext
Encrypts a bit using a public key (asymmetric key encryption)
- Parameters
params – a shared pointer to LWE scheme parameters
pk – the public key
m – the plaintext
p – the plaintext space
mod – the ciphertext modulus to encrypt with; by default m_q in params
- Returns
a shared pointer to the ciphertext
Converts a ciphertext (public key encryption) with modulus Q and dimension N to ciphertext with q and n
- Parameters
ksk – the key switching key from secret key of dimension N to secret key of dimension n
ct – the ciphertext to convert
- Returns
a shared pointer to the ciphertext
Decrypts the ciphertext using secret key sk
- Parameters
params – a shared pointer to LWE scheme parameters
sk – the secret key
ct – the ciphertext
result – plaintext result
p – the plaintext space
-
void EvalAddEq(LWECiphertext &ct1, ConstLWECiphertext &ct2) const
Adds the second ciphertext to the first ciphertext
- Parameters
ct1 – the ciphertext which will hold the sum
ct2 – the ciphertext to add
-
void EvalAddConstEq(LWECiphertext &ct, NativeInteger cnst) const
Adds the a constant to the ciphertext
- Parameters
ct – the ciphertext which will hold the sum
cnst – the constant to add
-
void EvalSubEq(LWECiphertext &ct1, ConstLWECiphertext &ct2) const
Subtracts the second ciphertext from the first ciphertext, the result is held in the first ciphertext
- Parameters
ct1 – the ciphertext which will hold the difference
ct2 – the ciphertext to subtract
-
void EvalSubEq2(ConstLWECiphertext &ct1, LWECiphertext &ct2) const
Subtracts the second ciphertext from the first ciphertext, the result is held in the first ciphertext
- Parameters
ct1 – the ciphertext from which to subtract
ct2 – the ciphertext to subtract, will hold the difference
-
void EvalSubConstEq(LWECiphertext &ct, NativeInteger cnst) const
Subtracts the constant from the ciphertext
- Parameters
ct1 – the ciphertext which will hold the difference
ct2 – the constant to subtract
-
void EvalMultConstEq(LWECiphertext &ct, NativeInteger cnst) const
Multiplies a ciphertext by a constant
- Parameters
ct1 – the ciphertext which will hold the product
ct2 – the constant to multiply by
-
LWECiphertext ModSwitch(NativeInteger q, ConstLWECiphertext &ctQ) const
Changes an LWE ciphertext modulo Q into an LWE ciphertext modulo q
- Parameters
q – modulus to
ctQ – the input ciphertext
- Returns
resulting ciphertext
Generates a switching key to go from a secret key with (Q,N) to a secret key with (q,n)
- Parameters
params – a shared pointer to LWE scheme parameters
sk – new secret key
skN – old secret key
- Returns
a shared pointer to the switching key
Switches ciphertext from (Q,N) to (Q,n)
- Parameters
params – a shared pointer to LWE scheme parameters
K – switching key
ctQN – input ciphertext
- Returns
a shared pointer to the resulting ciphertext
Embeds a plaintext bit without noise or encryption
- Parameters
params – a shared pointer to LWE scheme parameters
m – - the plaintext
- Returns
a shared pointer to the ciphertext
-
LWEEncryptionScheme() = default