pub struct Mpi { /* private fields */ }
Implementations§
source§impl Mpi
impl Mpi
pub fn new(value: mpi_sint) -> Result<Mpi>
sourcepub fn from_binary(num: &[u8]) -> Result<Mpi>
pub fn from_binary(num: &[u8]) -> Result<Mpi>
Initialize an MPI number from big endian binary data
pub fn get_bit(&self, bit: usize) -> bool
pub fn set_bit(&mut self, bit: usize, val: bool) -> Result<()>
sourcepub fn less_than_const_time(&self, other: &Mpi) -> Result<bool>
pub fn less_than_const_time(&self, other: &Mpi) -> Result<bool>
Checks if an Mpi
is less than the other in constant time.
Will return Error::MpiBadInputData
if the allocated length of the two input Mpi
s is not the same.
sourcepub fn cmp_const_time(&self, other: &Mpi) -> Result<Ordering>
pub fn cmp_const_time(&self, other: &Mpi) -> Result<Ordering>
Compares an Mpi
with the other in constant time.
Will return Error::MpiBadInputData
if the allocated length of the two input Mpi
s is not the same.
sourcepub fn eq_const_time(&self, other: &Mpi) -> Result<bool>
pub fn eq_const_time(&self, other: &Mpi) -> Result<bool>
Checks equalness with the other in constant time.
pub fn as_u32(&self) -> Result<u32>
pub fn sign(&self) -> Sign
pub fn to_string_radix(&self, radix: i32) -> Result<String>
sourcepub fn to_binary_padded(&self, min_len: usize) -> Result<Vec<u8>>
pub fn to_binary_padded(&self, min_len: usize) -> Result<Vec<u8>>
Serialize the MPI as big endian binary data, padding to at least min_len bytes
sourcepub fn bit_length(&self) -> Result<usize>
pub fn bit_length(&self) -> Result<usize>
Return size of this MPI in bits
sourcepub fn byte_length(&self) -> Result<usize>
pub fn byte_length(&self) -> Result<usize>
Return size of this MPI in bytes (rounded up)
pub fn divrem(&self, other: &Mpi) -> Result<(Mpi, Mpi)>
pub fn divrem_int(&self, other: mpi_sint) -> Result<(Mpi, Mpi)>
pub fn modinv(&self, modulus: &Mpi) -> Result<Mpi>
sourcepub fn mod_sqrt(&self, p: &Mpi) -> Result<Mpi>
pub fn mod_sqrt(&self, p: &Mpi) -> Result<Mpi>
Returns an integer a such that (a*a) === self (mod p)
The modulus must be prime; computing a square root modulo a composite number is equivalent to factoring the composite.
pub fn trailing_zeros(&self) -> usize
Trait Implementations§
source§impl<'a> AddAssign<&'a Mpi> for Mpi
impl<'a> AddAssign<&'a Mpi> for Mpi
source§fn add_assign(&mut self, other: &Mpi)
fn add_assign(&mut self, other: &Mpi)
+=
operation. Read moresource§impl AddAssign<i64> for Mpi
impl AddAssign<i64> for Mpi
source§fn add_assign(&mut self, other: mpi_sint)
fn add_assign(&mut self, other: mpi_sint)
+=
operation. Read moresource§impl AddAssign for Mpi
impl AddAssign for Mpi
source§fn add_assign(&mut self, other: Mpi)
fn add_assign(&mut self, other: Mpi)
+=
operation. Read moresource§impl<'a> DivAssign<&'a Mpi> for Mpi
impl<'a> DivAssign<&'a Mpi> for Mpi
Note this will panic if other == 0
source§fn div_assign(&mut self, other: &Mpi)
fn div_assign(&mut self, other: &Mpi)
/=
operation. Read moresource§impl DivAssign<i64> for Mpi
impl DivAssign<i64> for Mpi
Note this will panic if other == 0
source§fn div_assign(&mut self, other: mpi_sint)
fn div_assign(&mut self, other: mpi_sint)
/=
operation. Read moresource§impl DivAssign for Mpi
impl DivAssign for Mpi
Note this will panic if other == 0
source§fn div_assign(&mut self, other: Mpi)
fn div_assign(&mut self, other: Mpi)
/=
operation. Read moresource§impl<'a> MulAssign<&'a Mpi> for Mpi
impl<'a> MulAssign<&'a Mpi> for Mpi
source§fn mul_assign(&mut self, other: &Mpi)
fn mul_assign(&mut self, other: &Mpi)
*=
operation. Read moresource§impl MulAssign<i64> for Mpi
impl MulAssign<i64> for Mpi
source§fn mul_assign(&mut self, other: mpi_sint)
fn mul_assign(&mut self, other: mpi_sint)
*=
operation. Read moresource§impl MulAssign for Mpi
impl MulAssign for Mpi
source§fn mul_assign(&mut self, other: Mpi)
fn mul_assign(&mut self, other: Mpi)
*=
operation. Read moresource§impl Ord for Mpi
impl Ord for Mpi
source§impl PartialOrd for Mpi
impl PartialOrd for Mpi
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a> RemAssign<&'a Mpi> for Mpi
impl<'a> RemAssign<&'a Mpi> for Mpi
Note this will panic if other == 0
source§fn rem_assign(&mut self, other: &Mpi)
fn rem_assign(&mut self, other: &Mpi)
%=
operation. Read moresource§impl RemAssign<i64> for Mpi
impl RemAssign<i64> for Mpi
Note this will panic if other == 0
source§fn rem_assign(&mut self, other: mpi_sint)
fn rem_assign(&mut self, other: mpi_sint)
%=
operation. Read moresource§impl RemAssign for Mpi
impl RemAssign for Mpi
Note this will panic if other == 0
source§fn rem_assign(&mut self, other: Mpi)
fn rem_assign(&mut self, other: Mpi)
%=
operation. Read moresource§impl ShlAssign<usize> for Mpi
impl ShlAssign<usize> for Mpi
source§fn shl_assign(&mut self, shift: usize)
fn shl_assign(&mut self, shift: usize)
<<=
operation. Read moresource§impl ShrAssign<usize> for Mpi
impl ShrAssign<usize> for Mpi
source§fn shr_assign(&mut self, shift: usize)
fn shr_assign(&mut self, shift: usize)
>>=
operation. Read moresource§impl<'a> SubAssign<&'a Mpi> for Mpi
impl<'a> SubAssign<&'a Mpi> for Mpi
source§fn sub_assign(&mut self, other: &Mpi)
fn sub_assign(&mut self, other: &Mpi)
-=
operation. Read moresource§impl SubAssign<i64> for Mpi
impl SubAssign<i64> for Mpi
source§fn sub_assign(&mut self, other: mpi_sint)
fn sub_assign(&mut self, other: mpi_sint)
-=
operation. Read moresource§impl SubAssign for Mpi
impl SubAssign for Mpi
source§fn sub_assign(&mut self, other: Mpi)
fn sub_assign(&mut self, other: Mpi)
-=
operation. Read more