Skip to main content

BigUint

Struct BigUint 

Source
pub struct BigUint {
    pub limbs: Vec<Wire>,
}
Expand description

Represents an arbitrarily large unsigned integer using a vector of Wires

  • Each Wire holds 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

Source

pub fn new_inout(b: &CircuitBuilder, num_limbs: usize) -> Self

Creates a new BigUint with the given number of limbs as inout wires.

Source

pub fn new_witness(b: &CircuitBuilder, num_limbs: usize) -> Self

Creates a new BigUint with the given number of limbs as witness wires.

Source

pub fn new_constant(b: &CircuitBuilder, num_biguint: &BigUint) -> Self

Creates a constant BigUint from num_bigint::BigUint.

Source

pub fn zero_unless(&self, b: &CircuitBuilder, cond: Wire) -> Self

Returns zero unless the MSB-boolean cond is true, then passes the value unchanged.

Source

pub fn is_zero(&self, b: &CircuitBuilder) -> Wire

Checks whether BigUint is zero and returns the check result as a boolean wire.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for BigUint

Source§

fn clone(&self) -> BigUint

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

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more