• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ rep0函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: bn254_fp6_is_sqr

int bn254_fp6_is_sqr(const Element x)
{
    int k = 1;

    Element *t = field(x)->base->tmp;

    if (element_is_zero(x)) {
        return FALSE;
    }

    k *= bn254_fp2_is_sqr(rep2(x)) ? 1 : -1;

    bn254_fp2_sqr(t[1], rep1(x));
    bn254_fp2_mul(t[2], rep0(x), rep2(x));
    bn254_fp2_sub(t[1], t[1], t[2]);      // t1 = x1^2-x0*x2
    bn254_fp2_mul(t[2], rep0(x), rep1(x));
    bn254_fp2_sqr(t[3], rep2(x));
    bn254_fp2_xi_mul(t[3], t[3]);
    bn254_fp2_sub(t[2], t[2], t[3]);      // t2 = x0*x1-x2^2*xi
    bn254_fp2_inv(t[1], t[1]);
    bn254_fp2_mul(t[1], t[1], t[2]);      // t1 = t2 / t1

    bn254_fp2_inv(t[2], rep2(x));
    bn254_fp2_mul(t[3], t[2], rep1(x));
    bn254_fp2_sub(t[3], t[3], t[1]);
    bn254_fp2_mul(t[3], t[3], t[1]);      // t3 = ((x1/x2)-t1)t1

    bn254_fp2_mul(t[2], t[2], rep0(x));
    bn254_fp2_sub(t[2], t[2], t[3]);      // t2 = (x0/x2)-t3

    k *= bn254_fp2_is_sqr(t[2]) ? 1 : -1;

    return (k == 1);
}
开发者ID:TEPLA,项目名称:tepla-library,代码行数:34,代码来源:bn254_fp6.c


示例2: bn254_fp6_from_oct

void bn254_fp6_from_oct(Element x, const unsigned char *os, const size_t size)
{
    mpz_t quo, rem;

    if (size < 190) {
        fprintf(stderr, "error: please set up the enought buffer for element\n");
        exit(300);
    }

    mpz_init(quo);
    mpz_init(rem);

    mpz_import(quo, size, 1, sizeof(*os), 1, 0, os);

    mpz_tdiv_qr(quo, rem, quo, field(x)->base->base->order);
    mpz_set(rep(rep0(rep0(x))), rem);
    mpz_tdiv_qr(quo, rem, quo, field(x)->base->base->order);
    mpz_set(rep(rep0(rep1(x))), rem);
    mpz_tdiv_qr(quo, rem, quo, field(x)->base->base->order);
    mpz_set(rep(rep0(rep2(x))), rem);
    mpz_tdiv_qr(quo, rem, quo, field(x)->base->base->order);
    mpz_set(rep(rep1(rep0(x))), rem);
    mpz_tdiv_qr(quo, rem, quo, field(x)->base->base->order);
    mpz_set(rep(rep1(rep1(x))), rem);
    mpz_tdiv_qr(quo, rem, quo, field(x)->base->base->order);
    mpz_set(rep(rep1(rep2(x))), rem);

    mpz_clear(quo);
    mpz_clear(rem);
}
开发者ID:TEPLA,项目名称:tepla-library,代码行数:30,代码来源:bn254_fp6.c


示例3: bn254_fp6_mul_fp2_4

//--------------------------------------------------------
//   z = x * (y1, 0, y2)
//--------------------------------------------------------
void bn254_fp6_mul_fp2_4(Element z, const Element x, const Element y1, const Element y2)
{
    Element *v = field(z)->base->tmp;

    if (field(y1)->ID != bn254_fp2 || field(y2)->ID != bn254_fp2)
    {
        fprintf(stderr, "error: input should be element in bn254_fp6\n");
        exit(200);
    }

    bn254_fp2_mul(v[0], rep0(x), y1);
    bn254_fp2_mul(v[1], rep2(x), y2);

    bn254_fp2_add(v[3], rep0(x), rep2(x));
    bn254_fp2_add(v[4], y1, y2);
    bn254_fp2_mul(rep2(z), v[3], v[4]);
    bn254_fp2_sub(rep2(z), rep2(z), v[0]);
    bn254_fp2_sub(rep2(z), rep2(z), v[1]);

    bn254_fp2_mul(v[3], rep1(x), y2);
    bn254_fp2_mul(v[4], rep1(x), y1);

    bn254_fp2_xi_mul(v[1], v[1]);
    bn254_fp2_xi_mul(v[3], v[3]);

    bn254_fp2_add(rep0(z), v[0], v[3]);
    bn254_fp2_add(rep1(z), v[1], v[4]);
}
开发者ID:TEPLA,项目名称:tepla-library,代码行数:31,代码来源:bn254_fp6.c


