SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
private_recommendations_data_packing/client.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 CLIENT_HEADER_GUARD
30 #define CLIENT_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/paillier.h"
37 #include "core/randomizer_cache.h"
39 
41 #include "service_provider.h"
43 
44 //include C++ libraries
45 #include <fstream>
46 #include <string>
47 #include <sstream>
48 #include <deque>
49 #include <stdexcept>
50 
51 namespace SeComLib {
52 using namespace Core;
53 using namespace PrivateRecommendationsUtils;
54 
55 //hackish way of computing everything for only a single user (see also service_provider.h)
56 #define FIRST_USER_ONLY
57 
58 namespace PrivateRecommendationsDataPacking {
62  class Client {
63  public:
64 
66  Client (const std::shared_ptr<ServiceProvider> &serviceProvider, const std::shared_ptr<PrivacyServiceProvider> &privacyServiceProvider, const PaillierPublicKey &publicKey);
67 
69  ~Client () {}
70 
72  const ServiceProvider::EncryptedUserDataContainer &GetNormalizedScaledRatings () const;
73 
75  const ServiceProvider::PackedItems &GetSparseRatings () const;
76 
78  void ComputeRecommendations ();
79 
80  private:
83 
85  const std::shared_ptr<ServiceProvider> serviceProvider;
86 
88  const std::shared_ptr<PrivacyServiceProvider> privacyServiceProvider;
89 
92 
94  static const std::string configurationPath;
95 
97  size_t userCount;
98 
100  size_t itemCount;
101 
104 
107 
110 
112  unsigned int digitsToPreserve;
113 
115  size_t kappa;
116 
118  size_t hatL;
119 
121  std::deque<BigInteger> emptyBuckets;
122 
124  std::string ratingsFilePath;
125 
128 
130  std::deque<std::deque<unsigned long>> plaintextSparseRatings;
131 
134 
137 
140 
142  std::deque<BigInteger> computeEmptyBuckets (const size_t L) const;
143 
145  ServiceProvider::PackedData packUserSparseRatings (const std::deque<unsigned long> &userPlaintextSparseRatings, const std::deque<BigInteger> &userEmptyBuckets) const;
146 
148  Client (Client const &);
149 
151  Client operator= (Client const &);
152  };
153 }//namespace PrivateRecommendationsDataPacking
154 }//namespace SeComLib
155 
156 #endif//CLIENT_HEADER_GUARD
std::deque< BigInteger > emptyBuckets
Empty buckets , where is the bit size of the ratings.
RandomizerCache< BlindingFactorContainer > URSumDecryptionBlindingFactorCache
decryption blinding factor cache instance
RandomizerCache< BlindingFactorContainer > LdecryptionBlindingFactorCache
decryption blinding factor cache instance
unsigned int digitsToPreserve
Number of digits preserved from the normalized user ratings.
Definition of template class RandomizerCache.
std::deque< EncryptedUserData > EncryptedUserDataContainer
Container for encrypted user data.
Definition of struct BlindingFactorCacheParameters.
Definition of class Config.
const std::shared_ptr< ServiceProvider > serviceProvider
A reference to the ServiceProvider.
const std::shared_ptr< PrivacyServiceProvider > privacyServiceProvider
A reference to the PrivacyServiceProvider.
static const std::string configurationPath
Service Provider configuration path.
size_t scaledNormalizedRatingBitSize
k - The size of the scaled normalized ratings (in bits)
Definition of struct DecryptionBlindingFactorContainer.
Definition of class DateTime.
size_t kappa
The security parameter for the secure comparison protocol (in bits)
Implementation of the public-key Paillier Cryptosystem.
Definition: paillier.h:103
std::string ratingsFilePath
The path to the file containing precomputed ratings.
Definition of class CpuTimer.
DecryptionBlindingFactorContainer< Paillier, BlindingFactorCacheParameters > BlindingFactorContainer
Alias for the blinding factor container.
Definition of class PrivacyServiceProvider.
Definition of class Paillier.
Definition of class ServiceProvider.
The public key container structure for the Paillier cryptosystem.
Definition: paillier.h:49