Ejemplo n.º 1
0
Archivo: parser2.c Proyecto: tungvx/FSE
static AST block() {
    Token *t = &tok;
    AST a=0;
    AST vdl, fdl, sts;

    vdl = new_list(nVARDECLS);
    fdl = new_list(nFUNCDECLS);
    if(t->sym == '{') {
	gettoken();
	enter_block();

	vardecls(vdl,fdl);
	funcdecls(fdl);
	sts = stmts();

	a = make_AST(nBLOCK, vdl, fdl, sts, 0);
	leave_block();

	if (t->sym == '}') gettoken();
	else parse_error("expected }");

    } else {
	parse_error("expected {");
    }
    return a;
}
Ejemplo n.º 2
0
Archivo: parser2.c Proyecto: tungvx/FSE
static AST classdecl() {
    Token *t = &tok;
    AST a=0;
    AST a1=0, a2=0, a3=0, a4 = 0, a5 = 0;
    AST sdl = 0, vdl=0, fdl=0;  /* struct, var and func decl list */

    a1 = classhead();

    if (t->sym == '{') {
	gettoken();
	enter_block();

	sdl = new_list(nSTRUCTS);
	vdl = new_list(nVARDECLS);
	fdl = new_list(nFUNCDECLS);

	a2 = structdecls(sdl);
	if (t->sym == tCLASS) a3 = classdecls();
	a4 = vardecls(vdl, fdl);
	a5 = funcdecls(fdl);
	leave_block();

	if (t->sym == '}') {
	    gettoken();
	    a = make_AST(nCLASSBODY, a2, a3, a4, a5);
	    a = make_AST(nCLASSDECL, a1, a, 0, 0);
	} else {
	    parse_error("expected }");
	}

    } else {
	parse_error("expected {");
    }
    return a;
}
Ejemplo n.º 3
0
bn128_GT bn128_final_exponentiation(const bn128_Fq12 &elt)
{
    enter_block("Call to bn128_final_exponentiation");
    bn128_GT eltcopy = elt;
    eltcopy.elem.final_exp();
    leave_block("Call to bn128_final_exponentiation");
    return eltcopy;
}
Ejemplo n.º 4
0
bn128_ate_G1_precomp bn128_ate_precompute_G1(const bn128_G1& P)
{
    enter_block("Call to bn128_ate_precompute_G1");

    bn128_ate_G1_precomp result;
    bn::ecop::NormalizeJac(result.P, P.coord);

    leave_block("Call to bn128_ate_precompute_G1");
    return result;
}
Ejemplo n.º 5
0
bn128_ate_G2_precomp bn128_ate_precompute_G2(const bn128_G2& Q)
{
    enter_block("Call to bn128_ate_precompute_G2");

    bn128_ate_G2_precomp result;
    bn::ecop::NormalizeJac(result.Q, Q.coord);

    Fp2 T[3];
    T[0] = result.Q[0];
    T[1] = result.Q[1];
    T[2] = Fp2(1);

    Fp6 d;
    doubling_step_for_flipped_miller_loop(T, d);
    result.coeffs.emplace_back(d);

    Fp6 e;
    assert(Param::siTbl[1] == 1);
    mixed_addition_step_for_flipped_miller_loop(result.Q, T, e);
    result.coeffs.emplace_back(e);

    bn::Fp6 l;
    // 844kclk
    for (size_t i = 2; i < Param::siTblNum; i++) {
        doubling_step_for_flipped_miller_loop(T, l);
        result.coeffs.emplace_back(l);

        if (Param::siTbl[i]) {
            mixed_addition_step_for_flipped_miller_loop(result.Q, T, l);
            result.coeffs.emplace_back(l);
        }
    }

    // addition step
    Fp2 Q1[2];
    bn::ecop::FrobEndOnTwist_1(Q1, result.Q);
    Fp2 Q2[2];
    bn::ecop::FrobEndOnTwist_2(Q2, result.Q);
    Fp2::neg(Q2[1], Q2[1]);
    // @memo z < 0
    if (0)
    {
        bn::Fp2::neg(T[1], T[1]);
    }

    mixed_addition_step_for_flipped_miller_loop(Q1, T, d);
    result.coeffs.emplace_back(d);

    mixed_addition_step_for_flipped_miller_loop(Q2, T, e);
    result.coeffs.emplace_back(e);

    leave_block("Call to bn128_ate_precompute_G2");
    return result;
}
Ejemplo n.º 6
0
Archivo: parser2.c Proyecto: tungvx/FSE
static AST structdecl(){
    Token *t = &tok;

    AST struct_name = structname();
    insert_SYM(get_text(struct_name), 0, tGLOBAL, 0); /* dummy */
    AST a = new_list(nVARDECLS);
    if (t->sym == '{'){
	enter_block();
	gettoken();
	a = vardecls(a, 0);
	leave_block();
	if (t->sym == '}') gettoken();
	else parse_error("Expected }");

	if (t->sym == ';') gettoken();
	else parse_error("Expected ;");

	a = make_AST_structdecl(struct_name, a);
    } else {
	parse_error("Expected {");
    }
    return a;
}