pub struct SBig { /* private fields */ }Expand description
Signed integer (-1)^neg · mag. Zero is always stored with neg = false.
Implementations§
Source§impl SBig
impl SBig
pub fn zero(bits: u32) -> Self
pub fn from_i64(v: i64) -> Self
pub fn is_neg(&self) -> Choice
pub fn mag(&self) -> &BoxedUint
pub fn is_zero(&self) -> Choice
pub fn bits_precision(&self) -> u32
pub fn negate(&self) -> Self
pub fn add(&self, rhs: &Self) -> Self
pub fn sub(&self, rhs: &Self) -> Self
pub fn mul(&self, rhs: &Self) -> Self
Sourcepub fn rem_euclid(&self, m: &NonZero<BoxedUint>) -> BoxedUint
pub fn rem_euclid(&self, m: &NonZero<BoxedUint>) -> BoxedUint
Euclidean remainder in [0, m).
Sourcepub fn random_in<R: Rng + ?Sized>(rng: &mut R, range: SRange) -> Self
pub fn random_in<R: Rng + ?Sized>(rng: &mut R, range: SRange) -> Self
Uniform sample from ±2^n: u − 2^{n−1} + 1 with u ← [0, 2^n).
Sourcepub fn random_in_size<R: Rng + ?Sized>(
rng: &mut R,
size: &BoxedUint,
) -> Result<Self>
pub fn random_in_size<R: Rng + ?Sized>( rng: &mut R, size: &BoxedUint, ) -> Result<Self>
Uniform sample from an interval of size consecutive integers {−size/2+1, …, size/2}
(size even, at least 2), i.e. the paper’s ±size.
Sourcepub fn to_bytes(&self, range: SRange) -> Result<Vec<u8>>
pub fn to_bytes(&self, range: SRange) -> Result<Vec<u8>>
Encodes as sign byte 0x00/0x01 followed by ⌈(n−1)/8⌉ big-endian magnitude bytes (spec §10.2).
pub fn from_bytes(bytes: &[u8], range: SRange) -> Result<Self>
Trait Implementations§
impl Eq for SBig
Auto Trait Implementations§
impl Freeze for SBig
impl RefUnwindSafe for SBig
impl Send for SBig
impl Sync for SBig
impl Unpin for SBig
impl UnsafeUnpin for SBig
impl UnwindSafe for SBig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more