8 eb_t
hTbl[RELIC_EB_TABLE_MAX];
15 : io(io), party(party) , length(length) {
21 gTbl = eb_curve_get_tab();
32 eb_mul_fix_norm(h, gTbl, w);
33 eb_mul_fix_norm(t, gTbl, r);
37 bn_mul_mod(c, c, w, q);
38 bn_add_mod(c, c, r, q);
51 eb_mul_norm(hc, h, c);
52 eb_mul_fix_norm(gs, gTbl, s);
53 eb_add_norm(hc, hc, t);
54 return (eb_cmp(hc, gs)==CMP_EQ);
61 if(
com!=
nullptr)
delete[]
com;
69 eb_mul_fix_norm(com[0], gTbl, r);
70 eb_mul_fix_norm(com[1], hTbl, r);
71 if(b) eb_add_norm(com[1], com[1], g);
75 eb_mul_fix_norm(tmp, gTbl, r_diff);
76 eb_add_norm(tmp, new_com[0], tmp);
77 if(eb_cmp(tmp, old_com[0])!=CMP_EQ)
80 eb_mul_fix_norm(tmp, hTbl, r_diff);
81 eb_add_norm(tmp, new_com[1], tmp);
82 if(eb_cmp(tmp, old_com[1])!=CMP_EQ)
89 eb_t tmp; eb_newl(tmp);
93 for(
int i = 0; i <
length; ++i) {
95 eb_mul_fix_norm(
nA[i][0], gTbl, elgl_s[i][0]);
96 eb_mul_fix_norm(tmp, hTbl,
elgl_t[i][0]);
97 eb_add_norm(
nA[i][0],
nA[i][0], tmp);
99 eb_mul_fix_norm(
nA[i][1], gTbl, elgl_s[i][1]);
100 eb_mul_fix_norm(tmp, hTbl,
elgl_t[i][1]);
101 eb_add_norm(
nA[i][1],
nA[i][1], tmp);
104 eb_mul_norm(
nB[i][0], com[i][0], elgl_s[i][0]);
105 eb_mul_norm(tmp, com[i][1],
elgl_t[i][0]);
106 eb_add_norm(
nB[i][0],
nB[i][0], tmp);
107 eb_add_norm(
nB[i][0],
nB[i][0], X[i][0]);
109 eb_mul_norm(
nB[i][1], com[i][0], elgl_s[i][1]);
110 eb_sub_norm(tmp, com[i][1], g);
111 eb_mul_norm(tmp, tmp,
elgl_t[i][1]);
112 eb_add_norm(
nB[i][1],
nB[i][1], tmp);
113 eb_add_norm(
nB[i][1],
nB[i][1], X[i][1]);
116 for(
int i = 0; i <
length; ++i) {
125 for(
int i = 0; i <
length; ++i) {
138 for(
int i = 0; i <
length; ++i) {
139 commit(r[i], com, b[i], &prg);
143 for(
int i = 0; i <
length; ++i) {
146 int ind = b[i]? 1: 0;
147 eb_mul_norm(X[i],
nA[i][ind], r[i]);
148 eb_sub_norm(X[i],
nB[i][ind], X[i]);
155 for(
int i = 0; i <
length; ++i) {
159 eb_copy(Xs[i][ind], X[i]);
160 eb_mul_norm(Ar,
nA[i][1-ind], r[i]);
161 eb_sub_norm(Ar,
nB[i][1-ind], Ar);
162 eb_mul_fix_norm(gt, gTbl, t[1-ind]);
164 eb_sub_norm(Xs[i][1-ind], Ar, gt);
166 eb_add_norm(Xs[i][1-ind], Ar, gt);
173 for(
int i = 0; i <
length; ++i) {
174 eb_mul_norm(com[i][0], com[i][0], omega);
175 b[i] = (eb_cmp(com[i][0], com[i][1]) != CMP_EQ);
eb_t hTbl[RELIC_EB_TABLE_MAX]
Definition: elgamal.h:8
void send_bn(const bn_t *bn, size_t num)
Definition: io_channel.h:160
int party
Definition: elgamal.h:11
void recovery(bool *b, bn_t omega)
Definition: elgamal.h:172
eb_tpl * nB
Definition: elgamal.h:64
void send(eb_tpl *X)
Definition: elgamal.h:86
Definition: net_io_channel.h:22
bn_t w
Definition: elgamal.h:10
bn_tpl * elgl_s
Definition: elgamal.h:65
void recv_eb(eb_t *eb, size_t num)
Definition: io_channel.h:150
eb_t eb_tpl[2]
Definition: utils_ec.h:14
bool check_eq(eb_tpl new_com, eb_tpl old_com, bn_t r_diff)
Definition: elgamal.h:73
Elgamal(NetIO *io, int party, int length)
Definition: elgamal.h:14
bn_t * r
Definition: elgamal.h:66
void send_eb(const eb_t *eb, size_t num)
Definition: io_channel.h:140
NetIO * io
Definition: elgamal.h:6
bn_t q
Definition: elgamal.h:10
PRG prg
Definition: elgamal.h:12
~Elgamal()
Definition: elgamal.h:58
const eb_t * gTbl
Definition: elgamal.h:9
bool setup_omega()
Definition: elgamal.h:25
bn_t bn_tpl[2]
Definition: utils_ec.h:15
int length
Definition: elgamal.h:13
void recv(eb_t *X, bool *b)
Definition: elgamal.h:133
void open()
Definition: elgamal.h:124
#define ALICE
Definition: utils.h:15
void commit(bn_t r, eb_tpl com, bool b, PRG *prg)
Definition: elgamal.h:67
void initialize_relic()
Definition: utils_ec.hpp:8
void random_bn(T t, L... l)
Definition: prg.h:87
eb_tpl * nA
Definition: elgamal.h:64
void recv_bn(bn_t *bn, size_t num)
Definition: io_channel.h:171
bn_tpl * elgl_t
Definition: elgamal.h:65
eb_t h
Definition: elgamal.h:7
eb_tpl * com
Definition: elgamal.h:64
void open(eb_tpl *Xs, bool *b, eb_t *X)
Definition: elgamal.h:152
eb_t g
Definition: elgamal.h:7