-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtdh.h
70 lines (48 loc) · 1.55 KB
/
tdh.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
#include <relic/relic.h>
struct tdh_pk {
g1_t *vk;
g1_t pk;
g1_t genbar;
bn_t q;
int threshold;
int n;
// Mostly for faster verification of tdh_pk
g1_t *polycoms;
};
struct tdh_sk {
int i;
bn_t sshare;
};
struct tdh_ctxt {
g1_t c;
g1_t u;
g1_t v;
bn_t e;
bn_t f;
uint8_t* L;
size_t lL;
};
struct tdh_dec_share {
int i;
int bottom;
g1_t ui;
bn_t ei;
bn_t fi;
};
void tdh_keygen(struct tdh_pk **pk_res, struct tdh_sk **sks_res, int n, int k);
int tdh_pk_verify(struct tdh_pk *pk);
int tdh_pk_verify_probabilistic(struct tdh_pk *pk);
void tdh_pk_free(struct tdh_pk *pk);
void tdh_sks_free(struct tdh_sk *sks, size_t n);
void tdh_enc(struct tdh_ctxt *ctxt, struct tdh_pk *pk, g1_t m, uint8_t *L,
size_t lL);
void tdh_enc_with_random(struct tdh_ctxt *ctxt, struct tdh_pk *pk, g1_t m,
uint8_t *L, size_t lL, bn_t r);
int tdh_ctxt_verify(struct tdh_ctxt *ctxt, struct tdh_pk *pk);
size_t tdh_ctxt_size(struct tdh_ctxt *ctxt);
void tdh_share_dec(struct tdh_dec_share *d, struct tdh_ctxt *ctxt, struct tdh_pk *pk, struct tdh_sk *sk);
int tdh_share_verify(struct tdh_dec_share *d, struct tdh_ctxt *ctxt, struct tdh_pk *pk);
int tdh_combine(g1_t *msg, struct tdh_ctxt *ctxt, struct tdh_pk *pk, struct tdh_dec_share *ctxtshare, size_t nshares);
int tdh_combine_base(g1_t *msg, struct tdh_ctxt *ctxt, struct tdh_pk *pk,
struct tdh_dec_share *ctxtshare, size_t nshares, int strict);
void calculate_lcoefs_at(bn_t *lcoefs, size_t *idxs, bn_t x, size_t k, bn_t q);