Forráskód Böngészése

putting some of the couts in ifdef VERBOSE

avadapal 1 éve
szülő
commit
c89afe131b
3 módosított fájl, 30 hozzáadás és 183 törlés
  1. 12 159
      preprocessing/dpfgen.h
  2. 5 10
      preprocessing/p2preprocessing.cpp
  3. 13 14
      preprocessing/preprocessing.cpp

+ 12 - 159
preprocessing/dpfgen.h

@@ -450,14 +450,7 @@ inline void create_dpfs(  size_t db_nitems,
 		std::cout << "t[curlayer][0] " << (int) t[curlayer][0] << std::endl;
 	}
 
-	// struct dpfP2
-	// {
-	// 	__m128i root;
-	// 	__m128i CW[26];
-	// 	uint8_t cwt_L[26];
-	// 	uint8_t cwt_R[26];
-	// };
-	
+ 
 	dpfP2 dpf_instance;
 	dpf_instance.root           = root;
 	for (size_t layer = 0; layer < depth; ++layer)
@@ -565,10 +558,6 @@ inline void create_dpfs(  size_t db_nitems,
 
 
 
-
-
-
-
 inline void evaluate_dpfs( size_t db_nitems,  dpfP2 dpfinstance,  const AES_KEY& prgkey,   const size_t from, const size_t to, 
 							__m128i * output, int8_t * _t, __m128i& final_correction_word, bool party,  
 							size_t ind)
@@ -609,12 +598,14 @@ inline void evaluate_dpfs( size_t db_nitems,  dpfP2 dpfinstance,  const AES_KEY&
 
 	s[curlayer][0] = root;
 	t[curlayer][0] = get_lsb(root, 0b01);
-	 	if(ind == 0)
-	{
-		std::cout << "root = "         << root[0] << " " << root[1] << std::endl;
-		std::cout << "t[curlayer][0] " << (int) t[curlayer][0] << std::endl;
-	}
-
+	
+	#ifdef VERBOSE
+		if(ind == 0)
+		{
+			std::cout << "root = "         << root[0] << " " << root[1] << std::endl;
+			std::cout << "t[curlayer][0] " << (int) t[curlayer][0] << std::endl;
+		}
+	#endif
 	for (size_t layer = 0; layer < depth; ++layer)
 	{
 			#ifdef VERBOSE	
@@ -645,14 +636,15 @@ inline void evaluate_dpfs( size_t db_nitems,  dpfP2 dpfinstance,  const AES_KEY&
 				}
 			}
 
-			//#ifdef DEBUG
+			#ifdef VERBOSE
 				if(ind == 0) 
 				{ 
 					std::cout << "CW reconstruction  = " << CW[layer][0] << " " << CW[layer][1] << std::endl;
 					std::cout << "			   cwt_L = " << (int) cwt_L[layer] << std::endl;
 					std::cout << "			   cwt_R = " << (int) cwt_R[layer] << std::endl;
 				}
-			//#endif
+			#endif
+
 			for(size_t j = 0; j < nodes_in_prev_layer; ++j)
 			{	
 				t[curlayer][2*j] 	 = get_lsb(s[curlayer][2*j]) ^ (cwt_L[layer] & t[1-curlayer][j]);
@@ -681,143 +673,4 @@ inline void evaluate_dpfs( size_t db_nitems,  dpfP2 dpfinstance,  const AES_KEY&
 
 } // dpf::__evalinterval
 
-// void convert_shares(size_t i, __m128i ** output, int8_t ** flags, size_t n_threads, size_t db_nitems, __m128i * final_correction_word, 
-// 					int64_t ** leaves, int64_t ** leafbits,
-// 					tcp::socket& sb, tcp::socket& s2, bool party)
-// {
-	
-// 	#ifdef DEBUG
-// 		std::cout << "share conversion " << i << "-th, thread started runing" << std::endl << std::endl;
-// 	#endif
-
-// 	for(size_t j = 0; j < db_nitems; ++j)
-// 	{
-// 		if(party)
-// 		{
-// 			output[i][j] = -output[i][j];
-// 			flags[i][j]  =  -flags[i][j]; 
-// 		}
-// 	}
-
-// 	int64_t pm = 0;
-// 	int64_t rb, rb_prime;
-
-// 	arc4random_buf(&rb, sizeof(rb));
-
-// 	for(size_t j = 0; j < db_nitems; ++j)
-// 	{
-// 		if(party)
-// 		{
-// 		  if(flags[i][j] != 0)	pm -= 1;
-// 		}
-// 		if(!party)
-// 		{
-// 		 if(flags[i][j] != 0)	pm += 1;//flags[0][j];
-// 		}
-// 	}
-
-// 	rb_prime = du_attalah_Pb(rb, pm, s2, sb);
-
-// 	int64_t FCWshare = du_attalah_Pb(final_correction_word[i][1] + rb_prime, pm, s2, sb);
-
-// 	int64_t tmpfcw =  du_attalah_Pb(final_correction_word[i][1], pm, s2, sb);
-	
-// 	int64_t test0, test1, test;
-// 	test1 = 0;
-// 	test0 = 0;
-// 	for(size_t j = 0; j < db_nitems; ++j)
-// 	{
-// 		test0 += flags[i][j] * final_correction_word[i][1];
-// 		if(flags[i][j] == 0) test1 +=  final_correction_word[i][1];
-// 	}
-// 	test1 = -test1;
-// 	test = test0 + test1;
-// 	//tmpfcw += rb;
-
-// 	int64_t test_reconstruction;
-//  	boost::asio::write(sb, boost::asio::buffer(&test, sizeof(test)));
-// 	boost::asio::read(sb, boost::asio::buffer(&test_reconstruction, sizeof(test_reconstruction)));
-// 	test_reconstruction = test_reconstruction + test;
-
-// 	int64_t tmpfcw_reconstruction;
-//  	boost::asio::write(sb, boost::asio::buffer(&tmpfcw, sizeof(tmpfcw)));
-// 	boost::asio::read(sb, boost::asio::buffer(&tmpfcw_reconstruction, sizeof(tmpfcw_reconstruction)));
-// 	tmpfcw_reconstruction = tmpfcw_reconstruction + tmpfcw;
-
-// 	int64_t FCWshare_reconstruction;
-//  	boost::asio::write(sb, boost::asio::buffer(&FCWshare, sizeof(FCWshare)));
-// 	boost::asio::read(sb, boost::asio::buffer(&FCWshare_reconstruction, sizeof(FCWshare_reconstruction)));
-// 	FCWshare_reconstruction = FCWshare_reconstruction + FCWshare;
-
-// 	//std::cout << tmpfcw_reconstruction << " <----> " << test_reconstruction << std::endl;
-	
-// 	int64_t PM = pm + rb;
-// 	int64_t PM_recv;
-
-// 	boost::asio::write(sb, boost::asio::buffer(&PM, sizeof(PM)));
-// 	boost::asio::read(sb, boost::asio::buffer(&PM_recv, sizeof(PM_recv)));
-    
-//     int64_t * flags_  = (int64_t *)std::aligned_alloc(sizeof(node_t), db_nitems * sizeof(int64_t));
-// 	int64_t * outs_  = (int64_t *)std::aligned_alloc(sizeof(node_t), db_nitems * sizeof(int64_t));
-	
-// 	for(size_t j = 0; j < db_nitems; ++j)
-// 	{
-// 		outs_[j] = output[0][j][0];
-// 		leaves[i][j] = output[i][j][0];
 
-// 		#ifdef DEBUG
-// 			int64_t out_rec;
-// 			boost::asio::write(sb, boost::asio::buffer(&outs_[j], sizeof(outs_[j])));
-// 			boost::asio::read(sb, boost::asio::buffer(&out_rec, sizeof(out_rec)));
-// 			out_rec = out_rec + outs_[j];
-
-// 			if(out_rec != 0) std::cout << j << "-> " << out_rec << std::endl;
-// 		#endif
-
-// 		flags_[j] = (flags[i][j] * pm) + (flags[i][j] * PM_recv) + (flags[i][j] * rb); 
- 
-// 		flags_[j] += output[i][j][1]; 
-
-// 		if(!party)
-// 		{	
-// 			flags_[j] -= (flags[i][j] * FCWshare_reconstruction);		
-// 		}
-// 		if(party)
-// 		{ 
-// 			flags_[j] -= (flags[i][j] * FCWshare_reconstruction);
-// 		}
-	
-// 		#ifdef DEBUG
-// 		int64_t flags_rec;
-// 		boost::asio::write(sb, boost::asio::buffer(&flags_[j], sizeof(flags_[j])));
-// 		boost::asio::read(sb, boost::asio::buffer(&flags_rec, sizeof(flags_rec)));
-// 		flags_rec = flags_rec + flags_[j];
-
-// 		if(flags_rec != 0)
-// 		{
-// 			 std::cout << j << " ---> Flag Reconstruction = " << flags_rec << std::endl;
-// 		}
-// 		#endif
-		
- 
-// 		flags[i][j] = flags_[j];
-		
-// 		if(flags[i][j] == 128 || flags[i][j] == -128) flags[i][j] = 0;
-// 		leafbits[i][j] = flags[i][j];
-
-// 		#ifdef DEBUG
-// 			int8_t flags_rec2;
-// 			boost::asio::write(sb, boost::asio::buffer(&flags[i][j], sizeof(flags[i][j])));
-// 			boost::asio::read(sb, boost::asio::buffer(&flags_rec2, sizeof(flags_rec2)));
-// 			flags_rec2 = flags_rec2 + flags[i][j];
-
-// 			if(flags_rec2 != 0)
-// 			{
-// 				std::cout << j << " ---> Flag Reconstruction = " << (int) flags_rec2 << std::endl;
-// 				if(flags_rec2 != 1) std::cout << (int) flags[i][j]  << "-> " << flags_[j] << std::endl;
-// 			}
-// 		#endif
-// 	}
-
-// 	  write_evalfull_outs_into_a_file(party, i, db_nitems, flags,  leaves[0], final_correction_word); 
-// }

+ 5 - 10
preprocessing/p2preprocessing.cpp

@@ -13,11 +13,7 @@
 #include <bsd/stdlib.h> // arc4random_buf
 #include <x86intrin.h>  // SSE and AVX intrinsics
 #include <../boost/asio/thread_pool.hpp>
-#include "bitutils.h"
-#include "block.h"
-#include "prg_aes_impl.h" 
-#include <iostream>
-#include "block.h"
+#include <iostream> 
 #include <chrono>
 #include <sys/mman.h>
 #include <sys/stat.h>
@@ -26,7 +22,9 @@
 #include <boost/asio.hpp>
 #include <mutex>
 #include <boost/lexical_cast.hpp>
-
+#include "bitutils.h"
+#include "block.h"
+#include "prg_aes_impl.h" 
 
 using boost::asio::ip::tcp;
 
@@ -148,11 +146,8 @@ int main(int argc, char* argv[])
    
   const size_t n_threads = atoi(argv[3]);
   const size_t number_of_sockets = 5 * n_threads;
-       
-   
-  const size_t nitems2 = 1ULL << atoi(argv[4]);
   const size_t db_nitems = 1ULL << atoi(argv[4]);
-  const size_t depth = std::ceil(std::log2(nitems2));
+  const size_t depth = std::ceil(std::log2(db_nitems));
 
     
   std::vector<int> ports2_0;

+ 13 - 14
preprocessing/preprocessing.cpp

@@ -13,25 +13,24 @@
 #include <bsd/stdlib.h> // arc4random_buf
 #include <x86intrin.h>  // SSE and AVX intrinsics
 #include <../boost/asio/thread_pool.hpp>
-#include "bitutils.h"
-#include "block.h" 
-#include "prg_aes_impl.h"
-#include <iostream>
+#include <../boost/lexical_cast.hpp>
+#include <../boost/asio.hpp>
 #include <fcntl.h>
 #include <cstdlib>
-#include "block.h"
 #include <chrono>
 #include <sys/mman.h>
 #include <sys/stat.h>
-#include <fcntl.h>
 #include <fstream>
 #include <future>
-#include <boost/asio.hpp>
-using boost::asio::ip::tcp;
-
 #include <mutex>
-#include <boost/lexical_cast.hpp>
+
+
+#include "bitutils.h"
+#include "block.h" 
+#include "prg_aes_impl.h"
  
+
+using boost::asio::ip::tcp;
 using socket_t = boost::asio::ip::tcp::socket;
  
 typedef unsigned char byte_t;
@@ -45,11 +44,10 @@ typedef std::array<leaf_type, leaf_size> leaf_t;
 using namespace dpf;  // The namespace is found in bitutils.h
 
 #include "mpc.h"
-
 #include "network.h"
-
 #include "dpfgen.h"
 #include "share-conversion.h"
+
 int main(int argc, char * argv[])
 { 	
 	
@@ -105,6 +103,7 @@ int main(int argc, char * argv[])
 	// the flag vectors are stored in flags
 	// the leaves are stored in output
 	// the final correctionword is stored in final_correction_word
+	/* The function create_dpfs is defined dpf-gen.h*/
 	for(size_t j = 0; j < n_threads; ++j)
 	{
 		boost::asio::post(pool,  std::bind(create_dpfs,  db_nitems,	std::ref(aeskey),  target_share_read[j],  std::ref(socketsPb), std::ref(socketsP2), 0, db_nitems-1, 
@@ -112,7 +111,7 @@ int main(int argc, char * argv[])
 	}
 	pool.join();  
 
-	//#ifdef DEBUG
+	#ifdef DEBUG
 		for(size_t j = 0; j < n_threads; ++j)
 		{
 			for(size_t i = 0; i < db_nitems; ++i)
@@ -135,7 +134,7 @@ int main(int argc, char * argv[])
 			final_correction_word_reconstruction = final_correction_word_reconstruction + final_correction_word[j][0];
 			std::cout << "final_correction_word_reconstruction = " << final_correction_word_reconstruction << std::endl << std::endl;
 		}
-	//#endif
+	#endif
  
 
 	for(size_t j = 0; j < n_threads; ++j)