-
Notifications
You must be signed in to change notification settings - Fork 6
/
hadamardsc.h
87 lines (56 loc) · 1.35 KB
/
hadamardsc.h
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
#ifndef CPHAD_H
#define CPHAD_H
#include "snark.h"
#include "sumcheck.h"
#include "poly.h"
using HadRand = vector<CommRand>;
using HadField = CommRand;
struct HadIn
{
vector<HadField> a, b, c;
};
struct HadRel
{
size_t n;
HadRel(size_t _n) : n(_n) { } ;
using InT = HadIn;
};
struct HadKey {
long n;
long d; // logarithm of n
CPPoly *cppoly;
SumcheckKey *scCrs;
HadKey(long _n, long _d, CPPoly *_cppoly, SumcheckKey *_scKey) :
n(_n), d(_d), cppoly(_cppoly), scCrs(_scKey) {}
};
struct HadPf {
// randomness r
HadRand r;
PolyPf polyProof;
Comm uProdEvalCm;
SumcheckPf *sumcheckPf;
HadPf(long d)
{
r.resize(d);
}
};
// TODO: make this a subclass of CompositeCPSnark
class CPHad : public CPSnark<HadRel, HadKey, HadPf, CPPIn, CPVIn>
{
public:
using RelT = HadRel;
using InT = RelT::InT; // XXX: These lines should be moved earlier in the class hierarchy
CPHad(CommScheme *_commScm, CPPoly *_cppoly) :
CPSnark(_commScm), cpsumcheck(_commScm, _cppoly), cppoly(_cppoly)
{
addBenchmarkSlave(&cpsumcheck, "Sumcheck in Hadamard");
}
~CPHad() {}
virtual HadKey* keygen(const HadRel *rel) override;
virtual HadPf* prove(const HadKey *crs, const CPPIn &in) override;
virtual bool verify(const HadKey *crs, const CPVIn &, const HadPf *pf) override;
CPSumcheck cpsumcheck;
CPPoly *cppoly;
protected:
};
#endif