1 #include <gtest/gtest.h>
6 static dipe_param_t param
;
8 TEST(SSText
, SSBaseTest
) {
10 element_init_G1(types
[0], *dipe_get_pairing(param
));
11 element_init_G2(types
[1], *dipe_get_pairing(param
));
12 element_init_GT(types
[2], *dipe_get_pairing(param
));
16 element_t shared_secret
;
17 element_t recovered_secret
;
19 element_t
* shares
[parties
];
20 element_t
* dummy_shares
[dummies
];
21 element_t identities
[parties
];
22 element_t dummy_identities
[dummies
];
24 for (size_t j
= 0; j
< parties
; ++j
) {
25 shares
[j
] = (element_t
*)calloc(1, sizeof(element_t
));
26 element_init_Zr(identities
[j
], *dipe_get_pairing(param
));
27 element_random(identities
[j
]);
30 dummy_shares
[j
] = (element_t
*)calloc(1, sizeof(element_t
));
31 element_init_Zr(dummy_identities
[j
], *dipe_get_pairing(param
));
32 element_random(dummy_identities
[j
]);
37 for (size_t i
= 0; i
< 3; ++i
) {
38 // element_init_same_as(shared_secret, types[i]);
39 // element_init_same_as(recovered_secret, types[i]);
41 for (size_t j
= 0; j
< parties
; ++j
) {
42 element_init_same_as(shares
[j
][0], types
[i
]);
43 //element_init_same_as(dummy_shares[j][0], types[i]);
44 element_random(shares
[j
][0]);
47 dipe_ss_share(param
, parties
, identities
, parties
, dummy_identities
, 1, shares
, &shared_secret
, dummy_shares
);
48 dipe_ss_recover(param
, parties
, identities
, 1, shares
, &recovered_secret
);
49 EXPECT_EQ(element_cmp(shared_secret
, recovered_secret
), 0);
50 element_clear(recovered_secret
);
51 dipe_ss_recover(param
, parties
, dummy_identities
, 1, dummy_shares
, &recovered_secret
);
52 EXPECT_EQ(element_cmp(shared_secret
, recovered_secret
), 0);
53 element_clear(recovered_secret
);
55 for (size_t j
= 0; j
< parties
; ++j
) {
56 element_clear(shares
[j
][0]);
57 element_clear(dummy_shares
[j
][0]);
60 element_clear(shared_secret
);
63 for (size_t i
= 0; i
< 3; ++i
) {
64 element_clear(types
[i
]);
66 for (size_t j
= 0; j
< parties
; ++j
) {
67 element_clear(identities
[j
]);
68 element_clear(dummy_identities
[j
]);
71 free(dummy_shares
[j
]);
76 int main(int argc
, char **argv
) {
77 ::testing::InitGoogleTest(&argc
, argv
);
79 dipe_init(fopen("../tests/a.param", "r"), ¶m
);
81 int result
= RUN_ALL_TESTS();
82 dipe_free_param(param
);