107 unsigned int primeLength = (
unsigned int)(this->
keyLength / 2);
110 this->
privateKey.
p = RandomProvider::GetInstance().GetMaxLengthRandomPrime(primeLength);
111 this->
privateKey.
q = RandomProvider::GetInstance().GetMaxLengthRandomPrime(primeLength);
118 this->
privateKey.
p = RandomProvider::GetInstance().GetMaxLengthRandomPrime(primeLength);
133 #ifdef USE_STANDARD_PAILLIER_ALGORITHM
178 throw std::runtime_error(
"This operation requires the private key.");
181 #ifdef USE_STANDARD_PAILLIER_ALGORITHM
227 #ifdef USE_STANDARD_PAILLIER_ALGORITHM
294 BigInteger
Paillier::L (
const BigInteger &input,
const BigInteger &d)
const {
297 output = (input - 1) / d;
325 catch (std::runtime_error) {
327 throw std::runtime_error(
"p and q are not coprime.");
PaillierCiphertext Ciphertext
Provide public access to the T_Ciphertext type.
BigInteger qTimesQInvModP
RandomizerCache< RandomizerContainer< CryptoProvider< PaillierPublicKey, PaillierPrivateKey, PaillierCiphertext, PaillierRandomizer >, RandomizerCacheParameters > > RandomizerCacheType
Data type of the randomizer cache.
virtual BigInteger DecryptInteger(const Ciphertext &ciphertext) const
Decrypt number.
BigInteger L(const BigInteger &input, const BigInteger &d) const
L function evaluator.
virtual const BigInteger & GetMessageSpaceUpperBound() const
Returns the message space upper bound.
unsigned int keyLength
The key length in bits.
virtual bool GenerateKeys()
virtual PaillierCiphertext EncryptInteger(const BigInteger &plaintext) const
Encrypt an integer and apply randomization.
PaillierPrivateKey privateKey
Private key container.
BigInteger nMinusOne
Contains .
Paillier()
Default constructor.
PaillierCiphertext()
Default constructor.
PaillierCiphertext encryptedZero
Contains [0] used as initializer for homomorphic addition accumulators. Precompute it for optimizatio...
virtual Ciphertext RandomizeCiphertext(const Ciphertext &ciphertext) const
Randomize encrypted number with a self-generated random value.
BigInteger pTimesPInvModQ
virtual size_t GetMessageSpaceSize() const
Returns the message space bit size.
virtual Ciphertext EncryptIntegerNonrandom(const BigInteger &plaintext) const
Encrypt number without randomization.
std::unique_ptr< RandomizerCacheType > randomizerCache
Lazy loading randomizer cache.
BigInteger nSquared
Contains .
virtual Randomizer GetRandomizer() const
Compute the random factor required for the encryption operation.
BigInteger data
The ciphertext data.
bool precomputeSpeedupValues
Boolean flag that indicates wether doPrecomputations() should precompute certain values.
CiphertextBase template class.
PaillierRandomizer()
Default constructor.
Definition of class Paillier.
PaillierCiphertext encryptedOne
Contains [1].
The randomizer type for Paillier.
BigInteger positiveNegativeBoundary
Contains the delimiter between positive and negative values in the message space (usually ) ...
PaillierRandomizer Randomizer
Provide public access to the T_Randomizer type.
const BigInteger & GetEncryptionModulus() const
Returns the modulus required for reducing the encryption after randomization.
PaillierPublicKey publicKey
Public key container.
Template abstract base class for homomorphic encryption primitives.
std::shared_ptr< BigInteger > encryptionModulus
The encryption modulus.
bool hasPrivateKey
Boolean flag that enables decryption if the private key is present.
virtual void doPrecomputations()
Precompute values for speedups.
The private key container structure for the Paillier cryptosystem.
The public key container structure for the Paillier cryptosystem.