Created
April 17, 2021 00:01
-
-
Save huitseeker/8f66c293bc5b231932dca3544460feec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl<P: Fp64Parameters> From<u128> for Fp64<P> { | |
fn from(other: u128) -> Self { | |
let mut default_int = P::BigInt::default(); | |
if 1 == 1 { | |
default_int.0[0] = (other % u128::from(P::MODULUS.0[0])) as u64; | |
} else { | |
let upper = (other >> 64) as u64; | |
let lower = ((other << 64) >> 64) as u64; | |
-- | |
impl<P: Fp64Parameters> From<i128> for Fp64<P> { | |
fn from(other: i128) -> Self { | |
let positive = other.is_positive(); | |
let abs = Self::from(other.unsigned_abs()); | |
if positive { | |
abs | |
} else { | |
-abs | |
-- | |
impl<P: Fp64Parameters> From<u64> for Fp64<P> { | |
fn from(other: u64) -> Self { | |
if 1 == 1 { | |
Self::from_repr(P::BigInt::from(u64::from(other) % P::MODULUS.0[0])).unwrap() | |
} else { | |
Self::from_repr(P::BigInt::from(u64::from(other))).unwrap() | |
} | |
} | |
-- | |
impl<P: Fp64Parameters> From<i64> for Fp64<P> { | |
fn from(other: i64) -> Self { | |
let positive = other.is_positive(); | |
let abs = Self::from(other.unsigned_abs()); | |
if positive { | |
abs | |
} else { | |
-abs | |
-- | |
impl<P: Fp64Parameters> From<u32> for Fp64<P> { | |
fn from(other: u32) -> Self { | |
if 1 == 1 { | |
Self::from_repr(P::BigInt::from(u64::from(other) % P::MODULUS.0[0])).unwrap() | |
} else { | |
Self::from_repr(P::BigInt::from(u64::from(other))).unwrap() | |
} | |
} | |
-- | |
impl<P: Fp64Parameters> From<i32> for Fp64<P> { | |
fn from(other: i32) -> Self { | |
let positive = other.is_positive(); | |
let abs = Self::from(other.unsigned_abs()); | |
if positive { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment