[][src]Struct parity_bn::arith::U256

#[repr(C)]
pub struct U256(pub [u128; 2]);

256-bit, stack allocated biginteger for use in prime field arithmetic.

Methods

impl U256[src]

pub fn from_slice(s: &[u8]) -> Result<U256, Error>[src]

Initialize U256 from slice of bytes (big endian)

pub fn to_big_endian(&self, s: &mut [u8]) -> Result<(), Error>[src]

pub fn zero() -> U256[src]

pub fn one() -> U256[src]

pub fn random<R: Rng>(rng: &mut R, modulo: &U256) -> U256[src]

Produce a random number (mod modulo)

pub fn is_zero(&self) -> bool[src]

pub fn set_bit(&mut self, n: usize, to: bool) -> bool[src]

pub fn get_bit(&self, n: usize) -> Option<bool>[src]

pub fn add(&mut self, other: &U256, modulo: &U256)[src]

Add other to self (mod modulo)

pub fn sub(&mut self, other: &U256, modulo: &U256)[src]

Subtract other from self (mod modulo)

pub fn mul(&mut self, other: &U256, modulo: &U256, inv: u128)[src]

Multiply self by other (mod modulo) via the Montgomery multiplication method.

pub fn neg(&mut self, modulo: &U256)[src]

Turn self into its additive inverse (mod modulo)

pub fn is_even(&self) -> bool[src]

pub fn invert(&mut self, modulo: &U256)[src]

Turn self into its multiplicative inverse (mod modulo)

Important traits for BitIterator<'a>
pub fn bits(&self) -> BitIterator[src]

Return an Iterator<Item=bool> over all bits from MSB to LSB.

Trait Implementations

impl PartialOrd<U256> for U256[src]

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Copy for U256[src]

impl PartialEq<U256> for U256[src]

impl From<[u64; 4]> for U256[src]

impl From<u64> for U256[src]

impl Clone for U256[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Ord for U256[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Returns max if self is greater than max, and min if self is less than min. Otherwise this will return self. Panics if min > max. Read more

impl Eq for U256[src]

impl Debug for U256[src]

impl Encodable for U256[src]

impl Decodable for U256[src]

Auto Trait Implementations

impl Send for U256

impl Sync for U256

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.