/* Copyright (C) 2014 Carlos Aguilar Melchor, Joris Barrier, Marc-Olivier Killijian * This file is part of XPIR. * * XPIR is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * XPIR is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XPIR. If not, see . */ #include "PIRReplyExtraction_internal.hpp" #include "apps/client/PIRViewCLI.hpp" //#define DEBUG /** * Class constructor. * Params : * - crypto_ptr crypto : HomomorphicCrypto shared_ptr ; * - PIRParameters& param : PIRParameters reference ; * - signal1 : writeEvent listeners reference shared with PIRClient ; * - ignal1 : messageEvent listeners reference shared with PIRClient. **/ PIRReplyExtraction_internal::PIRReplyExtraction_internal(PIRParameters& param_, HomomorphicCrypto& cryptoMethod_) : filePath("reception"), pirParams(param_), cryptoMethod(cryptoMethod_), repliesBuffer("coucou"), fileSize(0) {} /** * Parallely extract/decrypt file, store clear chunk in clearChunks shared queue. **/ void PIRReplyExtraction_internal::extractReply(int aggregated_maxFileSize, shared_queue* clearChunks) { uint64_t response_size=0; unsigned long ciphertext_nbr = 1; unsigned int data_size, data_size2b; char *data, *in_data, *in_data_2b; double start = omp_get_wtime(); clock_t er_start, er_stop; uint64_t total_ciphertext_nbr= 0; er_start=clock(); for (unsigned int rec_lvl = pirParams.d ; rec_lvl >= 1 ; rec_lvl--) { ciphertext_nbr = ceil(static_cast(aggregated_maxFileSize) / static_cast(cryptoMethod.getPublicParameters().getAbsorptionBitsize(0)/GlobalConstant::kBitsPerByte)); std::cout<<"consensgx:PIRReplyExtraction_internal: First layer ciphertext_nbr="< 1) { memcpy(in_data_2b+(data_size2b * j), out_data, data_size2b); free(out_data); } else { clearChunks->push(out_data); #ifdef CRYPTO_DEBUG cout << "PIRReplyExtraction_internal : pushed " << hex; for (int k = 0 ; k < data_size2b ; k++) cout << (unsigned short) *(out_data+k) << " "; cout << dec << endl; #endif } if(rec_lvl == pirParams.d) free(data); } if (rec_lvl < pirParams.d) free(in_data); in_data = in_data_2b; } er_stop = clock(); response_size = data_size * total_ciphertext_nbr; std::cout<<"measure_response_size:"< Temp écoulé : %f seconds\n", omp_get_wtime() - start);