pub struct BigInt { /* private fields */ }
Expand description
Big integer
Wraps underlying BigInt implementation (either GMP bindings or num-bigint), exposes only very limited API that allows easily switching between implementations.
Set of traits implemented on BigInt remains the same regardless of underlying implementation.
Trait Implementations
sourceimpl AddAssign<&BigInt> for BigInt
impl AddAssign<&BigInt> for BigInt
sourcefn add_assign(&mut self, rhs: &BigInt)
fn add_assign(&mut self, rhs: &BigInt)
Performs the
+=
operation. Read moresourceimpl AddAssign<BigInt> for BigInt
impl AddAssign<BigInt> for BigInt
sourcefn add_assign(&mut self, rhs: BigInt)
fn add_assign(&mut self, rhs: BigInt)
Performs the
+=
operation. Read moresourceimpl AddAssign<u64> for BigInt
impl AddAssign<u64> for BigInt
sourcefn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
Performs the
+=
operation. Read moresourceimpl BitAndAssign<&BigInt> for BigInt
impl BitAndAssign<&BigInt> for BigInt
sourcefn bitand_assign(&mut self, rhs: &BigInt)
fn bitand_assign(&mut self, rhs: &BigInt)
Performs the
&=
operation. Read moresourceimpl BitAndAssign<BigInt> for BigInt
impl BitAndAssign<BigInt> for BigInt
sourcefn bitand_assign(&mut self, rhs: BigInt)
fn bitand_assign(&mut self, rhs: BigInt)
Performs the
&=
operation. Read moresourceimpl BitManipulation for BigInt
impl BitManipulation for BigInt
sourceimpl BitOrAssign<&BigInt> for BigInt
impl BitOrAssign<&BigInt> for BigInt
sourcefn bitor_assign(&mut self, rhs: &BigInt)
fn bitor_assign(&mut self, rhs: &BigInt)
Performs the
|=
operation. Read moresourceimpl BitOrAssign<BigInt> for BigInt
impl BitOrAssign<BigInt> for BigInt
sourcefn bitor_assign(&mut self, rhs: BigInt)
fn bitor_assign(&mut self, rhs: BigInt)
Performs the
|=
operation. Read moresourceimpl BitXorAssign<&BigInt> for BigInt
impl BitXorAssign<&BigInt> for BigInt
sourcefn bitxor_assign(&mut self, rhs: &BigInt)
fn bitxor_assign(&mut self, rhs: &BigInt)
Performs the
^=
operation. Read moresourceimpl BitXorAssign<BigInt> for BigInt
impl BitXorAssign<BigInt> for BigInt
sourcefn bitxor_assign(&mut self, rhs: BigInt)
fn bitxor_assign(&mut self, rhs: BigInt)
Performs the
^=
operation. Read moresourceimpl Converter for BigInt
impl Converter for BigInt
sourcefn from_bytes(bytes: &[u8]) -> BigInt
fn from_bytes(bytes: &[u8]) -> BigInt
Constructs BigInt from its byte representation Read more
sourcefn to_str_radix(&self, radix: u8) -> String
fn to_str_radix(&self, radix: u8) -> String
Converts BigInt to radix representation. Read more
sourcefn from_str_radix(str: &str, radix: u8) -> Result<BigInt, ParseBigIntError>
fn from_str_radix(str: &str, radix: u8) -> Result<BigInt, ParseBigIntError>
Parses given radix string. Read more
sourcefn to_bytes_array<const N: usize>(&self) -> Option<[u8; N]>
fn to_bytes_array<const N: usize>(&self) -> Option<[u8; N]>
Returns bytes representation of the number in an array with length chosen by the user
if the array is larger than the bytes it pads it with zeros in the most significant bytes
If the array is too small for the integer it returns None. Read more
sourceimpl<'de> Deserialize<'de> for BigInt
impl<'de> Deserialize<'de> for BigInt
sourcefn deserialize<D>(
deserializer: D
) -> Result<BigInt, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<BigInt, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl DivAssign<&BigInt> for BigInt
impl DivAssign<&BigInt> for BigInt
sourcefn div_assign(&mut self, rhs: &BigInt)
fn div_assign(&mut self, rhs: &BigInt)
Performs the
/=
operation. Read moresourceimpl DivAssign<BigInt> for BigInt
impl DivAssign<BigInt> for BigInt
sourcefn div_assign(&mut self, rhs: BigInt)
fn div_assign(&mut self, rhs: BigInt)
Performs the
/=
operation. Read moresourceimpl DivAssign<u64> for BigInt
impl DivAssign<u64> for BigInt
sourcefn div_assign(&mut self, rhs: u64)
fn div_assign(&mut self, rhs: u64)
Performs the
/=
operation. Read moresourceimpl<'b> From<&'b BigInt> for Randomness
impl<'b> From<&'b BigInt> for Randomness
sourcefn from(x: &'b BigInt) -> Randomness
fn from(x: &'b BigInt) -> Randomness
Converts to this type from the input type.
sourceimpl<'b> From<&'b BigInt> for RawCiphertext<'b>
impl<'b> From<&'b BigInt> for RawCiphertext<'b>
sourceimpl<'b> From<&'b BigInt> for RawPlaintext<'b>
impl<'b> From<&'b BigInt> for RawPlaintext<'b>
sourceimpl<'n> From<&'n BigInt> for EncryptionKey
impl<'n> From<&'n BigInt> for EncryptionKey
sourceimpl From<BigInt> for Randomness
impl From<BigInt> for Randomness
sourcefn from(x: BigInt) -> Randomness
fn from(x: BigInt) -> Randomness
Converts to this type from the input type.
sourceimpl<'b> From<BigInt> for RawCiphertext<'b>
impl<'b> From<BigInt> for RawCiphertext<'b>
sourceimpl<'b> From<BigInt> for RawPlaintext<'b>
impl<'b> From<BigInt> for RawPlaintext<'b>
sourceimpl<'b> From<RawCiphertext<'b>> for BigInt
impl<'b> From<RawCiphertext<'b>> for BigInt
sourcefn from(x: RawCiphertext<'b>) -> Self
fn from(x: RawCiphertext<'b>) -> Self
Converts to this type from the input type.
sourceimpl<'b> From<RawPlaintext<'b>> for BigInt
impl<'b> From<RawPlaintext<'b>> for BigInt
sourcefn from(x: RawPlaintext<'b>) -> Self
fn from(x: RawPlaintext<'b>) -> Self
Converts to this type from the input type.
sourceimpl Integer for BigInt
impl Integer for BigInt
sourcefn gcd_lcm(&self, other: &BigInt) -> (BigInt, BigInt)
fn gcd_lcm(&self, other: &BigInt) -> (BigInt, BigInt)
Greatest Common Divisor (GCD) and
Lowest Common Multiple (LCM) together. Read more
sourcefn is_multiple_of(&self, other: &BigInt) -> bool
fn is_multiple_of(&self, other: &BigInt) -> bool
sourcefn div_rem(&self, other: &BigInt) -> (BigInt, BigInt)
fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt)
Simultaneous truncated integer division and modulus.
Returns
(quotient, remainder)
. Read moresourcefn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt)
fn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt)
Simultaneous floored integer division and modulus.
Returns
(quotient, remainder)
. Read moresourcefn next_multiple_of(&self, other: &BigInt) -> BigIntwhere
BigInt: Clone,
fn next_multiple_of(&self, other: &BigInt) -> BigIntwhere
BigInt: Clone,
Rounds up to nearest multiple of argument. Read more
sourcefn prev_multiple_of(&self, other: &BigInt) -> BigIntwhere
BigInt: Clone,
fn prev_multiple_of(&self, other: &BigInt) -> BigIntwhere
BigInt: Clone,
Rounds down to nearest multiple of argument. Read more
sourcefn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self>where
Self: Clone,
fn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self>where
Self: Clone,
Greatest common divisor and Bézout coefficients. Read more
sourceimpl Modulo for BigInt
impl Modulo for BigInt
sourceimpl MulAssign<&BigInt> for BigInt
impl MulAssign<&BigInt> for BigInt
sourcefn mul_assign(&mut self, rhs: &BigInt)
fn mul_assign(&mut self, rhs: &BigInt)
Performs the
*=
operation. Read moresourceimpl MulAssign<BigInt> for BigInt
impl MulAssign<BigInt> for BigInt
sourcefn mul_assign(&mut self, rhs: BigInt)
fn mul_assign(&mut self, rhs: BigInt)
Performs the
*=
operation. Read moresourceimpl MulAssign<u64> for BigInt
impl MulAssign<u64> for BigInt
sourcefn mul_assign(&mut self, rhs: u64)
fn mul_assign(&mut self, rhs: u64)
Performs the
*=
operation. Read moresourceimpl Num for BigInt
impl Num for BigInt
type FromStrRadixErr = ParseBigIntError
sourcefn from_str_radix(
str: &str,
radix: u32
) -> Result<BigInt, <BigInt as Num>::FromStrRadixErr>
fn from_str_radix(
str: &str,
radix: u32
) -> Result<BigInt, <BigInt as Num>::FromStrRadixErr>
Convert from a string and radix (typically
2..=36
). Read moresourceimpl NumberTests for BigInt
impl NumberTests for BigInt
sourceimpl Ord for BigInt
impl Ord for BigInt
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<BigInt> for BigInt
impl PartialOrd<BigInt> for BigInt
sourcefn partial_cmp(&self, other: &BigInt) -> Option<Ordering>
fn partial_cmp(&self, other: &BigInt) -> Option<Ordering>
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 moresourceimpl<'ek, 'r> PrecomputeRandomness<&'ek EncryptionKey, &'r BigInt, PrecomputedRandomness> for Paillier
impl<'ek, 'r> PrecomputeRandomness<&'ek EncryptionKey, &'r BigInt, PrecomputedRandomness> for Paillier
fn precompute(ek: &'ek EncryptionKey, r: &'r BigInt) -> PrecomputedRandomness
sourceimpl PrimeSampable for BigInt
impl PrimeSampable for BigInt
fn sample_prime(bitsize: usize) -> Self
fn sample_safe_prime(bitsize: usize) -> Self
sourceimpl Primes for BigInt
impl Primes for BigInt
sourcefn next_prime(&self) -> BigInt
fn next_prime(&self) -> BigInt
Finds next prime number using probabilistic algorithms
sourcefn is_probable_prime(&self, n: u32) -> bool
fn is_probable_prime(&self, n: u32) -> bool
Probabilistically determine whether number is prime Read more
sourceimpl RemAssign<&BigInt> for BigInt
impl RemAssign<&BigInt> for BigInt
sourcefn rem_assign(&mut self, rhs: &BigInt)
fn rem_assign(&mut self, rhs: &BigInt)
Performs the
%=
operation. Read moresourceimpl RemAssign<BigInt> for BigInt
impl RemAssign<BigInt> for BigInt
sourcefn rem_assign(&mut self, rhs: BigInt)
fn rem_assign(&mut self, rhs: BigInt)
Performs the
%=
operation. Read moresourceimpl RemAssign<u64> for BigInt
impl RemAssign<u64> for BigInt
sourcefn rem_assign(&mut self, rhs: u64)
fn rem_assign(&mut self, rhs: u64)
Performs the
%=
operation. Read moresourceimpl Roots for BigInt
impl Roots for BigInt
sourceimpl Samplable for BigInt
impl Samplable for BigInt
sourcefn sample_below(upper: &BigInt) -> BigInt
fn sample_below(upper: &BigInt) -> BigInt
Generates random number within
[0; upper)
range Read moresourcefn sample_range(lower: &BigInt, upper: &BigInt) -> BigInt
fn sample_range(lower: &BigInt, upper: &BigInt) -> BigInt
Generates random number within
[lower; upper)
range Read moresourcefn strict_sample_range(lower: &BigInt, upper: &BigInt) -> BigInt
fn strict_sample_range(lower: &BigInt, upper: &BigInt) -> BigInt
Generates random number within
(lower; upper)
range Read moresourcefn strict_sample(bit_size: usize) -> BigInt
fn strict_sample(bit_size: usize) -> BigInt
Generates number within
[2^(bit_size-1); 2^bit_size)
rangesourceimpl Serialize for BigInt
impl Serialize for BigInt
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl ShlAssign<usize> for BigInt
impl ShlAssign<usize> for BigInt
sourcefn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
Performs the
<<=
operation. Read moresourceimpl ShrAssign<usize> for BigInt
impl ShrAssign<usize> for BigInt
sourcefn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
Performs the
>>=
operation. Read moresourceimpl SubAssign<&BigInt> for BigInt
impl SubAssign<&BigInt> for BigInt
sourcefn sub_assign(&mut self, rhs: &BigInt)
fn sub_assign(&mut self, rhs: &BigInt)
Performs the
-=
operation. Read moresourceimpl SubAssign<BigInt> for BigInt
impl SubAssign<BigInt> for BigInt
sourcefn sub_assign(&mut self, rhs: BigInt)
fn sub_assign(&mut self, rhs: BigInt)
Performs the
-=
operation. Read moresourceimpl SubAssign<u64> for BigInt
impl SubAssign<u64> for BigInt
sourcefn sub_assign(&mut self, rhs: u64)
fn sub_assign(&mut self, rhs: u64)
Performs the
-=
operation. Read moresourceimpl ZeroizeBN for BigInt
impl ZeroizeBN for BigInt
sourcefn zeroize_bn(&mut self)
fn zeroize_bn(&mut self)
👎Deprecated since 0.6.0: BigInt now implements zeroize::Zeroize trait, you should use it instead
impl Eq for BigInt
impl StructuralEq for BigInt
impl StructuralPartialEq for BigInt
Auto Trait Implementations
impl RefUnwindSafe for BigInt
impl Send for BigInt
impl Sync for BigInt
impl Unpin for BigInt
impl UnwindSafe for BigInt
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more