示例4: bn254_fp2_cmp

int bn254_fp2_cmp(const Element x, const Element y)
{
    if (bn254_fp_cmp(rep1(x), rep1(y)) == 0)
    {
        if (bn254_fp_cmp(rep0(x), rep0(y)) == 0) { return 0; }
    }
    return 1;
}
开发者ID:ysk-knbr,项目名称:tepla-1,代码行数:8,代码来源:bn254_fp2.c


示例5: bn254_fp2_sqrn

void bn254_fp2_sqrn(Element z, const Element x)
{
    Element *t = field(z)->base->tmp;

    bn254_fp_addn(t[0], rep0(x), rep1(x));
    bn254_fp_sub(t[1], rep0(x), rep1(x));
    bn254_fp_muln(rep0(z), t[0], t[1]);
    bn254_fp_addn(t[0], rep0(x), rep0(x));
    bn254_fp_muln(rep1(z), t[0], rep1(x));
}
开发者ID:akirakanaoka,项目名称:teplatest,代码行数:10,代码来源:bn254_fp2.c


示例6: bn254_fp2_xi_mul

void bn254_fp2_xi_mul(Element z, const Element x)
{
    Element* t = field(z)->base->tmp;

    bn254_fp_add(t[0], rep1(x), rep1(x));
    bn254_fp_add(t[0], t[0], t[0]);
    bn254_fp_add(t[0], t[0], rep1(x));
    bn254_fp_set(rep1(z), rep0(x));
    bn254_fp_neg(rep0(z), t[0]);
}
开发者ID:ysk-knbr,项目名称:tepla-1,代码行数:10,代码来源:bn254_fp2.c


示例7: bn254_fp6_gm_mul

//--------------------------------------------------------
//   z = x * gamma ( Fp12 : Fp6[x]/x^2-gamma )
//--------------------------------------------------------
void bn254_fp6_gm_mul(Element z, const Element x)
{
    if (z == x) {
        fprintf(stderr, "fail gm mul\n");
        exit(500);
    }

    bn254_fp2_xi_mul(rep0(z), rep2(x));
    bn254_fp2_set(rep1(z), rep0(x));
    bn254_fp2_set(rep2(z), rep1(x));
}
开发者ID:TEPLA,项目名称:tepla-library,代码行数:14,代码来源:bn254_fp6.c


示例8: bn254_fp6_mul_fp2

//--------------------------------------------------------
//   z = x * (y, 0, 0)
//--------------------------------------------------------
void bn254_fp6_mul_fp2(Element z, const Element x, const Element y)
{
    if (field(y)->ID != bn254_fp2)
    {
        fprintf(stderr, "error: input should be element in bn254_fp6\n");
        exit(200);
    }

    bn254_fp2_mul(rep0(z), rep0(x), y);
    bn254_fp2_mul(rep1(z), rep1(x), y);
    bn254_fp2_mul(rep2(z), rep2(x), y);
}
开发者ID:TEPLA,项目名称:tepla-library,代码行数:15,代码来源:bn254_fp6.c


示例9: bn254_fp6_get_str

void bn254_fp6_get_str(char *s, const Element x)
{
    char s0[65], s1[65], s2[65], s3[65], s4[65], s5[65];

    bn254_fp_get_str(s0, rep0(rep0(x)));
    bn254_fp_get_str(s1, rep0(rep1(x)));
    bn254_fp_get_str(s2, rep0(rep2(x)));
    bn254_fp_get_str(s3, rep1(rep0(x)));
    bn254_fp_get_str(s4, rep1(rep1(x)));
    bn254_fp_get_str(s5, rep1(rep2(x)));

    sprintf(s, "%s %s %s %s %s %s", s0, s1, s2, s3, s4, s5);
}
开发者ID:TEPLA,项目名称:tepla-library,代码行数:13,代码来源:bn254_fp6.c


