-
Notifications
You must be signed in to change notification settings - Fork 2
/
BLcanonical.h
66 lines (55 loc) · 2.65 KB
/
BLcanonical.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
/*
Testbed for empirical evaluation of KP-ABE schemes, according to Crampton, Pinto (CSF2014).
Code by: Alexandre Miranda Pinto
This file holds the declarations for the implementation of a specific Secret Sharing scheme: Benaloh-Leichter for canonical policies
There are two classes implemented here:
- BLAccessPolicy is a subclass of the abstract AccessPolicy
- BLSS is a subclass of the abstract SecretSharing
*/
#ifndef DEF_UTILS
#include "utils.h"
#endif
#ifndef DEF_SECRET_SHARING
#include "secretsharing.h"
#endif
#define DEF_BL_CANON
class BLAccessPolicy : public AccessPolicy{
std::string m_description; // to facilitate parsing, the description should be input in prefix, that is functional, notation.
vector<vector<int>> m_minimal_sets;
void init();
protected:
bool satisfyMinimalSet(int setID, vector<int> set, vector<std::string> shareIDs, vector<int> &satisfyingSharesIndices) const;
public:
static std::vector<std::vector<int>> parseFromExpression(int level, std::string expr);
vector<vector<int> >& getMinimalSets();
BLAccessPolicy();
BLAccessPolicy(const string &description, const int n); // constructor with participants numbered from 1 to n, each participant holding one share
BLAccessPolicy(const string &description, const vector<int> &parts); // constructor with participants specified freely, each participant holding one share
BLAccessPolicy(const BLAccessPolicy& other);
BLAccessPolicy& operator=(const BLAccessPolicy& other);
std::string getDescription() const;
unsigned int getNumShares();
// bool evaluate(const vector<ShareTuple> shares, vector<ShareTuple> &witnessShares) const;
static std::string createShareID(std::string setID, std::string partID);
bool evaluateIDs(const vector<std::string> shareIDs, vector<int> &witnessSharesIndices) const;
vector<Big> findCoefficients(const vector<std::string> shareIDs, const Big& order) const;
void obtainCoveredFrags(const vector<int> &atts, vector<int> &attFragIndices, vector<int> &keyFragIndices, vector<std::string> &coveredShareIDs) const;
};
class BLSS : public SecretSharing
{
private:
shared_ptr<BLAccessPolicy> i_policy;
vector<Big> m_randomness;
protected:
void init();
void initPolicy();
void manageRandomness(RandomnessActions action);
public:
BLSS(shared_ptr<BLAccessPolicy> policy, PFC &pfc);
BLSS(shared_ptr<BLAccessPolicy> policy, const Big &order, PFC &pfc);
// virtual inherited methods:
vector<Big> getDistribRandomness();
std::vector<ShareTuple> distribute_random(const Big& s);
std::vector<ShareTuple> distribute_determ(const Big& s, const vector<Big>& randomness);
Big reconstruct (const vector<ShareTuple> shares);
};