-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Description
When having access to a value in ConstMontyForm, getting the MODULO value is difficult. This is the only way I could think of:
use crypto_bigint::{CheckedAdd, U256, Zero, impl_modulus, modular::ConstMontyForm};
impl_modulus!(
MyModulus,
U256,
"73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"
);
pub type ValueUnderMod = ConstMontyForm<MyModulus, { U256::LIMBS }>;
fn main() {
// ...
let some_value = ValueUnderMod::new(&U256::from_u8(2));
let mut zero = some_value.clone();
zero.set_zero();
let mut modulo = zero.sub(&ValueUnderMod::new(&U256::from_u8(1))).retrieve();
modulo = modulo.checked_add(&U256::from_u8(1)).unwrap();
assert!(modulo.eq(&U256::from_be_hex(
"73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"
)))
}And it would be good to have a method for the MontyForm to get the modulus from it.
Metadata
Metadata
Assignees
Labels
No labels