示例10: bn254_fp6_to_mpz

//-------------------------------------------
//  i/o operation (octet string)
//-------------------------------------------
void bn254_fp6_to_mpz(mpz_t a, const Element x)
{
    mpz_mul(a, rep(rep1(rep2(x))), field(x)->base->base->order);   // a = rep12*p
    mpz_add(a, a, rep(rep1(rep1(x))));   // a = a + rep11
    mpz_mul(a, a, field(x)->base->base->order);   // a = a*p
    mpz_add(a, a, rep(rep1(rep0(x))));   // a = a + rep10
    mpz_mul(a, a, field(x)->base->base->order);   // a = a*p
    mpz_add(a, a, rep(rep0(rep2(x))));   // a = a + rep02
    mpz_mul(a, a, field(x)->base->base->order);   // a = a*p
    mpz_add(a, a, rep(rep0(rep1(x))));   // a = a + rep01
    mpz_mul(a, a, field(x)->base->base->order);   // a = a*p
    mpz_add(a, a, rep(rep0(rep0(x))));   // a = a + rep00
}
开发者ID:TEPLA,项目名称:tepla-library,代码行数:16,代码来源:bn254_fp6.c


示例11: bn254_fp2_inv

void bn254_fp2_inv(Element z, const Element x)
{
    Element* t = field(z)->base->tmp;

    if (strcmp(x->field->field_name, "bn254_fp2a") == 0)
    {
        bn254_fp_muln(t[1], rep1(x), rep1(x)); // t1 = a1^2
        bn254_fp_addn(t[0], t[1], t[1]);
        bn254_fp_addn(t[0], t[0], t[0]);
        bn254_fp_addn(t[1], t[1], t[0]);      // t1 = 5*a1^2
        bn254_fp_muln(t[0], rep0(x), rep0(x));// t0 = a0^2
        bn254_fp_addn(t[0], t[0], t[1]);      // t0 = t0 - t1
        bn254_fp_inv(t[1], t[0]);             // t1 = t0^-1
        bn254_fp_mul(rep0(z), rep0(x), t[1]); // c0 = a0*t1
        bn254_fp_mul(rep1(z), rep1(x), t[1]); // c1 = a1*t1
        bn254_fp_neg(rep1(z), rep1(z));       // c1 = -1*a1*t1
    }

    if (strcmp(x->field->field_name, "bn254_fp2b") == 0)
    {
        bn254_fp_muln(t[1], rep1(x), rep1(x));// t1 = a1^2
        bn254_fp_muln(t[0], rep0(x), rep0(x));// t0 = a0^2
        bn254_fp_addn(t[0], t[0], t[1]);      // t0 = t0 + t1 ( beta = -1 )
        bn254_fp_inv(t[1], t[0]);             // t1 = t0^-1
        bn254_fp_mul(rep0(z), rep0(x), t[1]); // c0 = a0*t1
        bn254_fp_mul(rep1(z), rep1(x), t[1]); // c1 = a1*t1
        bn254_fp_neg(rep1(z), rep1(z));       // c1 = -1*a1*t1
    }
}
开发者ID:akirakanaoka,项目名称:teplatest,代码行数:29,代码来源:bn254_fp2.c


示例12: bn254_fp2_sqr

void bn254_fp2_sqr(Element z, const Element x)
{
    Element* t = field(z)->base->tmp;

    if (strcmp(x->field->field_name, "bn254_fp2a") == 0)
    {
        bn254_fp_addn(t[0], rep1(x), rep1(x)); //
        bn254_fp_muln(t[0], t[0], rep0(x));    // t0 = 2*x1*x0
        bn254_fp_addp(t[1], rep0(x));
        bn254_fp_subn(t[1], t[1], rep1(x));    // t1 = x0-x1
        bn254_fp_addn(t[2], rep1(x), rep1(x)); //
        bn254_fp_addn(t[2], t[2], t[2]);       //
        bn254_fp_addn(t[2], t[2], rep1(x));    //
        bn254_fp_addn(t[2], t[2], rep0(x));    // t2 = 5*x1 + x0
        bn254_fp_muln(t[1], t[1], t[2]);       // t1 = t1 * t2
        bn254_fp_mod(rep1(z), t[0]);           // c1 = t0
        bn254_fp_addn(t[0], t[0], t[0]);       //
        bn254_fp_subn(t[1], t[1], t[0]);       // t1 = 2*t0*t1
        bn254_fp_mod(rep0(z), t[1]);           // c0 = t1
    }

    if (strcmp(x->field->field_name, "bn254_fp2b") == 0)
    {
        bn254_fp_addn(t[0], rep1(x), rep1(x)); // t0 = 2*x1
        bn254_fp_muln(t[0], t[0], rep0(x));    // t0 = 2*x1*x0
        bn254_fp_addn(t[1], rep0(x), rep1(x)); // t1 = x0+x1
        bn254_fp_subn(t[2], rep0(x), rep1(x)); // t2 = x0-x1
        bn254_fp_muln(t[1], t[1], t[2]);       // t1 = t1*t2
        bn254_fp_mod(rep1(z), t[0]);           // c1 = t0
        bn254_fp_mod(rep0(z), t[1]);		   // c0 = t1
    }
}
开发者ID:akirakanaoka,项目名称:teplatest,代码行数:32,代码来源:bn254_fp2.c


