ff: Add PrimeField: From<u64> constraint

This commit is contained in:
Jack Grigg
2020-03-27 23:19:58 +13:00
parent b6457a905b
commit fd79de5408
11 changed files with 50 additions and 37 deletions

View File

@@ -34,6 +34,12 @@ impl fmt::Display for Fr {
}
}
impl From<u64> for Fr {
fn from(v: u64) -> Fr {
Fr(Wrapping((v % MODULUS_R.0 as u64) as u32))
}
}
impl ConditionallySelectable for Fr {
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
Fr(Wrapping(u32::conditional_select(