Percy++
A C++ implementation of Private Information Retrieval (PIR) protocols
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
pspir_crypt.h
1 // Percy++ Copyright 2007,2012,2013,2014
2 // Ian Goldberg <iang@cs.uwaterloo.ca>,
3 // Paul Hendry <pshendry@uwaterloo.ca>,
4 // Casey Devet <cjdevet@uwaterloo.ca>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of version 2 of the GNU General Public License as
8 // published by the Free Software Foundation.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // There is a copy of the GNU General Public License in the COPYING file
16 // packaged with this plugin; if you cannot find it, write to the Free
17 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 
20 #ifndef PSPIR_CRYPT_H
21 #define PSPIR_CRYPT_H
22 
23 #include <iostream>
24 #include <gcrypt.h>
25 //NTL includes
26 #include <NTL/ZZ.h>
27 #include <NTL/ZZ_p.h>
28 #include <NTL/ZZ_pX.h>
29 #include <NTL/vec_ZZ.h>
30 //PolyCommit includes
31 #include "../PolyCommit/PolyCommitCommon.h"
32 
33 //Parameter for soundness of ZKPs
34 #define KAPPA 40
35 
36 NTL_CLIENT
37 
38 //NTL_vector_decl(PolyCommitment,vec_PolyCommitment)
39 typedef vector<PolyCommitment> vec_PolyCommitment;
40 NTL_vector_decl(G1,vec_G1)
41 NTL_io_vector_decl(G1,vec_G1)
42 NTL_vector_decl(G2,vec_G2)
43 NTL_io_vector_decl(G2,vec_G2)
44 NTL_vector_decl(GT,vec_GT)
45 NTL_io_vector_decl(GT,vec_GT)
46 
47 
48 unsigned char * hash(std::iostream &stream);
49 ZZ hash_ZZ(std::iostream &stream);
50 G1 hash_G1(const PolyCommitParams &p, std::iostream &stream);
51 
52 gcry_md_hd_t * incr_hash_init();
53 void incr_hash(std::iostream &stream, gcry_md_hd_t *hash_handle_p);
54 unsigned char * incr_hash_final(gcry_md_hd_t *hash_handle_p);
55 //G1 hash_G1(const PolyCommitParams &p, std::iostream &stream);
56 uint64_t hash_long(std::iostream &stream, const unsigned int bits);
57 
58 /*ZZ_p LagrangeCoefficient(const vec_ZZ_p &indices, const ZZ_p &index, const ZZ_p &point = to_ZZ_p(0));
59 
60 inline G1 BLSRecombine(const PolyCommitParams &p, const vec_G1 &sigmavec, const vec_ZZ_p &indices);
61 inline G2 BLSCreateGroupKey(const PolyCommitParams &p, const vec_G2 &pkvec, const vec_ZZ_p &indices);
62 inline G1 BLSSign(const PolyCommitParams &p, const G1 &message, const ZZ_p &sk);
63 inline bool BLSVerify(const PolyCommitParams &p, const G1 &message, const G2 &pk, const G1 &sigma);
64 */
65 
66 ZZ_p dot_product(const vec_ZZ_p &rhovec, const uint64_t *avec);
67 
68 ZZ_pX dot_product(const vec_ZZ_pX &polyvec, const uint64_t *avec);
69 
70 #endif /* PSPIR_CRYPT_H */