This commit is contained in:
Dmitry Vagner 2022-12-27 16:19:08 -08:00
parent d4d80f3528
commit 84fab8d6be
2 changed files with 16 additions and 24 deletions

View File

@ -75,14 +75,6 @@ fn gen_fp2() -> Fp2 {
[gen_fp(), gen_fp()]
}
pub fn gen_curve_point() -> Curve {
gen_fp2()
}
pub fn gen_twisted_curve_point() -> TwistedCurve {
[gen_fp2(), gen_fp2()]
}
fn gen_fp6() -> Fp6 {
[gen_fp2(), gen_fp2(), gen_fp2()]
}
@ -410,21 +402,21 @@ fn frob_z(n: usize) -> Fp2 {
}
}
// fn inv_fp2(a: Fp2) -> Fp2 {
// let [a0, a1] = a;
// let norm = inv_fp(mul_fp(a0, a0) + mul_fp(a1, a1));
// [mul_fp(norm, a0), neg_fp(mul_fp(norm, a1))]
// }
pub fn inv_fp2(a: Fp2) -> Fp2 {
let [a0, a1] = a;
let norm = inv_fp(mul_fp(a0, a0) + mul_fp(a1, a1));
[mul_fp(norm, a0), neg_fp(mul_fp(norm, a1))]
}
// fn inv_fp6(c: Fp6) -> Fp6 {
// let b = mul_fp6(frob_fp6(1, c), frob_fp6(3, c));
// let e = mul_fp6(b, frob_fp6(5, c))[0];
// let n = mul_fp2(e, conj_fp2(e))[0];
// let i = inv_fp(n);
// let d = mul_fp2(embed_fp2(i), e);
// let [f0, f1, f2] = frob_fp6(1, b);
// [mul_fp2(d, f0), mul_fp2(d, f1), mul_fp2(d, f2)]
// }
pub fn inv_fp6(c: Fp6) -> Fp6 {
let b = mul_fp6(frob_fp6(1, c), frob_fp6(3, c));
let e = mul_fp6(b, frob_fp6(5, c))[0];
let n = mul_fp2(e, conj_fp2(e))[0];
let i = inv_fp(n);
let d = mul_fp2(embed_fp2(i), e);
let [f0, f1, f2] = frob_fp6(1, b);
[mul_fp2(d, f0), mul_fp2(d, f1), mul_fp2(d, f2)]
}
pub fn inv_fp12(f: Fp12) -> Fp12 {
let [f0, f1] = f;

View File

@ -4,8 +4,8 @@ use anyhow::Result;
use ethereum_types::U256;
use crate::bn254::{
cord, fp12_to_vec, frob_fp12, gen_curve_point, gen_fp12, gen_fp12_sparse,
gen_twisted_curve_point, miller_loop, mul_fp12, power, tangent, Curve, Fp12, TwistedCurve,
fp12_to_vec, frob_fp12, gen_fp12, gen_fp12_sparse, miller_loop, mul_fp12, power, Curve, Fp12,
TwistedCurve,
};
use crate::cpu::kernel::aggregator::KERNEL;
use crate::cpu::kernel::interpreter::run_interpreter;