SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
secure_multiplication_server.hpp
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 */
29 #ifndef SECURE_MULTIPLICATION_SERVER_IMPLEMENTATION_GUARD
30 #define SECURE_MULTIPLICATION_SERVER_IMPLEMENTATION_GUARD
31 
32 namespace SeComLib {
33 namespace Core {
39  template <typename T_CryptoProvider>
40  SecureMultiplicationServer<T_CryptoProvider>::SecureMultiplicationServer (const T_CryptoProvider &cryptoProvider, const size_t l, const std::string &configurationPath) :
41  cryptoProvider(cryptoProvider),
42  blindingFactorCache(cryptoProvider, BlindingFactorCacheParameters(configurationPath + ".BlindingFactorCache", l)) {
43  }
44 
58  template <typename T_CryptoProvider>
59  typename T_CryptoProvider::Ciphertext SecureMultiplicationServer<T_CryptoProvider>::Multiply (const typename T_CryptoProvider::Ciphertext &lhs, const typename T_CryptoProvider::Ciphertext &rhs) {
60  const BlindingFactorContainer &blindingFactorContainer = this->blindingFactorCache.Pop();
61 
62  typename T_CryptoProvider::Ciphertext blindedVTildeA = lhs + blindingFactorContainer.encryptedMinusR1;
63  typename T_CryptoProvider::Ciphertext blindedVTildeB = rhs + blindingFactorContainer.encryptedMinusR2;
64 
65  //interact with the server
66  typename T_CryptoProvider::Ciphertext output = this->secureMultiplicationClient.lock()->Multiply(blindedVTildeA, blindedVTildeB);
67 
68  output = output + lhs * blindingFactorContainer.r2 + rhs * blindingFactorContainer.r1 + blindingFactorContainer.encryptedMinusR1R2;
69 
70  return output;
71  }
72 
76  template <typename T_CryptoProvider>
78  this->secureMultiplicationClient = secureMultiplicationClient;
79  }
80 
81 }//namespace Core
82 }//namespace SeComLib
83 
84 #endif//SECURE_MULTIPLICATION_SERVER_IMPLEMENTATION_GUARD
T_CryptoProvider::Ciphertext Multiply(const typename T_CryptoProvider::Ciphertext &lhs, const typename T_CryptoProvider::Ciphertext &rhs)
Interactive secure multiplication.
SecureMultiplicationServer(const T_CryptoProvider &cryptoProvider, const size_t l, const std::string &configurationPath)
Constructor.
void SetClient(const std::shared_ptr< SecureMultiplicationClient< T_CryptoProvider >> &secureMultiplicationClient)
Setter for this->secureMultiplicationClient.
Blinding factor cache parameter container struct.