示例13: bn254_fp2_inv

void bn254_fp2_inv(Element z, const Element x)
{
    Element* t = field(z)->base->tmp;

    bn254_fp_muln(t[1], rep1(x), rep1(x)); // t1 = a1^2
    bn254_fp_addn(t[0], t[1], t[1]);
    bn254_fp_addn(t[0], t[0], t[0]);
    bn254_fp_addn(t[1], t[1], t[0]);      // t1 = 5*a1^2
    bn254_fp_muln(t[0], rep0(x), rep0(x));// t0 = a0^2
    bn254_fp_addn(t[0], t[0], t[1]);      // t0 = t0 - t1
    bn254_fp_inv(t[1], t[0]);             // t1 = t0^-1
    bn254_fp_mul(rep0(z), rep0(x), t[1]); // c0 = a0*t1
    bn254_fp_mul(rep1(z), rep1(x), t[1]); // c1 = a1*t1
    bn254_fp_neg(rep1(z), rep1(z));       // c1 = -1*a1*t1
}
开发者ID:ysk-knbr,项目名称:tepla-1,代码行数:15,代码来源:bn254_fp2.c


示例14: bn254_fp2_is_one

int bn254_fp2_is_one(const Element x)
{
    if (bn254_fp_is_zero(rep1(x)))
    {
        return (bn254_fp_is_one(rep0(x)));
    }
    return FALSE;
}
开发者ID:ysk-knbr,项目名称:tepla-1,代码行数:8,代码来源:bn254_fp2.c


示例15: bn254_fp6_set_str

void bn254_fp6_set_str(Element x, const char *s)
{
    int i = 0;
    int len = strlen(s);

    char msg[400], *p, *c[5];

    if (len > 400) {
        fprintf(stderr, "error: input string is too long, string must be smaller than 400\n");
        exit(200);
    }

    strcpy(msg, s);

    p = msg;

    while ((*p) != '\0')
    {
        if ((*p) == ' ') {
            if (i < 5) {
                c[i] = p;
            }
            i++;
        }
        p++;
    }

    if (i != 5) {
        fprintf(stderr, "error: input string is not correct\n");
        exit(200);
    }

    (*c[0]) = '\0';
    (*c[1]) = '\0';
    (*c[2]) = '\0';
    (*c[3]) = '\0';
    (*c[4]) = '\0';

    bn254_fp_set_str(rep0(rep0(x)), msg);
    bn254_fp_set_str(rep0(rep1(x)), ++c[0]);
    bn254_fp_set_str(rep0(rep2(x)), ++c[1]);
    bn254_fp_set_str(rep1(rep0(x)), ++c[2]);
    bn254_fp_set_str(rep1(rep1(x)), ++c[3]);
    bn254_fp_set_str(rep1(rep2(x)), ++c[4]);
}
开发者ID:TEPLA,项目名称:tepla-library,代码行数:45,代码来源:bn254_fp6.c


示例16: bn254_fp2_mul_p

