SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SeComLib::PrivateRecommendations::ServiceProvider Class Reference

Service Provider. More...

#include <service_provider.h>

Public Types

typedef std::deque
< Paillier::Ciphertext
EncryptedUserData
 Encrypted user data.
 
typedef std::deque
< EncryptedUserData
EncryptedUserDataContainer
 Container for encrypted user data.
 

Public Member Functions

 ServiceProvider (const PaillierPublicKey &paillierPublicKey, const DgkPublicKey &dgkPublicKey)
 Constructor. More...
 
 ~ServiceProvider ()
 Destructor - void implementation.
 
void GenerateDummyDatabase ()
 Generates a dummy database for the users. More...
 
void ComputeSimilarityValues ()
 Computes the similarity values between each pair of users for the first \( R \) items. More...
 
void ComputeUserRecommendations ()
 Computes \( [\Gamma] \), \( [L] \) and \( [UR_{sum}] \) for each user. More...
 
const Paillier::CiphertextGetEncryptedL (size_t userId) const
 Returns the \( [L] \) value for the specified user. More...
 
const EncryptedUserDataGetEncryptedURSum (size_t userId) const
 Returns the \( [UR_{sum}] \) vector for the specified user. More...
 
void SetPrivacyServiceProvider (const std::shared_ptr< const PrivacyServiceProvider > &privacyServiceProvider)
 Sets a reference to the Privacy Service Provider. More...
 
const std::shared_ptr
< SecureComparisonServer > & 
GetSecureComparisonServer () const
 Getter for this->secureComparisonServer. More...
 
const std::shared_ptr
< SecureMultiplicationServer
< Paillier > > & 
GetSecureMultiplicationServer () const
 Getter for this->secureMultiplicationServer. More...
 

Private Member Functions

 ServiceProvider (ServiceProvider const &)
 Copy constructor - not implemented.
 
ServiceProvider operator= (ServiceProvider const &)
 Copy assignment operator - not implemented.
 

Private Attributes

std::weak_ptr< const
PrivacyServiceProvider
privacyServiceProvider
 A reference to the PrivacyServiceProvider.
 
Paillier paillierCryptoProvider
 Paillier crypto provider.
 
Dgk dgkCryptoProvider
 DGK crypto provider.
 
size_t userCount
 Number of users who need recommendations.
 
size_t itemCount
 Number of ratings per user.
 
size_t denselyRatedItemCount
 Number of densely rated items.
 
size_t ratingBitSize
 The size of the user ratings (in bits)
 
unsigned int digitsToPreserve
 Number of digits preserved from the normalized user ratings.
 
BigInteger similarityTreshold
 \( s^2 \delta \) - Scaled public threshold value for the similarity values
 
std::string ratingsFilePath
 The path to the file containing precomputed ratings.
 
EncryptedUserDataContainer normalizedScaledRatings
 \( [\tilde{V}_i^d] \)
 
EncryptedUserDataContainer sparseRatings
 \( [V_i^p] \)
 
EncryptedUserData gammaValues
 \( [\Gamma] \)
 
EncryptedUserData LValues
 Vector of \( [L] \) values, where L is the number of users similar to a given user.
 
EncryptedUserDataContainer URSumContainer
 Contains the \( [UR_{sum}] \) vectors for each user.
 
const std::shared_ptr
< SecureComparisonServer
secureComparisonServer
 A reference to the SecureComparisonServer.
 
std::shared_ptr
< SecureMultiplicationServer
< Paillier > > 
secureMultiplicationServer
 A reference to the SecureMultiplicationServer.
 

Static Private Attributes

static const std::string configurationPath
 Service Provider configuration path. More...
 

Detailed Description

Service Provider.

Definition at line 67 of file service_provider.h.

Constructor & Destructor Documentation

SeComLib::PrivateRecommendations::ServiceProvider::ServiceProvider ( const PaillierPublicKey paillierPublicKey,
const DgkPublicKey dgkPublicKey 
)

Constructor.

\( \delta \) needs to be scaled with \( s^2 \), because \( sim_{(A, B)} \) is the dot product of two scaled vectors

Parameters
paillierPublicKeyThe Paillier public key
dgkPublicKeyThe DGK public key

Definition at line 47 of file service_provider.cpp.

Member Function Documentation

void SeComLib::PrivateRecommendations::ServiceProvider::ComputeSimilarityValues ( )

Computes the similarity values between each pair of users for the first \( R \) items.

Computes \( [sim_{(A, B)}] = \prod_{r = 0}^{R-1}{[\tilde{v}_{(A, r)}^d \tilde{v}_{(B, r)}^d]} = \prod_{r = 0}^{R-1}{([\tilde{v}_{(A, r)}^d] \otimes [\tilde{v}_{(B, r)}^d])} \), where \( A < B \), because \( [sim_{(A, B)}] = [sim_{(B, A)}] \)

Computes the \( [\Gamma] \) vector for each user, where \( [\Gamma_A] = ([\gamma_{(A, 0)}], [\gamma_{(A, 1)}], ..., [\gamma_{(A, N - 2)}])^T \), where \( [\gamma_{(A, i)}] = sim_{(A, i)} >= \delta ? [1] : [0] \)

