当前位置: 首页>>代码示例>>C++>>正文


C++ pbc_malloc函数代码示例

本文整理汇总了C++中pbc_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ pbc_malloc函数的具体用法?C++ pbc_malloc怎么用?C++ pbc_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pbc_malloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cc_pairings_affine

void cc_pairings_affine(element_ptr out, element_t in1[], element_t in2[],
        int n_prod, pairing_t pairing) {
  element_ptr Qbase;
  element_t* Qx = pbc_malloc(sizeof(element_t)*n_prod);
  element_t* Qy = pbc_malloc(sizeof(element_t)*n_prod);
  pptr p = pairing->data;
  int i;
  for(i=0; i<n_prod; i++){
          element_init(Qx[i], p->Fqd);
          element_init(Qy[i], p->Fqd);
        Qbase = in2[i];
          // Twist: (x, y) --> (v^-1 x, v^-(3/2) y)
          // where v is the quadratic nonresidue used to construct the twist.
          element_mul(Qx[i], curve_x_coord(Qbase), p->nqrinv);
          // v^-3/2 = v^-2 * v^1/2
          element_mul(Qy[i], curve_y_coord(Qbase), p->nqrinv2);
  }
  cc_millers_no_denom_affine(out, pairing->r, in1, Qx, Qy, n_prod);
  cc_tatepower(out, out, pairing);

  for(i=0; i<n_prod; i++){
          element_clear(Qx[i]);
                element_clear(Qy[i]);
  }
  pbc_free(Qx);
  pbc_free(Qy);
}
开发者ID:blynn,项目名称:pbc,代码行数:27,代码来源:d_param.c

示例2: fp_init

static void fp_init(element_ptr e) {
	fptr p = (fptr)e->field->data;
	eptr ep;
	e->data = pbc_malloc(sizeof(*ep));
	ep = (eptr)e->data;
	ep->flag = 0;
	ep->d = (mp_limb_t*)pbc_malloc(p->bytes);
}
开发者ID:mahdiz,项目名称:mpclib,代码行数:8,代码来源:montfp.cpp

示例3: run_extend

static val_ptr run_extend(val_ptr v[]) {
	// TODO: Check v[1] is multiz poly.
	field_ptr fx = (field_ptr)pbc_malloc(sizeof(*fx));
	field_init_poly(fx, v[0]->field);
	element_ptr poly = element_new(fx);
	element_set_multiz(poly, (multiz)(v[1]->elem->data));
	field_ptr f = (field_ptr)pbc_malloc(sizeof(*f));
	field_init_polymod(f, poly);
	element_free(poly);
	return val_new_field(f);
}
开发者ID:mahnushm,项目名称:MpcLib,代码行数:11,代码来源:pbc.cpp

示例4: darray_remove_all

void darray_remove_all(darray_ptr a)
{
    a->max = max_init;
    a->count = 0;
    pbc_free(a->item);
    a->item = pbc_malloc(sizeof(void *) * a->max);
}
开发者ID:Jason0218,项目名称:JustPaly,代码行数:7,代码来源:darray.c

示例5: gf32m_init

static void gf32m_init(element_t e) {
    e->data = pbc_malloc(sizeof(gf32m_s));
    gf32m_ptr p = (gf32m_ptr) e->data;
    field_ptr base = BASE(e);
    element_init(p->_0, base);
    element_init(p->_1, base);
}
开发者ID:mahdiz,项目名称:mpclib,代码行数:7,代码来源:ternary_extension_field.cpp

示例6: eval_elem

static val_ptr eval_elem(tree_ptr t) {
	// TODO: Write element_clone(), or at least element_new().
	element_ptr e = (element_ptr)pbc_malloc(sizeof(*e));
	element_init_same_as(e, t->elem);
	element_set(e, t->elem);
	return val_new_element(e);
}
开发者ID:mahnushm,项目名称:MpcLib,代码行数:7,代码来源:pbc.cpp

示例7: run_order

static val_ptr run_order(val_ptr v[]) {
	field_ptr f = v[0]->field;
	element_ptr e = (element_ptr)pbc_malloc(sizeof(*e));
	element_init(e, M);
	element_set_mpz(e, f->order);
	return val_new_element(e);
}
开发者ID:mahnushm,项目名称:MpcLib,代码行数:7,代码来源:pbc.cpp

示例8: eval_define

static val_ptr eval_define(tree_ptr t) {
	val_ptr v = (val_ptr)pbc_malloc(sizeof(*v));
	v->type = v_def;
	v->def = t;
	symtab_put(tab, v, ((tree_ptr)darray_at(t->child, 0))->id);
	return v;
}
开发者ID:mahnushm,项目名称:MpcLib,代码行数:7,代码来源:pbc.cpp