//--------------------------------------------------------
//  multiplication of element of fp and element of fp^2
//--------------------------------------------------------
void bn254_fp2_mul_p(Element z, const Element x, const Element y)
{
    if (field(x)->ID == bn254_fp)
    {
        bn254_fp_mul(rep0(z), x, rep0(y));
        bn254_fp_mul(rep1(z), x, rep1(y));
    }
    else if (field(y)->ID == bn254_fp)
    {
        bn254_fp_mul(rep0(z), rep0(x), y);
        bn254_fp_mul(rep1(z), rep1(x), y);
    }
    else
    {
        fprintf(stderr, "error: input should be element in bn254_fp2\n");
        exit(200);
    }
}
开发者ID:ysk-knbr,项目名称:tepla-1,代码行数:21,代码来源:bn254_fp2.c


示例17: bn254_fp2_get_str

void bn254_fp2_get_str(char *s, const Element x)
{
    char s1[65], s2[65];

    bn254_fp_get_str(s1, rep0(x));
    bn254_fp_get_str(s2, rep1(x));

    sprintf(s, "%s %s", s1, s2);
}
开发者ID:ysk-knbr,项目名称:tepla-1,代码行数:9,代码来源:bn254_fp2.c


示例18: bn254_fp2_sqr

void bn254_fp2_sqr(Element z, const Element x)
{
    Element* t = field(z)->base->tmp;

    bn254_fp_addn(t[0], rep1(x), rep1(x)); //
    bn254_fp_muln(t[0], t[0], rep0(x));    // t0 = 2*x1*x0
    bn254_fp_addp(t[1], rep0(x));
    bn254_fp_subn(t[1], t[1], rep1(x));    // t1 = x0-x1
    bn254_fp_addn(t[2], rep1(x), rep1(x)); //
    bn254_fp_addn(t[2], t[2], t[2]);       //
    bn254_fp_addn(t[2], t[2], rep1(x));    //
    bn254_fp_addn(t[2], t[2], rep0(x));    // t2 = 5*x1 + x0
    bn254_fp_muln(t[1], t[1], t[2]);       // t1 = t1 * t2
    bn254_fp_mod(rep1(z), t[0]);           // c1 = t0
    bn254_fp_addn(t[0], t[0], t[0]);       //
    bn254_fp_subn(t[1], t[1], t[0]);       // t1 = 2*t0*t1
    bn254_fp_mod(rep0(z), t[1]);           // c0 = t1
}
开发者ID:ysk-knbr,项目名称:tepla-1,代码行数:18,代码来源:bn254_fp2.c


示例19: bn254_fp2_init

//-------------------------------------------
//  initialization, clear, set
//-------------------------------------------
void bn254_fp2_init(Element x)
{
    x->data = (void *)malloc(sizeof(Element) * 2);

    if (x->data == NULL) { fprintf(stderr, "fail: allocate in fp2 init\n"); exit(100); }

    element_init(rep0(x), field(x)->base);
    element_init(rep1(x), field(x)->base);
}
开发者ID:ysk-knbr,项目名称:tepla-1,代码行数:12,代码来源:bn254_fp2.c


示例20: bn254_fp2_muln

void bn254_fp2_muln(Element z, const Element x, const Element y)
{
    Element* t = field(z)->base->tmp;
    //int i;
    //Element* t = (Element *)malloc(sizeof(Element)*10);
    //for(i=0;i<10;i++){ element_init(t[i], field(z)->base); }

    bn254_fp_muln(t[0], rep0(x), rep0(y)); // t0 = x0 * y0
    bn254_fp_muln(t[1], rep1(x), rep1(y)); // t1 = x0 * y1
    bn254_fp_addn(t[2], rep0(x), rep1(x)); // t2 = x0 + x1
    bn254_fp_addn(t[3], rep0(y), rep1(y)); // t2 = y0 + y1
    bn254_fp_muln(t[4], t[2], t[3]);	   // t4 = t2 * t3
    bn254_fp_addn(t[5], t[0], t[1]);	   // t5 = t0 + t1
    bn254_fp_subn(rep1(z), t[4], t[5]);	   // t5 = t4 - t5
    bn254_fp_sub(t[6], t[0], t[1]);		   // t6 = t0 - t1
    bn254_fp_OP2(rep0(z), t[6]);

    //for(i=0;i<10;i++){ element_clear(t[i]); }
}
开发者ID:akirakanaoka,项目名称:teplatest,代码行数:19,代码来源:bn254_fp2.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ repaint函数代码示例发布时间:2022-05-30
下一篇:
C++ rep函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap