SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
dgk.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 DGK_HEADER_GUARD
30 #define DGK_HEADER_GUARD
31 
32 #include "big_integer.h"
33 #include "ciphertext_base.h"
34 #include "crypto_provider.h"
35 #include "random_provider.h"
36 #include "utils/config.h"
37 
38 //include C++ headers
39 #include <stdexcept>
40 #include <map>
41 
42 namespace SeComLib {
43 namespace Core {
47  struct DgkPublicKey {
48  public:
50  BigInteger n;
52  BigInteger g;
54  BigInteger h;
56  BigInteger u;
57  };
58 
62  struct DgkPrivateKey {
63  public:
65  BigInteger p;
67  BigInteger q;
69  BigInteger vp;
71  BigInteger vq;
72  };
73 
77  class DgkCiphertext : public CiphertextBase<DgkCiphertext> {
78  public:
80  DgkCiphertext ();
81 
83  DgkCiphertext (const std::shared_ptr<BigInteger> &encryptionModulus);
84 
86  DgkCiphertext (const BigInteger &data, const std::shared_ptr<BigInteger> &encryptionModulus);
87  };
88 
92  struct DgkRandomizer : public RandomizerBase {
94  DgkRandomizer ();
95 
97  DgkRandomizer (const BigInteger &data);
98  };
99 
104  class Dgk : public CryptoProvider<DgkPublicKey, DgkPrivateKey, DgkCiphertext, DgkRandomizer> {
105  public:
108  Dgk (const bool precomputeDecryptionMap = false);
109 
111  Dgk (const DgkPublicKey &publicKey);
112 
114  Dgk (const DgkPublicKey &publicKey, const DgkPrivateKey &privateKey, const bool precomputeDecryptionMap = false);
115 
117  ~Dgk () {}
118 
119  /* Base class methods */
120 
122  virtual bool GenerateKeys ();
123 
126  virtual BigInteger DecryptInteger (const Ciphertext &ciphertext) const;
127 
129  virtual Ciphertext EncryptIntegerNonrandom (const BigInteger &plaintext) const;
130 
132  virtual Randomizer GetRandomizer () const;
133 
135  virtual Ciphertext RandomizeCiphertext (const Ciphertext &ciphertext) const;
136 
138  virtual const BigInteger &GetMessageSpaceUpperBound () const;
139 
141  virtual size_t GetMessageSpaceSize () const;
142 
143  /* /Base class methods */
144 
146  bool IsEncryptedZero (const Ciphertext &ciphertext) const;
147 
148  private:
150  typedef std::map<const BigInteger, BigInteger> DecryptionMap;
151 
153  const unsigned int t;
154 
156  const unsigned int l;
157 
160 
163 
165  BigInteger pTimesPInvModQ;
167  BigInteger qTimesQInvModP;
168 
169  /* Base class methods */
170 
172  virtual void validateParameters ();
173 
175  virtual void doPrecomputations ();
176 
177  /* /Base class methods */
178 
180  Dgk (const Dgk &);
181 
183  Dgk operator= (const Dgk &);
184  };
185 }//namespace Core
186 }//namespace SeComLib
187 
188 #endif//DGK_HEADER_GUARD
DgkCiphertext Ciphertext
Provide public access to the T_Ciphertext type.
Implementation of the public-key DGK Cryptosystem.
Definition: dgk.h:104
DecryptionMap decryptionMap
Contains all possible values of , where , and it is required for decryption.
Definition: dgk.h:162
virtual void validateParameters()
Validate configuration parameters.
Definition: dgk.cpp:476
Dgk(const bool precomputeDecryptionMap=false)
Definition: dgk.cpp:78
virtual size_t GetMessageSpaceSize() const
Returns the message space bit size.
Definition: dgk.cpp:451
~Dgk()
Destructor.
Definition: dgk.h:117
Defines BigInteger.
RandomizerBase struct.
BigInteger qTimesQInvModP
Contains .
Definition: dgk.h:167
Definition of class Config.
The public key container structure for the Dgk cryptosystem.
Definition: dgk.h:47
virtual void doPrecomputations()
Precompute values for speedups.
Definition: dgk.cpp:507
virtual Ciphertext RandomizeCiphertext(const Ciphertext &ciphertext) const
Randomize encrypted number with a self-generated random value.
Definition: dgk.cpp:437
virtual Ciphertext EncryptIntegerNonrandom(const BigInteger &plaintext) const
Encrypt number without randomization.
Definition: dgk.cpp:356
BigInteger data
The randomizer data.
The randomizer type for DGK.
Definition: dgk.h:92
DgkRandomizer()
Default constructor.
Definition: dgk.cpp:61
virtual const BigInteger & GetMessageSpaceUpperBound() const
Returns the message space upper bound.
Definition: dgk.cpp:444
Dgk operator=(const Dgk &)
Copy assignment operator - not implemented.
virtual Randomizer GetRandomizer() const
Compute the random factor required for the encryption operation.
Definition: dgk.cpp:402
const unsigned int l
Parameter .
Definition: dgk.h:156
std::shared_ptr< BigInteger > encryptionModulus
The encryption modulus.
bool IsEncryptedZero(const Ciphertext &ciphertext) const
Determines if ciphertext contains an encryption of 0 or not.
Definition: dgk.cpp:463
bool precomputeDecryptionMap
If true, full decryptions are enabled and the decryption map is (pre)computed.
Definition: dgk.h:159
virtual BigInteger DecryptInteger(const Ciphertext &ciphertext) const
Definition: dgk.cpp:309
virtual bool GenerateKeys()
Generate the public and private keys.
Definition: dgk.cpp:161
Defines RandomProvider.
CiphertextBase template class.
The private key container structure for the Dgk cryptosystem.
Definition: dgk.h:62
DgkRandomizer Randomizer
Provide public access to the T_Randomizer type.
Definition of template abstract class CryptoProvider.
BigInteger u
- The message space upper bound
Definition: dgk.h:56
Template abstract base class for homomorphic encryption primitives.
DgkCiphertext()
Default constructor.
Definition: dgk.cpp:38
Definition of template class CiphertextBase.
DGK cipertext.
Definition: dgk.h:77
const unsigned int t
Parameter .
Definition: dgk.h:153
BigInteger pTimesPInvModQ
Contains .
Definition: dgk.h:165
std::map< const BigInteger, BigInteger > DecryptionMap
std::map template specialization
Definition: dgk.h:150