Expand description
256-bit, stack allocated biginteger for use in prime field arithmetic.
Tuple Fields
0: [u128; 2]
Implementations
sourceimpl U256
impl U256
sourcepub fn from_slice(s: &[u8]) -> Result<U256, Error>
pub fn from_slice(s: &[u8]) -> Result<U256, Error>
Initialize U256 from slice of bytes (big endian)
pub fn to_big_endian(&self, s: &mut [u8]) -> Result<(), Error>
pub fn zero() -> U256
pub fn one() -> U256
pub fn is_zero(&self) -> bool
pub fn set_bit(&mut self, n: usize, to: bool) -> bool
pub fn get_bit(&self, n: usize) -> Option<bool>
sourcepub fn mul(&mut self, other: &U256, modulo: &U256, inv: u128)
pub fn mul(&mut self, other: &U256, modulo: &U256, inv: u128)
Multiply self
by other
(mod modulo
) via the Montgomery
multiplication method.
pub fn is_even(&self) -> bool
sourcepub fn bits(&self) -> BitIterator<'_>ⓘNotable traits for BitIterator<'a>impl<'a> Iterator for BitIterator<'a> type Item = bool;
pub fn bits(&self) -> BitIterator<'_>ⓘNotable traits for BitIterator<'a>impl<'a> Iterator for BitIterator<'a> type Item = bool;
Return an Iterator<Item=bool> over all bits from MSB to LSB.
Trait Implementations
sourceimpl Ord for U256
impl Ord for U256
sourceimpl PartialOrd<U256> for U256
impl PartialOrd<U256> for U256
sourcefn partial_cmp(&self, other: &U256) -> Option<Ordering>
fn partial_cmp(&self, other: &U256) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for U256
impl Eq for U256
impl StructuralEq for U256
impl StructuralPartialEq for U256
Auto Trait Implementations
impl RefUnwindSafe for U256
impl Send for U256
impl Sync for U256
impl Unpin for U256
impl UnwindSafe for U256
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more