SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
okamoto_uchiyama.h
Go to the documentation of this file.
1 /*
2 SeComLib
3 Copyright 2012-2013 TU Delft, Information Security & Privacy Lab (http://isplab.tudelft.nl/)
4 
5 Contributors:
6 Inald Lagendijk (R.L.Lagendijk@TUDelft.nl)
7 Mihai Todor (todormihai@gmail.com)
8 Thijs Veugen (P.J.M.Veugen@tudelft.nl)
9 Zekeriya Erkin (z.erkin@tudelft.nl)
10 
11 Licensed under the Apache License, Version 2.0 (the "License");
12 you may not use this file except in compliance with the License.
13 You may obtain a copy of the License at
14 
15 http://www.apache.org/licenses/LICENSE-2.0
16 
17 Unless required by applicable law or agreed to in writing, software
18 distributed under the License is distributed on an "AS IS" BASIS,
19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 See the License for the specific language governing permissions and
21 limitations under the License.
22 */
29 #ifndef OKAMOTO_UCHIYAMA_HEADER_GUARD
30 #define OKAMOTO_UCHIYAMA_HEADER_GUARD
31 
32 #include "big_integer.h"
33 #include "random_provider.h"
34 #include "ciphertext_base.h"
35 #include "crypto_provider.h"
36 #include "utils/config.h"
37 
38 //include C++ headers
39 #include <stdexcept>
40 
41 namespace SeComLib {
42 namespace Core {
47  public:
49  BigInteger n;
51  BigInteger G;
53  BigInteger H;
54  };
55 
60  public:
62  BigInteger p;
64  BigInteger q;
66  BigInteger gp;
68  BigInteger t;
69  };
70 
74  class OkamotoUchiyamaCiphertext : public CiphertextBase<OkamotoUchiyamaCiphertext> {
75  public:
78 
80  OkamotoUchiyamaCiphertext (const std::shared_ptr<BigInteger> &encryptionModulus);
81 
83  OkamotoUchiyamaCiphertext (const BigInteger &data, const std::shared_ptr<BigInteger> &encryptionModulus);
84  };
85 
92 
94  OkamotoUchiyamaRandomizer (const BigInteger &data);
95  };
96 
100  class OkamotoUchiyama : public CryptoProvider<OkamotoUchiyamaPublicKey, OkamotoUchiyamaPrivateKey, OkamotoUchiyamaCiphertext, OkamotoUchiyamaRandomizer> {
101  public:
105  OkamotoUchiyama ();
106 
109 
112 
115 
116  /* Base class methods */
117 
119  virtual bool GenerateKeys ();
120 
122  virtual BigInteger DecryptInteger (const Ciphertext &ciphertext) const;
123 
125  virtual Ciphertext EncryptIntegerNonrandom (const BigInteger &plaintext) const;
126 
128  virtual Randomizer GetRandomizer () const;
129 
131  virtual Ciphertext RandomizeCiphertext (const Ciphertext &ciphertext) const;
132 
134  virtual const BigInteger &GetMessageSpaceUpperBound () const;
135 
137  virtual size_t GetMessageSpaceSize () const;
138 
139  /* /Base class methods */
140 
141  private:
143  BigInteger pSquared;
144 
146  BigInteger messageSpace;
147 
150 
152  BigInteger g;
153 
155  BigInteger lgpInv;
156 
158  BigInteger L (const BigInteger &input) const;
159 
160  /* Base class methods */
161 
163  virtual void validateParameters () {}
164 
166  virtual void doPrecomputations ();
167 
168  /* /Base class methods */
169 
172 
175  };
176 }//namespace Core
177 }//namespace SeComLib
178 
179 #endif//OKAMOTO_UCHIYAMA_HEADER_GUARD
virtual Randomizer GetRandomizer() const
Compute the random factor required for the encryption operation.
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.
Defines BigInteger.
RandomizerBase struct.
BigInteger pSquared
Contains , required for the decryption operation. Precompute it for optimization purposes.
Definition of class Config.
The randomizer type for Okamoto-Uchiyama.
BigInteger lgpInv
Stores precomputed value used to speedup decyption.
BigInteger data
The randomizer data.
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.
std::shared_ptr< BigInteger > encryptionModulus
The encryption modulus.
virtual size_t GetMessageSpaceSize() const
Returns the message space bit size.
Implementation of the public-key Okamoto-Uchiyama Cryptosystem.
The private key container structure for the Okamoto-Uchiyama cryptosystem.
virtual const BigInteger & GetMessageSpaceUpperBound() const
Returns the message space upper bound.
Defines RandomProvider.
CiphertextBase template class.
Definition of template abstract class CryptoProvider.
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.
Definition of template class CiphertextBase.
BigInteger messageSpace
The message space.
virtual void validateParameters()
Do nothing for now.
OkamotoUchiyama operator=(const OkamotoUchiyama &)
Copy assignment operator - not implemented.