Skip to main content

SBig

Struct SBig 

Source
pub struct SBig { /* private fields */ }
Expand description

Signed integer (-1)^neg · mag. Zero is always stored with neg = false.

Implementations§

Source§

impl SBig

Source

pub fn zero(bits: u32) -> Self

Source

pub fn from_uint(mag: BoxedUint) -> Self

Non-negative value.

Source

pub fn from_i64(v: i64) -> Self

Source

pub fn is_neg(&self) -> Choice

Source

pub fn mag(&self) -> &BoxedUint

Source

pub fn is_zero(&self) -> Choice

Source

pub fn bits_precision(&self) -> u32

Source

pub fn negate(&self) -> Self

Source

pub fn add(&self, rhs: &Self) -> Self

Source

pub fn sub(&self, rhs: &Self) -> Self

Source

pub fn mul(&self, rhs: &Self) -> Self

Source

pub fn rem_euclid(&self, m: &NonZero<BoxedUint>) -> BoxedUint

Euclidean remainder in [0, m).

Source

pub fn in_range(&self, range: SRange) -> bool

Checks |z| ≤ 2^{n−1} (public data).

Source

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).

Source

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.

Source

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).

Source

pub fn from_bytes(bytes: &[u8], range: SRange) -> Result<Self>

Trait Implementations§

Source§

impl Clone for SBig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SBig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SBig

Source§

impl PartialEq for SBig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Zeroize for SBig

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.