pub struct BigUint {
pub limbs: Vec<Wire>,
}Expand description
Represents an arbitrarily large unsigned integer using a vector of Wires
- Each
Wireholds a 64-bit unsigned integer value (a “limb”) - Limbs are stored in little-endian order (index 0 = least significant)
- The total bit width is always a multiple of 64 bits (number of limbs × 64)
Fields§
§limbs: Vec<Wire>Implementations§
Source§impl BigUint
impl BigUint
Sourcepub fn new_inout(b: &CircuitBuilder, num_limbs: usize) -> Self
pub fn new_inout(b: &CircuitBuilder, num_limbs: usize) -> Self
Creates a new BigUint with the given number of limbs as inout wires.
Sourcepub fn new_witness(b: &CircuitBuilder, num_limbs: usize) -> Self
pub fn new_witness(b: &CircuitBuilder, num_limbs: usize) -> Self
Creates a new BigUint with the given number of limbs as witness wires.
Sourcepub fn new_constant(b: &CircuitBuilder, num_biguint: &BigUint) -> Self
pub fn new_constant(b: &CircuitBuilder, num_biguint: &BigUint) -> Self
Creates a constant BigUint from num_bigint::BigUint.
Sourcepub fn zero_unless(&self, b: &CircuitBuilder, cond: Wire) -> Self
pub fn zero_unless(&self, b: &CircuitBuilder, cond: Wire) -> Self
Returns zero unless the MSB-boolean cond is true, then passes the value unchanged.
Sourcepub fn is_zero(&self, b: &CircuitBuilder) -> Wire
pub fn is_zero(&self, b: &CircuitBuilder) -> Wire
Checks whether BigUint is zero and returns the check result as a boolean wire.
Sourcepub fn zero_extend(&self, b: &CircuitBuilder, new_limbs_len: usize) -> Self
pub fn zero_extend(&self, b: &CircuitBuilder, new_limbs_len: usize) -> Self
Pads to given limb length with zeros.
No-op if new_limbs_len is shorter then the current one.
Sourcepub fn pad_limbs_to(&self, new_limbs_len: usize, padding_value: Wire) -> Self
pub fn pad_limbs_to(&self, new_limbs_len: usize, padding_value: Wire) -> Self
Pads to given limb length with a wire value.
No-op if new_limbs_len is shorter then the current one.
Sourcepub fn split_at_limbs(self, at_limbs: usize) -> (Self, Self)
pub fn split_at_limbs(self, at_limbs: usize) -> (Self, Self)
Splits the BigUint at a given limb position into (lo, hi). The result
satisfies lo + 2^(Word::BITS * lo.limbs.len()) * hi.
Sourcepub fn concat_limbs(&self, hi: &Self) -> Self
pub fn concat_limbs(&self, hi: &Self) -> Self
Concatenate the limbs of another BigUint on top. The resulting value
equals self + 2^(Word::BITS * self.limbs.len()) * hi.
Sourcepub fn populate_limbs(&self, w: &mut WitnessFiller<'_>, limb_values: &[u64])
pub fn populate_limbs(&self, w: &mut WitnessFiller<'_>, limb_values: &[u64])
Populate the BigUint with the expected limb_values
Panics if limb_values.len() != self.limbs.len()
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BigUint
impl RefUnwindSafe for BigUint
impl Send for BigUint
impl Sync for BigUint
impl Unpin for BigUint
impl UnsafeUnpin for BigUint
impl UnwindSafe for BigUint
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more