75 messageSpaceSize(Utils::Config::GetInstance().GetParameter<size_t>(
"Core.OkamotoUchiyama.messageSpaceSize")) {
85 messageSpaceSize(Utils::Config::GetInstance().GetParameter<size_t>(
"Core.OkamotoUchiyama.messageSpaceSize")) {
98 messageSpaceSize(Utils::Config::GetInstance().GetParameter<size_t>(
"Core.OkamotoUchiyama.messageSpaceSize")) {
114 unsigned int primeLength =
static_cast<unsigned int>(this->
keyLength / 3);
115 if (sizeT >= primeLength) {
117 throw std::runtime_error(
"Key size must be larger than the t parameter.");
123 this->
privateKey.
t = RandomProvider::GetInstance().GetMaxLengthRandomPrime(sizeT);
128 unsigned int sizeU = primeLength - sizeT;
131 u = RandomProvider::GetInstance().GetRandomInteger(sizeU - 1);
145 this->
privateKey.
q = RandomProvider::GetInstance().GetMaxLengthRandomPrime(primeLength);
157 this->
g = RandomProvider::GetInstance().GetRandomInteger(this->
publicKey.
n);
160 while (BigInteger::Gcd(this->
g, this->
privateKey.
p) != 1);
166 while (this->
privateKey.
gp.GetPowModN(this->privateKey.p, this->pSquared) != 1);
176 gPrime = RandomProvider::GetInstance().GetRandomInteger(this->
publicKey.
n);
179 while (BigInteger::Gcd(gPrime, this->
publicKey.
n) != 1);
203 throw std::runtime_error(
"This operation requires the private key.");
207 BigInteger output = (this->
L(ciphertext.
data.GetPowModN(this->privateKey.t, this->pSquared)) * this->
lgpInv) % this->
privateKey.
p;
OkamotoUchiyamaCiphertext Ciphertext
Provide public access to the T_Ciphertext type.
virtual Randomizer GetRandomizer() const
Compute the random factor required for the encryption operation.
RandomizerCache< RandomizerContainer< CryptoProvider< OkamotoUchiyamaPublicKey, OkamotoUchiyamaPrivateKey, OkamotoUchiyamaCiphertext, OkamotoUchiyamaRandomizer >, RandomizerCacheParameters > > RandomizerCacheType
Data type of the randomizer cache.
size_t messageSpaceSize
Contains the bit size of the message space.
virtual bool GenerateKeys()
Generate the public and private keys.
virtual void doPrecomputations()
Precompute values for speedups.
static Config & GetInstance()
Returns a reference to the singleton.
unsigned int keyLength
The key length in bits.
OkamotoUchiyamaCiphertext()
Default constructor.
BigInteger pSquared
Contains , required for the decryption operation. Precompute it for optimization purposes.
The randomizer type for Okamoto-Uchiyama.
virtual OkamotoUchiyamaCiphertext EncryptInteger(const BigInteger &plaintext) const
Encrypt an integer and apply randomization.
BigInteger lgpInv
Stores precomputed value used to speedup decyption.
OkamotoUchiyamaPrivateKey privateKey
Private key container.
OkamotoUchiyamaCiphertext encryptedZero
Contains [0] used as initializer for homomorphic addition accumulators. Precompute it for optimizatio...
OkamotoUchiyamaRandomizer()
Default constructor.
virtual Ciphertext RandomizeCiphertext(const Ciphertext &ciphertext) const
Randomize encrypted number with a self-generated random value.
virtual Ciphertext EncryptIntegerNonrandom(const BigInteger &plaintext) const
Encrypt number without randomization.
BigInteger t
, the prime factor of
BigInteger L(const BigInteger &input) const
L function evaluator.
BigInteger g
Stores , required for the decryption operation.
Definition of class OkamotoUchiyama.
virtual size_t GetMessageSpaceSize() const
Returns the message space bit size.
std::unique_ptr< RandomizerCacheType > randomizerCache
Lazy loading randomizer cache.
The private key container structure for the Okamoto-Uchiyama cryptosystem.
BigInteger data
The ciphertext data.
virtual const BigInteger & GetMessageSpaceUpperBound() const
Returns the message space upper bound.
bool precomputeSpeedupValues
Boolean flag that indicates wether doPrecomputations() should precompute certain values.
T GetParameter(const std::string ¶meter) const
Template method which returns the value of the specified configuration parameter. ...
CiphertextBase template class.
OkamotoUchiyamaCiphertext encryptedOne
Contains [1].
BigInteger positiveNegativeBoundary
Contains the delimiter between positive and negative values in the message space (usually ) ...
OkamotoUchiyamaRandomizer Randomizer
Provide public access to the T_Randomizer type.
const BigInteger & GetEncryptionModulus() const
Returns the modulus required for reducing the encryption after randomization.
OkamotoUchiyamaPublicKey publicKey
Public key container.
virtual BigInteger DecryptInteger(const Ciphertext &ciphertext) const
Decrypt number.
The public key container structure for the Okamoto-Uchiyama cryptosystem.
Template abstract base class for homomorphic encryption primitives.
Okamoto-Uchiyama cipertext.
std::shared_ptr< BigInteger > encryptionModulus
The encryption modulus.
BigInteger messageSpace
The message space.
bool hasPrivateKey
Boolean flag that enables decryption if the private key is present.