本文整理汇总了C++中element_clear函数的典型用法代码示例。如果您正苦于以下问题:C++ element_clear函数的具体用法?C++ element_clear怎么用?C++ element_clear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了element_clear函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cc_tatepower
// The final powering, where we standardize the coset representative.
static void cc_tatepower(element_ptr out, element_ptr in, pairing_t pairing) {
pptr p = pairing->data;
#define qpower(sign) { \
polymod_const_mul(e2, inre[1], p->xpowq); \
element_set(e0re, e2); \
polymod_const_mul(e2, inre[2], p->xpowq2); \
element_add(e0re, e0re, e2); \
element_add(e0re0, e0re0, inre[0]); \
\
if (sign > 0) { \
polymod_const_mul(e2, inim[1], p->xpowq); \
element_set(e0im, e2); \
polymod_const_mul(e2, inim[2], p->xpowq2); \
element_add(e0im, e0im, e2); \
element_add(e0im0, e0im0, inim[0]); \
} else { \
polymod_const_mul(e2, inim[1], p->xpowq); \
element_neg(e0im, e2); \
polymod_const_mul(e2, inim[2], p->xpowq2); \
element_sub(e0im, e0im, e2); \
element_sub(e0im0, e0im0, inim[0]); \
} \
}
if (p->k == 6) {
// See thesis, section 6.9, "The Final Powering", which gives a formula
// for the first step of the final powering when Fq6 has been implemented
// as a quadratic extension on top of a cubic extension.
element_t e0, e2, e3;
element_init(e0, p->Fqk);
element_init(e2, p->Fqd);
element_init(e3, p->Fqk);
element_ptr e0re = element_x(e0);
element_ptr e0im = element_y(e0);
element_ptr e0re0 = ((element_t *) e0re->data)[0];
element_ptr e0im0 = ((element_t *) e0im->data)[0];
element_t *inre = element_x(in)->data;
element_t *inim = element_y(in)->data;
// Expressions in the formula are similar, hence the following function.
qpower(1);
element_set(e3, e0);
element_set(e0re, element_x(in));
element_neg(e0im, element_y(in));
element_mul(e3, e3, e0);
qpower(-1);
element_mul(e0, e0, in);
element_invert(e0, e0);
element_mul(in, e3, e0);
element_set(e0, in);
// We use Lucas sequences to complete the final powering.
lucas_even(out, e0, pairing->phikonr);
element_clear(e0);
element_clear(e2);
element_clear(e3);
} else {
element_pow_mpz(out, in, p->tateexp);
}
#undef qpower
}
示例2: element_init
//c_iとk_iをペアリングする関数
//¬記号で別々の処理する
//(v_i - x_t)も必要→とりあえず置いておこう……→一応できた?
Element *pairing_c_k(EC_PAIRING p, rho_i *rho, EC_POINT *c, EC_POINT *k, mpz_t *alpha_i) {
int i;
Element *result;
result = (Element*)malloc(sizeof(Element));
Element egg, tempegg1, tempegg2;
element_init(egg, p->g3);
element_init(tempegg1, p->g3);
element_init(tempegg2, p->g3);
element_init(*result, p->g3);
mpz_t temp1;
mpz_init(temp1);
mpz_t temp2;
mpz_init(temp2);
mpz_t order;
mpz_init(order);
mpz_set(order, *pairing_get_order(p));
element_set_one(*result);
if (alpha_i == NULL && rho == NULL) { //e(c_0, k_0)
for (i = 0; i < 5; i++) {
pairing_map(tempegg1, c[i], k[i], p);
element_mul(tempegg2, tempegg1, *result);
element_set(*result, tempegg2);
}
}
else if (mpz_cmp_ui(*alpha_i, 0) == 0) {//return 1
}
else if (rho->is_negated == FALSE) {
for (i = 0; i < 7; i++) {
pairing_map(tempegg1, c[i], k[i], p);
element_mul(tempegg2, tempegg1, *result);
element_set(*result, tempegg2);
}
element_pow(tempegg1, *result, *alpha_i);
element_set(*result, tempegg1);
}
else { //is_negated == TRUE
for (i = 0; i < 7; i++) {
pairing_map(tempegg1, c[i], k[i], p);
element_mul(tempegg2, tempegg1, *result);
element_set(*result, tempegg2);
}
mpz_set_ui(temp1, rho->v_t[0]); //v_i - x_t
mpz_invert(temp2, temp1, order);
mpz_mul(temp1, temp2, *alpha_i); // alpha_i / (v_i - x_t)
mpz_mod(*alpha_i, temp1, order);
element_pow(tempegg1, *result, *alpha_i);
element_set(*result, tempegg1);
}
mpz_clear(order);
mpz_clear(temp2);
mpz_clear(temp1);
element_clear(egg);
element_clear(tempegg1);
element_clear(tempegg2);
return result;
}
示例3: bb_free_pk
void bb_free_pk(bb_public_key_t pk)
{
element_clear(pk->g1);
element_clear(pk->g2);
element_clear(pk->u);
element_clear(pk->v);
element_clear(pk->z);
}
示例4: bbs_free_gsk
void bbs_free_gsk(bbs_group_private_key_t *gsk, int n)
{
int i = 0;
for(i = 0; i < n; i++) {
element_clear(gsk[i]->A);
element_clear(gsk[i]->x);
element_clear(gsk[i]->pr_A_g2);
}
}
示例5: sn_add
static void sn_add(element_t c, element_t a, element_t b) {
point_ptr r = c->data;
point_ptr p = a->data;
point_ptr q = b->data;
if (p->inf_flag) {
sn_set(c, b);
return;
}
if (q->inf_flag) {
sn_set(c, a);
return;
}
if (!element_cmp(p->x, q->x)) {
if (!element_cmp(p->y, q->y)) {
if (element_is0(p->y)) {
r->inf_flag = 1;
return;
} else {
sn_double_no_check(r, p);
return;
}
}
//points are inverses of each other
r->inf_flag = 1;
return;
} else {
element_t lambda, e0, e1;
element_init(lambda, p->x->field);
element_init(e0, p->x->field);
element_init(e1, p->x->field);
//lambda = (y2-y1)/(x2-x1)
element_sub(e0, q->x, p->x);
element_invert(e0, e0);
element_sub(lambda, q->y, p->y);
element_mul(lambda, lambda, e0);
//x3 = lambda^2 - x1 - x2 - 1
element_square(e0, lambda);
element_sub(e0, e0, p->x);
element_sub(e0, e0, q->x);
element_set1(e1);
element_sub(e0, e0, e1);
//y3 = (x1-x3)lambda - y1
element_sub(e1, p->x, e0);
element_mul(e1, e1, lambda);
element_sub(e1, e1, p->y);
element_set(r->x, e0);
element_set(r->y, e1);
r->inf_flag = 0;
element_clear(lambda);
element_clear(e0);
element_clear(e1);
}
}
示例6: pbgp_ibe_signature_clear
void
pbgp_ibe_signature_clear(ibe_signature_t *s)
{
if (s) {
element_clear(s->u);
element_clear(s->v);
element_clear(s->w);
xfree(s);
}
}
示例7: FreeCT
void FreeCT(ct_t myct)
{
if(!myct) {
printf("error: null pointer passed to freeCT\n");
return;
}
element_clear(myct->C0);
element_clear(myct->C1);
return;
}
示例8: GT_random
static void GT_random(element_ptr e) {
element_t a, b;
element_init(a, e->field->pairing->G1);
element_init(b, e->field->pairing->G1);
element_random(a);
element_random(b);
element_pairing(e, a, b);
element_clear(a);
element_clear(b);
}
示例9: curve_mul
static void curve_mul(element_ptr c, element_ptr a, element_ptr b) {
curve_data_ptr cdp = (curve_data_ptr)a->field->data;
point_ptr r = (point_ptr)c->data, p = (point_ptr)a->data, q = (point_ptr)b->data;
if (p->inf_flag) {
curve_set(c, b);
return;
}
if (q->inf_flag) {
curve_set(c, a);
return;
}
if (!element_cmp(p->x, q->x)) {
if (!element_cmp(p->y, q->y)) {
if (element_is0(p->y)) {
r->inf_flag = 1;
return;
} else {
double_no_check(r, p, cdp->a);
return;
}
}
//points are inverses of each other
r->inf_flag = 1;
return;
} else {
element_t lambda, e0, e1;
element_init(lambda, cdp->field);
element_init(e0, cdp->field);
element_init(e1, cdp->field);
//lambda = (y2-y1)/(x2-x1)
element_sub(e0, q->x, p->x);
element_invert(e0, e0);
element_sub(lambda, q->y, p->y);
element_mul(lambda, lambda, e0);
//x3 = lambda^2 - x1 - x2
element_square(e0, lambda);
element_sub(e0, e0, p->x);
element_sub(e0, e0, q->x);
//y3 = (x1-x3)lambda - y1
element_sub(e1, p->x, e0);
element_mul(e1, e1, lambda);
element_sub(e1, e1, p->y);
element_set(r->x, e0);
element_set(r->y, e1);
r->inf_flag = 0;
element_clear(lambda);
element_clear(e0);
element_clear(e1);
}
}
示例10: main
int main(int argc, char ** argv) {
pbc_param_t ec_params;
pairing_t pairing;
unsigned int rbits = 40, qbits = 128;
element_t *g1, *g2, *gt;
for (int s = 10; s <= 1000; s += 10) {
while (qbits <= 4096) {
fprintf(stderr, "%d", qbits);
pbc_param_init_a_gen(ec_params, rbits, qbits);
pairing_init_pbc_param(pairing, ec_params);
element_init_G1(g1, pairing);
element_init_G2(g2, pairing);
element_init_GT(gt, pairing);
struct timeval tv1, tv2;
int bc = element_length_in_bytes(g1);
for (int i = 0; i < 100; i++) {
if (0 == i % 10)
fprintf(stderr, ".");
element_random(g1);
element_random(g2);
gettimeofday(&tv1, NULL);
pairing_apply(gt, g1, g2, pairing);
gettimeofday(&tv2, NULL);
double time = tv2.tv_sec - tv1.tv_sec;
time *= (1000 * 1000);
time += tv2.tv_usec - tv1.tv_usec;
fprintf(stdout, "%d %d %d %d %d\n", bc, rbits, qbits, i, ((int) time));
}
for (int j = 0; j < s; j++) {
element_clear(g1[j]);
element_clear(g2[j]);
element_clear(gt[j]);
}
rbits *= 2;
qbits *= 2;
fprintf(stderr, "\n");
}
free(g1);
free(g2);
free(g3);
}
}
示例11: FreeBCS
void FreeBCS(broadcast_system_t bcs)
{
if(!bcs) {
printf("error: null pointer passed to freeBCS\n");
return;
}
element_clear(bcs->encr_prod);
element_clear(bcs->pub_key);
element_clear(bcs->priv_key);
return;
}
示例12: miller
void miller(element_t z, element_t PR, element_t R, element_t P, element_t Q)
{
int m = mpz_sizeinbase(order, 2) - 2;
element_t Z;
element_t z1;
element_t x1;
element_init_same_as(Z, PR);
element_set(Z, P);
element_set1(z);
element_init_same_as(z1, z);
element_init_same_as(x1, z);
do_vert(x1, PR, Q);
element_printf("vert(P+R) %B\n", x1);
do_line(z1, P, R, Q);
element_printf("line(P,R) %B\n", z1);
element_div(x1, x1, z1);
element_printf("x1 %B\n", x1);
element_set(z, x1);
for (;;) {
printf("iteration %d: %d\n", m, mpz_tstbit(order,m));
element_square(z, z);
element_printf("squared: %B\n", z);
do_tangent(z1, Z, Q);
element_mul(z, z, z1);
element_double(Z, Z);
do_vert(z1, Z, Q);
element_div(z, z, z1);
element_printf("pre-if: %B\n", z);
if (mpz_tstbit(order, m)) {
element_mul(z, z, x1);
do_vert(z1, P, Q);
element_mul(z, z, z1);
element_printf("done %B\n", z);
/*
do_line(z1, Z, P, Q);
element_mul(z, z, z1);
element_add(Z, Z, P);
do_vert(z1, Z, Q);
element_div(z, z, z1);
*/
}
if (!m) break;
m--;
}
element_clear(x1);
element_clear(z1);
}
示例13: bn254_fp2_clear
void bn254_fp2_clear(Element x)
{
if (x->data != NULL)
{
element_clear(rep0(x));
element_clear(rep1(x));
free(x->data);
x->data = NULL;
}
}
示例14: FreePK
void FreePK(priv_key_t key)
{
if(!key) {
printf("error: null pointer passed to freePK\n");
return;
}
element_clear(key->g_i_gamma);
element_clear(key->g_i);
element_clear(key->decr_prod);
return;
}
示例15: pbgp_ibe_keypair_clear
void
pbgp_ibe_keypair_clear(ibe_keypair_t *keys)
{
if (keys) {
element_clear(keys->pub0);
element_clear(keys->priv0);
element_clear(keys->pub1);
element_clear(keys->priv1);
xfree(keys);
}
}