SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
data_packing/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 PrivateRecommendationsDataPacking {
39  const std::string PrivacyServiceProvider::configurationPath("PrivateRecommendationsDataPacking");
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);
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 PrivateRecommendationsDataPacking
107 }//namespace SeComLib
const T_PublicKey & GetPublicKey() const
Public key getter.
virtual BigInteger DecryptInteger(const Ciphertext &ciphertext) const
Decrypt number.
Definition: paillier.cpp:176
std::shared_ptr< const ServiceProvider > serviceProvider
A reference to the ServiceProvider.
virtual bool GenerateKeys()
Definition: paillier.cpp:105
The public key container structure for the Dgk cryptosystem.
Definition: dgk.h:47
const DgkPublicKey & GetDgkPublicKey() const
Getter for the DGK crypto provider public key.
const std::shared_ptr< SecureComparisonClient > & GetSecureComparisonClient() const
Getter for this->secureComparisonClient.
BigInteger SecureDecryption(const Paillier::Ciphertext &input) const
Decrypts a blinded Paillier ciphertext.
virtual bool GenerateKeys()
Generate the public and private keys.
Definition: dgk.cpp:161
Definition of class PrivacyServiceProvider.
const PaillierPublicKey & GetPaillierPublicKey() const
Getter for the Paillier crypto provider public key.
Definition of class ServiceProvider.
std::shared_ptr< SecureMultiplicationClient< Paillier > > secureMultiplicationClient
A reference to the SecureMultiplicationClient.
void DebugPaillierEncryption(const Paillier::Ciphertext &input) const
Decrypts and prints a Paillier encrypted integer.
std::shared_ptr< SecureComparisonClient > secureComparisonClient
A reference to the SecureComparisonClient.
const std::shared_ptr< SecureMultiplicationClient< Paillier > > & GetSecureMultiplicationClient() const
Getter for this->secureMultiplicationClient.
static const std::string configurationPath
Service Provider configuration path.
void SetServiceProvider(const std::shared_ptr< const ServiceProvider > &serviceProvider)
Sets a reference to the Privacy Service Provider.
The public key container structure for the Paillier cryptosystem.
Definition: paillier.h:49