SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
secure_face_recognition/client.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 */
30 #include "client.h"
31 //avoid circular includes
32 #include "server.h"
33 
34 namespace SeComLib {
35 namespace SecureFaceRecognition {
39  const std::string Client::configurationPath("SecureFaceRecognition");
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  }
52 
57  BigInteger a = Utils::Config::GetInstance().GetParameter<long>(this->configurationPath + ".a");
58  BigInteger b = Utils::Config::GetInstance().GetParameter<long>(this->configurationPath + ".b");
59 
60  Paillier::Ciphertext comparison = this->server->SecureComparison(this->paillierCryptoProvider.EncryptInteger(a), this->paillierCryptoProvider.EncryptInteger(b));
61 
63  this->DebugPaillierEncryption(comparison);
64  }
65 
69  void Client::SetServer (const std::shared_ptr<const Server> &server) {
70  this->server = server;
71  this->secureComparisonClient->SetServer(server->GetSecureComparisonServer());
72  }
73 
77  const std::shared_ptr<SecureComparisonClient> &Client::GetSecureComparisonClient () const {
78  return this->secureComparisonClient;
79  }
80 
85  std::cout << this->paillierCryptoProvider.DecryptInteger(input).ToString(10) << std::endl;
86  }
87 
88 }//namespace SecureFaceRecognition
89 }//namespace SeComLib
std::shared_ptr< SecureComparisonClient > secureComparisonClient
A reference to the SecureComparisonClient.
virtual BigInteger DecryptInteger(const Ciphertext &ciphertext) const
Decrypt number.
Definition: paillier.cpp:176
static Config & GetInstance()
Returns a reference to the singleton.
Definition: config.cpp:48
void SetServer(const std::shared_ptr< const Server > &server)
Sets a reference to the Privacy Service Provider.
static const std::string configurationPath
Service Provider configuration path.
Paillier paillierCryptoProvider
The Paillier crypto provider.
virtual bool GenerateKeys()
Definition: paillier.cpp:105
virtual T_Ciphertext EncryptInteger(const BigInteger &plaintext) const
Encrypt an integer and apply randomization.
const std::shared_ptr< SecureComparisonClient > & GetSecureComparisonClient() const
Getter for this->secureComparisonClient.
Definition of class Client.
void DebugPaillierEncryption(const Paillier::Ciphertext &input) const
Decrypts and prints a Paillier encrypted integer.
virtual bool GenerateKeys()
Generate the public and private keys.
Definition: dgk.cpp:161
std::shared_ptr< const Server > server
A reference to the Server.
T GetParameter(const std::string &parameter) const
Template method which returns the value of the specified configuration parameter. ...
Definition: config.hpp:41
Definition of class Server.