github.com/jiajun1992/watercarver@v0.0.0-20191031150618-dfc2b17c0c4a/StadiumForWaterCarver/src/RemoteShuffler.h (about) 1 #ifndef __REMOTE_SHUFFLER_H__ 2 #define __REMOTE_SHUFFLER_H__ 3 4 #define BOOST_SPIRIT_THREADSAFE 5 6 #include <stdio.h> 7 #include <time.h> 8 #include <vector> 9 #include <fstream> 10 11 #include "G_q.h" 12 #include "Functions.h" 13 #include "ElGammal.h" 14 #include "Cipher_elg.h" 15 #include "Permutation.h" 16 #include "Prover_toom.h" 17 #include "VerifierClient.h" 18 19 #include "FakeZZ.h" 20 #include <chrono> 21 NTL_CLIENT 22 23 using namespace std::chrono; 24 25 class RemoteShuffler { 26 public: 27 RemoteShuffler(const vector<long>& config, vector<vector<Cipher_elg>* >* ciphers_in, ElGammal* reenc_key, int m, int n, bool owner = true); 28 RemoteShuffler(const vector<long>& config, vector<vector<Cipher_elg>* >* ciphers_in, ElGammal* reenc_key, 29 int m, int n, vector<vector<vector<long>* >* > * pi_in, vector<vector<ZZ>* > * R_in, bool owner = true); 30 ~RemoteShuffler(); 31 32 string create_nizk(); 33 34 vector<vector<Cipher_elg>* >* permute_and_reencrypt(ElGammal* reenc_key); 35 vector<vector<Cipher_elg>* >* getc() { return c; } 36 vector<vector<Cipher_elg>* >* getC() { return C; } 37 vector<vector<vector<long>* >* > * getPermutation() { return pi; } 38 void print_state() const; 39 void reverse_permutation(vector<long>& reversed); 40 void output_permutation(ostream& f); 41 double get_time() const { return time_p; } 42 string get_public_vector(); 43 44 private: 45 string round1(string* input_for_next, ZZ* challenge, ZZ* randomness); 46 string round3(const string& input_file, string* input_for_next_prover, ZZ* challenge, ZZ* randomness); 47 string round5(const string& input_file, string* input_for_next_prover, ZZ* challenge, ZZ* randomness); 48 string round5red(const string& input_file, string* input_for_next_prover, ZZ* challenge, ZZ* randomness); 49 string round5red_1(const string& input_file, string* input_for_next_prover, ZZ* challenge, ZZ* randomness); 50 string round7(const string& input_file, string* input_for_next_prover, ZZ* challenge, ZZ* randomness); 51 string round7red(const string& input_file, string* input_for_next_prover, ZZ* challenge, ZZ* randomness); 52 string round9(const string& input_file); 53 54 vector<long> config_; //Containing the number of ciphertexts and the structure of the matrix of the ciphertexts 55 double time_rw_p; 56 double time_rw_v; 57 double time_cm; 58 59 int i; 60 vector<vector<Cipher_elg>* >* c; // contains the original input ciphertexts 61 vector<vector<Cipher_elg>* >* C;//Contains reencryptetd ciphers 62 vector<vector<vector<long>* >* > * pi; //Permutation 63 vector<vector<ZZ>* > * R; //Random elements for reencryption 64 ElGammal *key; 65 long m, n; 66 long m_r_; 67 double time_p; 68 69 // prover vars 70 Prover_toom* P; 71 ZZ chal_10,ans_12; 72 string name; 73 74 VerifierClient* verifier_; 75 bool owner_; 76 77 public: 78 bool flow_flag_; 79 }; 80 81 #endif