27 assert(signatures != NULL);
29 for (
int i = 0; i < info->
k; i++) {
30 assert(signatures[i] != NULL);
33 assert(document != NULL && document->
data != NULL);
38 mpz_t x, n, e, u, delta, e_prime, w, s_i, lambda_k_2, aux, a, b, wa, xb, y;
39 mpz_inits(x, n, e, u, delta, e_prime, w, s_i, lambda_k_2, aux, a, b, wa, xb, y,
49 if(mpz_jacobi(x, n) == -1) {
52 mpz_powm(ue, u, e, n);
59 mpz_fac_ui(delta, info->
l);
60 mpz_set_ui(e_prime, 4);
66 for (
int i = 0; i < k; i++) {
67 int id = signatures[i]->
id;
70 mpz_mul_ui(lambda_k_2, lambda_k_2, 2);
72 mpz_powm(aux, s_i, lambda_k_2, n);
77 mpz_gcdext(aux, a, b, e_prime, e);
79 mpz_powm(wa, w, a, n);
80 mpz_powm(xb, x, b, n);
87 mpz_invert(inv_u, u, n);
96 mpz_clears(x, n, e, u, delta, e_prime, w, s_i, lambda_k_2, aux, a, b, wa, xb,
99 assert(out != NULL && out->
data != NULL);
107 mpz_init_set_si(num, 1);
108 mpz_init_set_si(den, 1);
110 for (
int i = 0; i < k; i++) {
113 mpz_mul_si(num, num,
id);
114 mpz_mul_si(den, den,
id - j);
118 mpz_mul(out, out, num);
119 mpz_fdiv_q(out, out, den);
121 mpz_clears(num, den, NULL);
void lagrange_interpolation(mpz_t out, int j, int k, const signature_share_t **S, const mpz_t delta)
Structure that's stores a pointer that points to data_len bytes.
Structure that represents a signature share, to be joined generating a standard RSA signatures...
#define TC_BYTES_TO_MPZ(z, bytes)
bytes_t * tc_join_signatures(const signature_share_t **signatures, const bytes_t *document, const key_metainfo_t *info)
bytes_t * tc_init_bytes(void *bs, size_t len)
#define TC_MPZ_TO_BYTES(bytes, z)