SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
service_provider.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 SERVICE_PROVIDER_HEADER_GUARD
30 #define SERVICE_PROVIDER_HEADER_GUARD
31 
32 //include our headers
33 #include "utils/config.h"
34 #include "utils/date_time.h"
35 #include "utils/cpu_timer.h"
36 #include "core/big_integer.h"
37 #include "core/random_provider.h"
38 #include "core/paillier.h"
39 #include "core/dgk.h"
41 
43 
44 
45 //include C++ libraries
46 #include <fstream>
47 #include <string>
48 #include <sstream>
49 #include <deque>
50 #include <stdexcept>
51 
52 namespace SeComLib {
53 
54 using namespace Core;
55 using namespace PrivateRecommendationsUtils;
56 
57 //hackish way of computing everything for only a single user (see also client.h)
58 #define FIRST_USER_ONLY
59 
60 namespace PrivateRecommendations {
61  //forward-declare required classes
62  class PrivacyServiceProvider;
63 
68  public:
70  typedef std::deque<Paillier::Ciphertext> EncryptedUserData;
71 
73  typedef std::deque<EncryptedUserData> EncryptedUserDataContainer;
74 
76  ServiceProvider (const PaillierPublicKey &paillierPublicKey, const DgkPublicKey &dgkPublicKey);
77 
80 
82  void GenerateDummyDatabase ();
83 
85  void ComputeSimilarityValues ();
86 
88  void ComputeUserRecommendations ();
89 
91  const Paillier::Ciphertext &GetEncryptedL (size_t userId) const;
92 
94  const EncryptedUserData &GetEncryptedURSum (size_t userId) const;
95 
97  void SetPrivacyServiceProvider (const std::shared_ptr<const PrivacyServiceProvider> &privacyServiceProvider);
98 
100  const std::shared_ptr<SecureComparisonServer> &GetSecureComparisonServer () const;
101 
103  const std::shared_ptr<SecureMultiplicationServer<Paillier>> &GetSecureMultiplicationServer () const;
104 
105  private:
107  std::weak_ptr<const PrivacyServiceProvider> privacyServiceProvider;
108 
111 
114 
116  size_t userCount;
117 
119  size_t itemCount;
120 
123 
126 
128  unsigned int digitsToPreserve;
129 
131  BigInteger similarityTreshold;
132 
134  std::string ratingsFilePath;
135 
138 
141 
144 
147 
150 
152  const std::shared_ptr<SecureComparisonServer> secureComparisonServer;
153 
155  std::shared_ptr<SecureMultiplicationServer<Paillier>> secureMultiplicationServer;
156 
158  static const std::string configurationPath;
159 
162 
164  ServiceProvider operator= (ServiceProvider const &);
165  };
166 }//namespace PrivateRecommendations
167 }//namespace SeComLib
168 
169 #endif//SERVICE_PROVIDER_HEADER_GUARD
Implementation of the public-key DGK Cryptosystem.
Definition: dgk.h:104
size_t ratingBitSize
The size of the user ratings (in bits)
Definition of class Dgk.
std::string ratingsFilePath
The path to the file containing precomputed ratings.
size_t denselyRatedItemCount
Number of densely rated items.
std::deque< Paillier::Ciphertext > EncryptedUserData
Encrypted user data.
Defines BigInteger.
size_t itemCount
Number of ratings per user.
Definition of class Config.
The public key container structure for the Dgk cryptosystem.
Definition: dgk.h:47
BigInteger similarityTreshold
- Scaled public threshold value for the similarity values
EncryptedUserData LValues
Vector of values, where L is the number of users similar to a given user.
Paillier paillierCryptoProvider
Paillier crypto provider.
static const std::string configurationPath
Service Provider configuration path.
unsigned int digitsToPreserve
Number of digits preserved from the normalized user ratings.
~ServiceProvider()
Destructor - void implementation.
Definition of template class SecureMultiplicationServer.
size_t userCount
Number of users who need recommendations.
EncryptedUserDataContainer URSumContainer
Contains the vectors for each user.
Definition of class DateTime.
Definition of class SecureComparisonServer.
Implementation of the public-key Paillier Cryptosystem.
Definition: paillier.h:103
std::shared_ptr< SecureMultiplicationServer< Paillier > > secureMultiplicationServer
A reference to the SecureMultiplicationServer.
Definition of class CpuTimer.
const std::shared_ptr< SecureComparisonServer > secureComparisonServer
A reference to the SecureComparisonServer.
Defines RandomProvider.
Definition of class Paillier.
The public key container structure for the Paillier cryptosystem.
Definition: paillier.h:49
std::deque< EncryptedUserData > EncryptedUserDataContainer
Container for encrypted user data.
std::weak_ptr< const PrivacyServiceProvider > privacyServiceProvider
A reference to the PrivacyServiceProvider.