示例9: in

static inline void in(element_t elem, FILE *myfile) {
  int sz;
  fread(&sz, 4, 1, myfile);
  unsigned char* data = pbc_malloc(sz);
  fread(data, sz, 1, myfile);
  element_from_bytes(elem, data);
  pbc_free(data);
}
开发者ID:loiluu,项目名称:weshare,代码行数:8,代码来源:bce.c

示例10: setup_global_broadcast_params

void setup_global_broadcast_params(global_broadcast_params_t *sys, int num_users)
{
  global_broadcast_params_t gbs;

  gbs = pbc_malloc(sizeof(struct global_broadcast_params_s));

  // Setup curve in gbp
  size_t count = strlen(PBC_PAIRING_PARAMS);
  if (!count) pbc_die("input error");
  if (pairing_init_set_buf(gbs->pairing, PBC_PAIRING_PARAMS, count))
    pbc_die("pairing init failed");

  gbs->num_users = num_users;
  element_t *lgs;
  int i;

  lgs = pbc_malloc(2 * num_users * sizeof(element_t));
  if(!(lgs)) {
    printf("\nMalloc Failed\n");
    printf("Didn't finish system setup\n\n");
  }
  //Set g as a chosen public value
  element_init(gbs->g, gbs->pairing->G1);
  i=element_set_str(gbs->g, PUBLIC_G, PBC_CONVERT_BASE);

  //Get alpha from Zp as mentioned in the paper
  element_init_Zr(gbs->alpha, gbs->pairing);
  element_random(gbs->alpha);   //pick random alpha value and later delete from memory
  //i=element_set_str(gbs->alpha, PRIVATE_ALPHA, PBC_CONVERT_BASE); //alpha is initialised as secret and later removed from memory

  //Make the 0th element equal to g^alpha
  element_init(lgs[0], gbs->pairing->G1);
  element_pow_zn(lgs[0],gbs->g, gbs->alpha);

  //Fill in the gs and the hs arrays
  for(i = 1; i < 2*num_users; i++) {
    //raise alpha to one more power
    element_init(lgs[i], gbs->pairing->G1);
    element_pow_zn(lgs[i], lgs[i-1], gbs->alpha);
  }
  element_clear(lgs[num_users]);  //remove g^(alpha^(n+1)) as it can leak info about parameters

  //For simplicity & so code was easy to read
  gbs->gs = lgs;
  *sys = gbs;
}
开发者ID:bawejakunal,项目名称:MyCrest,代码行数:46,代码来源:bgw.c

示例11: sn_init

static void sn_init(element_ptr e) {
  field_ptr f = e->field->data;
  e->data = pbc_malloc(sizeof(point_t));
  point_ptr p = e->data;
  element_init(p->x, f);
  element_init(p->y, f);
  p->inf_flag = 1;
}
开发者ID:jun-kim,项目名称:SEDA,代码行数:8,代码来源:singular.c

示例12: tree_new_z

tree_ptr tree_new_z(const char* s) {
	element_ptr e = (element_ptr)pbc_malloc(sizeof(*e));
	element_init(e, M);
	element_set_str(e, s, 0);
	tree_ptr t = tree_new(eval_elem);
	t->elem = e;
	return t;
}
开发者ID:mahnushm,项目名称:MpcLib,代码行数:8,代码来源:pbc.cpp

示例13: fun_cmp

static val_ptr fun_cmp(val_ptr v[], int(*fun)(int)) {
	int i = element_cmp(v[0]->elem, v[1]->elem);
	element_ptr e = (element_ptr)pbc_malloc(sizeof(*e));
	element_init(e, M);
	element_set_si(e, fun(i));
	v[0]->elem = e;
	return v[0];
}
开发者ID:mahnushm,项目名称:MpcLib,代码行数:8,代码来源:pbc.cpp

示例14: point_init

static void point_init(element_t e) {
    field_ptr f = BASE(e);
    e->data = pbc_malloc(sizeof(struct point_s));
    point_ptr p = DATA(e);
    element_init(p->x, f);
    element_init(p->y, f);
    p->isinf = 1;
}
开发者ID:JasonSome,项目名称:pbc,代码行数:8,代码来源:eta_T_3.c

示例15: curve_init

static void curve_init(element_ptr e) {
	curve_data_ptr cdp = (curve_data_ptr)e->field->data;
	point_ptr p; 
	e->data = pbc_malloc(sizeof(*p));
	p = (point_ptr)e->data;
  element_init(p->x, cdp->field);
  element_init(p->y, cdp->field);
  p->inf_flag = 1;
}
开发者ID:mahdiz,项目名称:mpclib,代码行数:9,代码来源:curve.cpp


注:本文中的pbc_malloc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。