mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-02-26 08:43:08 +00:00
bls method
This commit is contained in:
parent
5783a3745e
commit
3b95e01390
@ -1,5 +1,4 @@
|
||||
use anyhow::Result;
|
||||
use ethereum_types::U512;
|
||||
use rand::Rng;
|
||||
|
||||
use crate::cpu::kernel::interpreter::{
|
||||
@ -19,9 +18,7 @@ fn run_and_return_bls(label: String, x: BLS381, y: BLS381) -> BLS381 {
|
||||
};
|
||||
let interpreter = run_interpreter_with_memory(setup).unwrap();
|
||||
let output = interpreter.stack();
|
||||
BLS381 {
|
||||
val: U512::from(output[1]) + (U512::from(output[0]) << 256),
|
||||
}
|
||||
BLS381::from_limbs(output[0], output[1])
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -144,6 +144,13 @@ impl BLS381 {
|
||||
pub fn hi(self) -> U256 {
|
||||
U256(self.val.0[4..].try_into().unwrap())
|
||||
}
|
||||
|
||||
pub fn from_limbs(hi: U256, lo: U256) -> BLS381 {
|
||||
let mut val = [0u64; 8];
|
||||
val[..4].copy_from_slice(&lo.0);
|
||||
val[4..].copy_from_slice(&hi.0);
|
||||
BLS381 { val: U512(val) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Distribution<BLS381> for Standard {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user