SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
privacy_service_provider.cpp
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 */
31 //avoid circular includes
32 #include "service_provider.h"
33 
34 namespace SeComLib {
35 namespace PrivateRecommendations {
39  const std::string PrivacyServiceProvider::configurationPath("PrivateRecommendations");
40 
46 
48 
49  //can't initialize it in the initialization list, because the crypto providers need to generate keys first
50  this->secureComparisonClient = std::make_shared<SecureComparisonClient>(this->paillierCryptoProvider, this->dgkCryptoProvider, this->configurationPath);
51  this->secureMultiplicationClient = std::make_shared<SecureMultiplicationClient<Paillier>>(this->paillierCryptoProvider);
52  }
53 
59  return this->paillierCryptoProvider.DecryptInteger(input);
60  }
61 
65  void PrivacyServiceProvider::SetServiceProvider (const std::shared_ptr<const ServiceProvider> &serviceProvider) {
66  this->serviceProvider = serviceProvider;
67  this->secureComparisonClient->SetServer(serviceProvider->GetSecureComparisonServer());
68  this->secureMultiplicationClient->SetServer(serviceProvider->GetSecureMultiplicationServer());
69  }
70 
74  const std::shared_ptr<SecureComparisonClient> &PrivacyServiceProvider::GetSecureComparisonClient () const {
75  return this->secureComparisonClient;
76  }
77 
81  const std::shared_ptr<SecureMultiplicationClient<Paillier>> &PrivacyServiceProvider::GetSecureMultiplicationClient () const {
82  return this->secureMultiplicationClient;
83  }
84 
89  return this->paillierCryptoProvider.GetPublicKey();
90  }
91 
96  return this->dgkCryptoProvider.GetPublicKey();
97  }
98 
103  std::cout << this->paillierCryptoProvider.DecryptInteger(input).ToString(10) << std::endl;
104  }
105 
106 }//namespace PrivateRecommendations
107 }//namespace SeComLib
const std::shared_ptr< SecureMultiplicationClient< Paillier > > & GetSecureMultiplicationClient() const
Getter for this->secureMultiplicationClient.
BigInteger SecureDecryption(const Paillier::Ciphertext &input) const
Decrypts a blinded Paillier ciphertext.
const T_PublicKey & GetPublicKey() const
Public key getter.
virtual BigInteger DecryptInteger(const Ciphertext &ciphertext) const
Decrypt number.
Definition: paillier.cpp:176
Definition of class PrivacyServiceProvider.
virtual bool GenerateKeys()
Definition: paillier.cpp:105
The public key container structure for the Dgk cryptosystem.
Definition: dgk.h:47
std::shared_ptr< const ServiceProvider > serviceProvider
A reference to the ServiceProvider.
std::shared_ptr< SecureMultiplicationClient< Paillier > > secureMultiplicationClient
A reference to the SecureMultiplicationClient.
void SetServiceProvider(const std::shared_ptr< const ServiceProvider > &serviceProvider)
Sets a reference to the Privacy Service Provider.
const std::shared_ptr< SecureComparisonClient > & GetSecureComparisonClient() const
Getter for this->secureComparisonClient.
const PaillierPublicKey & GetPaillierPublicKey() const
Getter for the Paillier crypto provider public key.
std::shared_ptr< SecureComparisonClient > secureComparisonClient
A reference to the SecureComparisonClient.
const DgkPublicKey & GetDgkPublicKey() const
Getter for the DGK crypto provider public key.
virtual bool GenerateKeys()
Generate the public and private keys.
Definition: dgk.cpp:161
static const std::string configurationPath
Service Provider configuration path.
void DebugPaillierEncryption(const Paillier::Ciphertext &input) const
Decrypts and prints a Paillier encrypted integer.
Paillier paillierCryptoProvider
The Paillier crypto provider.
Definition of class ServiceProvider.
The public key container structure for the Paillier cryptosystem.
Definition: paillier.h:49