Definition at line 154 of file service_provider.cpp.

void SeComLib::PrivateRecommendations::ServiceProvider::ComputeUserRecommendations ( )

Computes \( [\Gamma] \), \( [L] \) and \( [UR_{sum}] \) for each user.

Computes \( [L] \) and \( [UR_{sum}] \) for each user

\( [L] = \left[ \displaystyle\sum_{i = 0}^{N - 2}{\gamma_{(A, i)}} \right] = \displaystyle\prod_{i=0}^{N - 2}{[\gamma_{(A, i)}]} \)

\( [UR_i] := ([\gamma_{(A, i)}] \otimes [v_{(i, 0)}^p], ..., [\gamma_{(A, i)}] \otimes [v_{(i, M - R - 1)}^p])^T = ([\gamma_{(A, i)} v_{(i, 0)}^p], ..., [\gamma_{(A, i)} v_{(i, M - R - 1)}^p])^T = ([UR_{(i, 0)}], ..., [UR_{(i, M - R - 1)}])^T \)

where \( [UR_i] = \left\{ \begin{array}{lc} [V_{(i, j)}^p], & if \; \gamma_{(A, i)} \; is \; 1 \\ ([0], ..., [0])^T, & if \; \gamma_{(A, i)} \; is \; 0 \end{array} \right. \)

\( [UR_{user}^{sum}] = \left( \displaystyle\prod_{i = 0}^{N - 2}{[UR_{(i, 0)}]}, ..., \displaystyle\prod_{i = 0}^{N - 2}{[UR_{(i, M - R - 1)}]} \right)^T = \left( \left[ \displaystyle\sum_{i = 0}^{N - 2}{UR_{(i, 0)}} \right], ..., \left[\displaystyle\sum_{i = 0}^{N - 2}{UR_{(i, M - R - 1)}}\right] \right)^T \)

Initialize L with the first gamma value (note that \( \gamma_{(A, B)} = \gamma_{(B, A)} \))

Compute \( \left( [UR_{(0, 0)}], ..., [UR_{(0, M - R - 1)}] \right) \)

Compute the rest: \( \left( \displaystyle\prod_{i = 1}^{N - 2}{[UR_{(i, 0)}]}, ..., \displaystyle\prod_{i = 1}^{N - 2}{[UR_{(i, M - R - 1)}]} \right) \)

Compute the gammaValues vector index from the matrix indices

Compute \( \displaystyle\prod_{i = 0}^{N - 2}{[UR_{(i, j)}]} \)

Definition at line 210 of file service_provider.cpp.

void SeComLib::PrivateRecommendations::ServiceProvider::GenerateDummyDatabase ( )

Generates a dummy database for the users.

Generates \( M \) item ratings for each of the \( N \) users and scales them.

Encrypts the scaled normalized densely related ratings: \( [\tilde{V}_i^d] = ([\tilde{v}_{(i, 0)}^d], ..., [\tilde{v}_{(i, R - 1)}^d])^T \) and the sparse ratings for the rest of the items: \( [V_i^p] = ([v_{(i, 0)}^p], ..., [v_{(i, M - R - 1)}^p])^T \).

Exceptions
std::runtime_errorthe ratings file can't be opened

Load ratings from file

Definition at line 70 of file service_provider.cpp.

const Paillier::Ciphertext & SeComLib::PrivateRecommendations::ServiceProvider::GetEncryptedL ( size_t  userId) const

Returns the \( [L] \) value for the specified user.

Parameters
userIdThe index of the user
Returns
\( [L] \)

Definition at line 270 of file service_provider.cpp.

const ServiceProvider::EncryptedUserData & SeComLib::PrivateRecommendations::ServiceProvider::GetEncryptedURSum ( size_t  userId) const

Returns the \( [UR_{sum}] \) vector for the specified user.

Parameters
userIdThe index of the user
Returns
\( [UR_{user}^{sum}] \)

Definition at line 278 of file service_provider.cpp.

const std::shared_ptr< SecureComparisonServer > & SeComLib::PrivateRecommendations::ServiceProvider::GetSecureComparisonServer ( ) const

Getter for this->secureComparisonServer.

Returns
The SecureComparisonServer instance.

Definition at line 294 of file service_provider.cpp.

const std::shared_ptr< SecureMultiplicationServer< Paillier > > & SeComLib::PrivateRecommendations::ServiceProvider::GetSecureMultiplicationServer ( ) const

Getter for this->secureMultiplicationServer.

Returns
The SecureMultiplicationServer instance.

Definition at line 301 of file service_provider.cpp.

void SeComLib::PrivateRecommendations::ServiceProvider::SetPrivacyServiceProvider ( const std::shared_ptr< const PrivacyServiceProvider > &  privacyServiceProvider)

Sets a reference to the Privacy Service Provider.

Parameters
privacyServiceProvidera PrivacyServiceProvider instance

Definition at line 285 of file service_provider.cpp.

Member Data Documentation

const std::string SeComLib::PrivateRecommendations::ServiceProvider::configurationPath
staticprivate

Service Provider configuration path.

Set the configuration path.

Definition at line 158 of file service_provider.h.


The documentation for this class was generated from the following files: