Repository navigation
Expand file tree
/
Copy pathpercyserver.h
More file actions
98 lines (83 loc) · 3.64 KB
/
Copy pathpercyserver.h
File metadata and controls
98 lines (83 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Percy++ Copyright 2007,2012,2013 Ian Goldberg <iang@cs.uwaterloo.ca>,
// Casey Devet <cjdevet@cs.uwaterloo.ca>,
// Paul Hendry <pshdenry@uwaterloo.ca>,
// Ryan Henry <rhenry@cs.uwaterloo.ca>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of version 2 of the GNU General Public License as
// published by the Free Software Foundation.
//
// This program 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.
//
// There is a copy of the GNU General Public License in the COPYING file
// packaged with this plugin; if you cannot find it, write to the Free
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA
#ifndef __PERCYSERVER_H__
#define __PERCYSERVER_H__
#include <iostream>
#include <array>
#include <vec_ZZ_p.h>
#include "datastore.h"
#include "percyparams.h"
#include "gf2e.h"
// Sorry for being a terrible programmer, but...
// this is also defined in percyclient.h!
constexpr dbsize_t WORDS_PER_BLOCK = 1024;
NTL_CLIENT
// The class for Percy++ servers
class PercyServer {
public:
// Initialize a server with the given DataStore.
PercyServer(DataStore * datastore) : byzantine(false),
synchronized(false),
server_unsynchronized(false),
datastore(datastore) {}
~PercyServer() {}
// Tell the server to be Byzantine
void be_byzantine() { byzantine = true; }
// Tell the server that it is synchronized
void set_synchronized() { synchronized = true; }
// Tell the server that it should hold unsynchronized files
void set_server_unsynchronized(PercyServerParams ¶ms);
// Handle a request.
virtual bool handle_request(PercyServerParams ¶ms, std::istream &is,
std::ostream &os);
private:
bool handle_request_ZZ_p(PercyServerParams ¶ms, std::istream &is,
std::ostream &os);
bool handle_request_GF28(PercyServerParams ¶ms, std::istream &is,
std::ostream &os);
template <typename GF2E_Element>
bool handle_request_GF2E(PercyServerParams ¶ms,
std::istream &is, std::ostream &os);
bool handle_request_Chor(PercyServerParams ¶ms, std::istream &is,
std::ostream &os);
// template <typename GF2E_Element>
template <typename GF2E_Element>
bool handle_request_RS_Sync(PercyServerParams ¶ms, std::istream &is,
std::ostream &os);
template <typename GF2E_Element>
bool handle_sync_request_RS_Sync(PercyServerParams ¶ms, std::istream &is,
std::ostream &os);
// compute the actual hashes
// template <typename GF2E_Element>
template<dbsize_t arrSize>
void compute_outputvec_sync(const GF216_Element *data, std::vector<std::array<GF216_Element, arrSize> > &outputvec,
dbsize_t num_blocks, dbsize_t words_per_block, dbsize_t max_unsynchronized, dbsize_t num_rows, GF216_Element q_x);
// hash computation methods
void compute_hashes(PercyServerParams ¶ms);
bool byzantine;
bool synchronized; // tells whether this server has undergone the synchronization process
bool server_unsynchronized; // flags whether this server is the one that contains unsynchronized files
vector<dbsize_t> unsynchronized_files; // lists the indices of unsynchronized files in the database
void compute_one(ZZ_p *value, bool hybrid_protection,
dbsize_t num_blocks, nqueries_t num_queries,
const vec_ZZ_p *inputvector, dbsize_t c);
protected:
DataStore *datastore;
};
#endif