pub struct BigInt { /* private fields */ }Expand description
BigInt wrapper around clock-bigint’s U256.
Implementations§
Source§impl BigInt
impl BigInt
Sourcepub fn from_limbs(limbs: &[u64; 4]) -> Self
pub fn from_limbs(limbs: &[u64; 4]) -> Self
Create a BigInt from u64 limbs (little-endian).
Sourcepub fn from_bytes(bytes: &[u8; 32]) -> Self
pub fn from_bytes(bytes: &[u8; 32]) -> Self
Create a BigInt from bytes (little-endian).
Sourcepub fn mul(&self, rhs: &Self) -> Self
pub fn mul(&self, rhs: &Self) -> Self
Constant-time multiplication with proper overflow handling.
Returns the full 256-bit product. For modular arithmetic, the caller is responsible for reduction if needed.
Sourcepub fn mul_wide(&self, rhs: &Self) -> (Self, Self)
pub fn mul_wide(&self, rhs: &Self) -> (Self, Self)
Wide multiplication returning the full 512-bit result as (low, high) BigInts.
Sourcepub fn div_rem(&self, divisor: &Self) -> (Self, Self)
pub fn div_rem(&self, divisor: &Self) -> (Self, Self)
Division with remainder using binary long division.
Returns (quotient, remainder) where self = quotient * divisor + remainder. This implementation uses binary long division which is much more efficient than repeated subtraction.
Sourcepub fn get_bit(&self, bit_position: u32) -> u64
pub fn get_bit(&self, bit_position: u32) -> u64
Get the bit at the specified position (constant-time).
Returns 1 if the bit is set, 0 otherwise. Bit positions start from 0 (least significant bit).
Sourcepub fn bit_length(&self) -> u32
pub fn bit_length(&self) -> u32
Get the number of bits needed to represent this BigInt.
Returns the position of the highest set bit plus one. Returns 0 for zero.