SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
data_packing/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/cpu_timer.h"
35 #include "core/big_integer.h"
36 #include "core/random_provider.h"
37 #include "core/paillier.h"
39 
41 
42 
43 //include C++ libraries
44 #include <string>
45 #include <deque>
46 #include <stdexcept>
47 
48 namespace SeComLib {
49 using namespace Core;
50 using namespace PrivateRecommendationsUtils;
51 
52 //hackish way of computing everything for only a single user (see also client.h)
53 #define FIRST_USER_ONLY
54 
55 namespace PrivateRecommendationsDataPacking {
56  //forward-declare required classes
57  class PrivacyServiceProvider;
58 
63  public:
65  typedef std::deque<Paillier::Ciphertext> EncryptedUserData;
66 
68  typedef std::deque<EncryptedUserData> EncryptedUserDataContainer;
69 
71  typedef std::deque<Paillier::Ciphertext> PackedData;
72 
74  typedef std::deque<PackedData> PackedItems;
75 
77  typedef std::deque<PackedItems> PackedItemContainer;
78 
80  ServiceProvider (const PaillierPublicKey &paillierPublicKey, const DgkPublicKey &dgkPublicKey);
81 
84 
86  void GenerateDummyDatabase (const EncryptedUserDataContainer &normalizedScaledRatings);
87 
89  void ComputeSimilarityValues (const EncryptedUserDataContainer &normalizedScaledRatings);
90 
92  void ComputeUserRecommendations (const PackedItems &sparseRatings);
93 
95  const Paillier::Ciphertext &GetEncryptedL (const size_t userId) const;
96 
98  const PackedData &GetEncryptedURSum (const size_t userId) const;
99 
100  #if 0
101  const PackedData ComputeURSum (const size_t userId, const PackedData &userPackedSparseRatings) const;
103  #endif
104 
106  void SetPrivacyServiceProvider (const std::shared_ptr<const PrivacyServiceProvider> &privacyServiceProvider);
107 
109  size_t GetBucketSize () const;
110 
112  size_t GetMaxPackedBuckets () const;
113 
115  const std::shared_ptr<SecureComparisonServer> &GetSecureComparisonServer () const;
116 
118  const std::shared_ptr<SecureMultiplicationServer<Paillier>> &GetSecureMultiplicationServer () const;
119 
120  private:
122  std::weak_ptr<const PrivacyServiceProvider> privacyServiceProvider;
123 
126 
129 
131  size_t userCount;
132 
134  size_t itemCount;
135 
138 
141 
143  unsigned int digitsToPreserve;
144 
146  size_t kappa;
147 
149  BigInteger similarityTreshold;
150 
152  size_t bucketSize;
153 
156 
158  std::deque<BigInteger> emptyBuckets;
159 
162 
165 
168 
171 
173  std::shared_ptr<SecureComparisonServer> secureComparisonServer;
174 
176  std::shared_ptr<SecureMultiplicationServer<Paillier>> secureMultiplicationServer;
177 
179  static const std::string configurationPath;
180 
183 
185  ServiceProvider operator= (ServiceProvider const &);
186  };
187 }//namespace PrivateRecommendationsDataPacking
188 }//namespace SeComLib
189 
190 #endif//SERVICE_PROVIDER_HEADER_GUARD
Implementation of the public-key DGK Cryptosystem.
Definition: dgk.h:104
Definition of class SecureComparisonServer.
std::deque< EncryptedUserData > EncryptedUserDataContainer
Container for encrypted user data.
std::deque< Paillier::Ciphertext > EncryptedUserData
Encrypted user data.
Defines BigInteger.
EncryptedUserData LValues
Vector of values, where L is the number of users similar to a given user.
Definition of class Config.
The public key container structure for the Dgk cryptosystem.
Definition: dgk.h:47
std::weak_ptr< const PrivacyServiceProvider > privacyServiceProvider
A reference to the PrivacyServiceProvider.
PackedItems URSumContainer
Contains the vectors for each user.
Definition of template class SecureMultiplicationServer.
Implementation of the public-key Paillier Cryptosystem.
Definition: paillier.h:103
Definition of class CpuTimer.
std::shared_ptr< SecureComparisonServer > secureComparisonServer
A reference to the SecureComparisonServer.
size_t scaledNormalizedRatingBitSize
k - The size of the scaled normalized ratings (in bits) (should be l / 2?)
size_t kappa
The security parameter for the secure comparison protocol (in bits)
Defines RandomProvider.
BigInteger similarityTreshold
- Scaled public threshold value for the similarity values
EncryptedUserDataContainer gamma
- the encrypted gamma values for every user (the upper triangle of the matrix, excluding the diagona...
Definition of class Paillier.
std::deque< PackedItems > PackedItemContainer
Container for packed items.
static const std::string configurationPath
Service Provider configuration path.
size_t maxPackedBuckets
The maximum number of buckets that fit in one encryption.
std::shared_ptr< SecureMultiplicationServer< Paillier > > secureMultiplicationServer
A reference to the SecureMultiplicationServer.
unsigned int digitsToPreserve
Number of digits preserved from the normalized user ratings.
The public key container structure for the Paillier cryptosystem.
Definition: paillier.h:49