SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
secure_face_recognition_utils/secure_comparison_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 //avoid circular includes
32 
33 namespace SeComLib {
34 namespace SecureFaceRecognitionUtils {
40  SecureComparisonClient::SecureComparisonClient (const Paillier &paillierCryptoProvider, const Dgk &dgkCryptoProvider, const std::string &configurationPath) :
41  paillierCryptoProvider(paillierCryptoProvider),
42  dgkCryptoProvider(dgkCryptoProvider),
43  dgkComparisonClient(std::make_shared<DgkComparisonClient>(paillierCryptoProvider, dgkCryptoProvider, configurationPath)),
44  l(Utils::Config::GetInstance().GetParameter<size_t>(configurationPath + ".l")),
45  twoPowL(BigInteger(2).GetPow(static_cast<unsigned long>(l))) {
46  }
47 
53  BigInteger plaintextDModTwoPowL = this->paillierCryptoProvider.DecryptInteger(d) % this->twoPowL;
54 
56  this->dgkComparisonClient->SetHatD(plaintextDModTwoPowL);
57 
59  return this->paillierCryptoProvider.EncryptInteger(-plaintextDModTwoPowL);
60  }
61 
65  void SecureComparisonClient::SetServer (const std::shared_ptr<SecureComparisonServer> &secureComparisonServer) {
66  this->secureComparisonServer = secureComparisonServer;
67  this->dgkComparisonClient->SetServer(secureComparisonServer->GetDgkComparisonServer());
68  }
69 
73  const std::shared_ptr<DgkComparisonClient> &SecureComparisonClient::GetDgkComparisonClient () const {
74  return this->dgkComparisonClient;
75  }
76 
81  std::cout << this->paillierCryptoProvider.DecryptInteger(input).ToString(10) << std::endl;
82  }
83 
84 }//namespace SecureFaceRecognitionUtils
85 }//namespace SeComLib
Definition of class SecureComparisonServer.
Implementation of the public-key DGK Cryptosystem.
Definition: dgk.h:104
virtual BigInteger DecryptInteger(const Ciphertext &ciphertext) const
Decrypt number.
Definition: paillier.cpp:176
const std::shared_ptr< DgkComparisonClient > dgkComparisonClient
A reference to the DgkComparisonClient.
virtual T_Ciphertext EncryptInteger(const BigInteger &plaintext) const
Encrypt an integer and apply randomization.
void SetServer(const std::shared_ptr< SecureComparisonServer > &secureComparisonServer)
Setter for this->secureComparisonServer.
std::shared_ptr< const SecureComparisonServer > secureComparisonServer
A reference to the SecureComparisonServer.
Paillier::Ciphertext ComputeMinusDModTwoPowL(const Paillier::Ciphertext &d) const
Computes .
Definition of class SecureComparisonClient.
Implementation of the public-key Paillier Cryptosystem.
Definition: paillier.h:103
void DebugPaillierEncryption(const Paillier::Ciphertext &input) const
Decrypts and prints a Paillier encrypted integer.
const std::shared_ptr< DgkComparisonClient > & GetDgkComparisonClient() const
Getter for this->dgkComparisonClient.
SecureComparisonClient(const Paillier &paillierCryptoProvider, const Dgk &dgkCryptoProvider, const std::string &configurationPath)
Constructor.