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


C++ rep0函数代码示例

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


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


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