mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-10 09:43:09 +00:00
fixed multiplication
This commit is contained in:
parent
bde5c557a6
commit
ab32f03b10
@ -93,8 +93,8 @@ impl Mul for Fp {
|
||||
fn mul(self, other: Self) -> Self {
|
||||
let b256: U512 = U512([0, 0, 0, 0, 1, 0, 0, 0]);
|
||||
// x1, y1 are at most (q-1) // 2^256 < 2^125
|
||||
let (x0, x1) = self.val.div_mod(b256);
|
||||
let (y0, y1) = other.val.div_mod(b256);
|
||||
let (x1, x0) = self.val.div_mod(b256);
|
||||
let (y1, y0) = other.val.div_mod(b256);
|
||||
|
||||
let z00 = Fp {
|
||||
val: x0.saturating_mul(y0) % BLS_BASE,
|
||||
|
||||
16
evm/src/cpu/kernel/tests/bls381.rs
Normal file
16
evm/src/cpu/kernel/tests/bls381.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use crate::bls381_arithmetic::Fp;
|
||||
use rand::Rng;
|
||||
|
||||
#[test]
|
||||
fn test_bls_mul() -> Result<(),()> {
|
||||
let mut rng = rand::thread_rng();
|
||||
let f: Fp = rng.gen::<Fp>();
|
||||
let g: Fp = rng.gen::<Fp>();
|
||||
let fg = f*g;
|
||||
|
||||
println!("{:#?}", f);
|
||||
println!("{:#?}", g);
|
||||
println!("{:#?}", fg);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
mod account_code;
|
||||
mod balance;
|
||||
mod bls381;
|
||||
mod bn254;
|
||||
mod core;
|
||||
mod ecc;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user