move consts

This commit is contained in:
Dmitry Vagner 2023-01-25 16:10:53 +07:00
parent f70243e70c
commit b46af11f3a
2 changed files with 55 additions and 55 deletions

View File

@ -194,59 +194,7 @@ fn get_custom_powers(f: Fp12) -> (Fp12, Fp12, Fp12) {
(y2, y4 * y2 * y2 * y0_inv, y0_inv)
}
// The curve is cyclic with generator (1, 2)
pub const CURVE_GENERATOR: Curve = {
Curve {
x: Fp { val: U256::one() },
y: Fp {
val: U256([2, 0, 0, 0]),
},
}
};
// The twisted curve is cyclic with generator (x, y) as follows
pub const TWISTED_GENERATOR: TwistedCurve = {
TwistedCurve {
x: Fp2 {
re: Fp {
val: U256([
0x46debd5cd992f6ed,
0x674322d4f75edadd,
0x426a00665e5c4479,
0x1800deef121f1e76,
]),
},
im: Fp {
val: U256([
0x97e485b7aef312c2,
0xf1aa493335a9e712,
0x7260bfb731fb5d25,
0x198e9393920d483a,
]),
},
},
y: Fp2 {
re: Fp {
val: U256([
0x4ce6cc0166fa7daa,
0xe3d1e7690c43d37b,
0x4aab71808dcb408f,
0x12c85ea5db8c6deb,
]),
},
im: Fp {
val: U256([
0x55acdadcd122975b,
0xbc4b313370b38ef3,
0xec9e99ad690c3395,
0x090689d0585ff075,
]),
},
},
}
};
/// The folowing constants are defined above get_custom_powers
// The folowing constants are defined above get_custom_powers
const EXPS4: [(usize, usize, usize); 64] = [
(1, 1, 0),

View File

@ -4,8 +4,8 @@ use std::ops::Range;
use anyhow::Result;
use ethereum_types::U256;
use crate::bn254_arithmetic::{gen_fp12, Fp12};
use crate::bn254_pairing::{gen_fp12_sparse, tate, CURVE_GENERATOR, TWISTED_GENERATOR};
use crate::bn254_arithmetic::{gen_fp12, Fp, Fp12, Fp2};
use crate::bn254_pairing::{gen_fp12_sparse, tate, Curve, TwistedCurve};
use crate::cpu::kernel::aggregator::KERNEL;
use crate::cpu::kernel::interpreter::Interpreter;
use crate::memory::segments::Segment;
@ -204,6 +204,58 @@ fn test_inv_fp12() -> Result<()> {
// Ok(())
// }
// The curve is cyclic with generator (1, 2)
pub const CURVE_GENERATOR: Curve = {
Curve {
x: Fp { val: U256::one() },
y: Fp {
val: U256([2, 0, 0, 0]),
},
}
};
// The twisted curve is cyclic with generator (x, y) as follows
pub const TWISTED_GENERATOR: TwistedCurve = {
TwistedCurve {
x: Fp2 {
re: Fp {
val: U256([
0x46debd5cd992f6ed,
0x674322d4f75edadd,
0x426a00665e5c4479,
0x1800deef121f1e76,
]),
},
im: Fp {
val: U256([
0x97e485b7aef312c2,
0xf1aa493335a9e712,
0x7260bfb731fb5d25,
0x198e9393920d483a,
]),
},
},
y: Fp2 {
re: Fp {
val: U256([
0x4ce6cc0166fa7daa,
0xe3d1e7690c43d37b,
0x4aab71808dcb408f,
0x12c85ea5db8c6deb,
]),
},
im: Fp {
val: U256([
0x55acdadcd122975b,
0xbc4b313370b38ef3,
0xec9e99ad690c3395,
0x090689d0585ff075,
]),
},
},
}
};
#[test]
fn test_tate() -> Result<()> {
let ptr: usize = 300;