github.com/jiajun1992/watercarver@v0.0.0-20191031150618-dfc2b17c0c4a/StadiumForWaterCarver/src/Functions.h (about)

     1  /*
     2   * Functions.h
     3   *
     4   *  Created on: 26.10.2010
     5   *      Author: stephaniebayer
     6   *
     7   *      Functions used for the shuffle argument, which are used from main, Verifier and Prover
     8   *
     9   */
    10  
    11  #ifndef __FUNCTIONS_H__
    12  #define __FUNCTIONS_H__
    13  
    14  #include <vector>
    15  #include "G_q.h"
    16  #include "Mod_p.h"
    17  #include "Cipher_elg.h"
    18  #include "ElGammal.h"
    19  #include "Pedersen.h"
    20  #include "FakeZZ.h"
    21  NTL_CLIENT
    22  
    23  class Functions
    24  {
    25  public:
    26  	Functions();
    27  	virtual ~Functions();
    28  	//read the config file and sets the parameters and the groups
    29  	static void get_config(vector<long> &num, int m_in, int n_in);
    30  	static void read_config(const string &config_file, vector<long> &num, ZZ &genq);
    31  	static void sha256(string input, unsigned char *out_buf);
    32  
    33  	static void parse_ciphers(string &f, long m, vector<vector<Cipher_elg> *> &C, ElGammal *elgammal);
    34  	static string ciphers_to_str(vector<vector<Cipher_elg> *> *ciphers);
    35  	static string parse_response(std::basic_streambuf<char> *in);
    36  
    37  	//generates N=num[0] different ciphertexts
    38  	static void createCipher(vector<vector<ZZ>> *secrets, int m, int n, int N, vector<vector<Cipher_elg> *> *C, vector<vector<Mod_p> *> *elements, ElGammal *enc_key);
    39  	static void createCipherWithProof(vector<vector<ZZ>> *secrets, int m, int n, int N, vector<vector<Cipher_elg> *> *C, vector<vector<Mod_p> *> *elements, char *proofs, ElGammal *enc_key);
    40  	//generates a matrix of random elements
    41  	static void randomEl(vector<vector<ZZ> *> *R, int m, int n);
    42  	//reencrypts the ciphertexts e using the permutation pi and random elements R
    43  	static void reencryptCipher(vector<vector<Cipher_elg> *> *E, vector<vector<Cipher_elg> *> *e, vector<vector<vector<long> *> *> *pi, vector<vector<ZZ> *> *R, int m, int n, ElGammal *reenc_pub_key);
    44  
    45  	static vector<long> permutation2d_to_vector(vector<vector<vector<long> *> *> *pi, long m, long n);
    46  	static int get_num_cols(int m, int num_elements);
    47  	//returns the Hadamard product of x and y
    48  	static void Hadamard(vector<ZZ> *ret, vector<ZZ> *x, vector<ZZ> *y);
    49  	//Calculates the bilinear map Z^n x Z^ -> Z: x(y�t)^T
    50  	static ZZ bilinearMap(vector<ZZ> *x, vector<ZZ> *y, vector<ZZ> *t);
    51  
    52  	static long tolong(string s);
    53  	static string tostring(long s);
    54  	static void write_to_file(const string &filename, double output);
    55  
    56  	//help functions to delete matrices
    57  	static void delete_vector(vector<vector<ZZ> *> *v);
    58  	static void delete_vector(vector<vector<long> *> *v);
    59  	static void delete_vector(vector<vector<Cipher_elg> *> *v);
    60  	static void delete_vector(vector<vector<vector<long> *> *> *v);
    61  	static void delete_vector(vector<vector<vector<ZZ> *> *> *v);
    62  
    63  	// help functions, which pick random values and commit to a vector/matrix
    64  	static void commit_op(vector<ZZ> *a, ZZ &r, Mod_p &com, Pedersen &ped);
    65  	static void commit_op(vector<vector<ZZ> *> *a, vector<ZZ> *r, vector<Mod_p> *com, Pedersen &ped);
    66  };
    67  
    68  #endif /* FUNCTIONS_H_ */