29 #ifndef CRYPTO_PROVIDER_HEADER_GUARD
30 #define CRYPTO_PROVIDER_HEADER_GUARD
56 template <
typename T_PublicKey,
typename T_PrivateKey,
typename T_Ciphertext,
typename T_Randomizer>
81 virtual T_Ciphertext
EncryptInteger (
const BigInteger &plaintext)
const;
84 virtual BigInteger
DecryptInteger (
const T_Ciphertext &ciphertext)
const = 0;
95 #ifdef ENABLE_CRYPTO_PROVIDER_HOMOMORPHIC_OPERATIONS
96 T_Ciphertext HomomorphicAdd (
const T_Ciphertext &lhs,
const T_Ciphertext &rhs)
const;
100 T_Ciphertext GetHomomorphicInverse (
const T_Ciphertext &input)
const;
103 T_Ciphertext HomomorphicSubtract (
const T_Ciphertext &lhs,
const T_Ciphertext &rhs)
const;
106 T_Ciphertext HomomorphicMultiply (
const T_Ciphertext &lhs,
const BigInteger &rhs)
const;
186 #endif//CRYPTO_PROVIDER_HEADER_GUARD
T_Ciphertext Ciphertext
Provide public access to the T_Ciphertext type.
Ciphertext GetEncryptedOne(const bool randomized=true) const
Returns [1].
Ciphertext GetEncryptedZero(const bool randomized=true) const
Returns [0].
const T_PublicKey & GetPublicKey() const
Public key getter.
RandomizerCache< RandomizerContainer< CryptoProvider< T_PublicKey, T_PrivateKey, T_Ciphertext, T_Randomizer >, RandomizerCacheParameters > > RandomizerCacheType
Data type of the randomizer cache.
unsigned int keyLength
The key length in bits.
Definition of template class RandomizerCache.
virtual size_t GetMessageSpaceSize() const =0
Returns the message space bit size.
Randomizer cache parameter container struct.
virtual T_Ciphertext EncryptInteger(const BigInteger &plaintext) const
Encrypt an integer and apply randomization.
T_PrivateKey privateKey
Private key container.
virtual const BigInteger & GetPositiveNegativeBoundary() const
Returns the biggest positive number that can be encrypted without overflowing.
T_Ciphertext encryptedZero
Contains [0] used as initializer for homomorphic addition accumulators. Precompute it for optimizatio...
Definition of struct RandomizerContainer.
const T_PrivateKey & GetPrivateKey() const
Private key getter.
Definition of struct RandomizerBase.
virtual BigInteger DecryptInteger(const T_Ciphertext &ciphertext) const =0
Decrypt an integer.
std::unique_ptr< RandomizerCacheType > randomizerCache
Lazy loading randomizer cache.
virtual ~CryptoProvider()
Destructor.
Implementation of template abstract class CryptoProvider. To be included in crypto_provider.h.
Definition of struct RandomizerCacheParameters.
bool precomputeSpeedupValues
Boolean flag that indicates wether doPrecomputations() should precompute certain values.
virtual const BigInteger & GetMessageSpaceUpperBound() const =0
Returns the message space upper bound.
virtual T_Randomizer GetRandomizer() const =0
Compute the random factor required for the encryption operation.
T_Ciphertext encryptedOne
Contains [1].
BigInteger positiveNegativeBoundary
Contains the delimiter between positive and negative values in the message space (usually ) ...
T_Randomizer Randomizer
Provide public access to the T_Randomizer type.
const BigInteger & GetEncryptionModulus() const
Returns the modulus required for reducing the encryption after randomization.
T_PublicKey publicKey
Public key container.
Template abstract base class for homomorphic encryption primitives.
virtual void doPrecomputations()=0
Computes the required precomputed values.
virtual bool GenerateKeys()=0
Generate the public and private keys required by the encryption primitive.
Definition of template class CiphertextBase.
std::shared_ptr< BigInteger > encryptionModulus
The encryption modulus.
virtual void validateParameters()=0
Validates configuration parameters.
bool hasPrivateKey
Boolean flag that enables decryption if the private key is present.
CryptoProvider(const unsigned int keyLength)
Constructor.
virtual T_Ciphertext EncryptIntegerNonrandom(const BigInteger &plaintext) const =0
Encrypt number without randomization.
virtual T_Ciphertext RandomizeCiphertext(const T_Ciphertext &ciphertext) const =0
Randomize encrypted number with a self-generated random value.