/* computes (op1->m_a*op2->m_a, op1->m_b*op2->m_b) */ void fp2e_parallel_coeffmul_c(fp2e_t rop, const fp2e_t op1, const fp2e_t op2) { fpe_t a1, b1, a2, b2; // Needed for intermediary results fp2e_to_2fpe(a1, b1, op1); fp2e_to_2fpe(a2, b2, op2); fpe_mul(a1, a1, a2); fpe_mul(b1, b1, b2); _2fpe_to_fp2e(rop, a1, b1); }
// Compute inverse of an fpe, store result in rop: void fpe_invert(fpe_t rop, const fpe_t op1) { fpe_set(rop,op1); int i; for(i = 254; i >= 0; i--) { fpe_mul(rop,rop,rop); if(scalar_getbit(bn_pminus2, i)) fpe_mul(rop,rop,op1); } }
void fp2e_mul_fpe_c(fp2e_t rop, const fp2e_t op1, const fpe_t op2) { #ifdef N_OPS mulfp2fpctr += 1; #endif fpe_t a1, b1; fp2e_to_2fpe(a1, b1, op1); fpe_mul(a1, a1, op2); fpe_mul(b1, b1, op2); _2fpe_to_fp2e(rop, a1, b1); }
// Square an fpe, store result in rop: void fpe_square(fpe_t rop, const fpe_t op) { /* Not used during pairing computation */ fpe_mul(rop, op, op); }