Trait snarkvm_wasm::traits::utilities::uint::UInt[][src]

pub trait UInt: Clone + PartialEq<Self> + Eq + PartialOrd<Self> + Debug {
    pub fn negate(&self) -> Self;
pub fn is_constant(&self) -> bool;
pub fn to_bits_le(&self) -> Vec<Boolean, Global>;
pub fn from_bits_le(bits: &[Boolean]) -> Self;
pub fn rotr(&self, by: usize) -> Self;
pub fn xor<F, CS>(
        &self,
        cs: CS,
        other: &Self
    ) -> Result<Self, SynthesisError>
    where
        CS: ConstraintSystem<F>,
        F: Field
;
pub fn addmany<F, CS>(
        cs: CS,
        operands: &[Self]
    ) -> Result<Self, SynthesisError>
    where
        CS: ConstraintSystem<F>,
        F: PrimeField
;
pub fn sub<F, CS>(
        &self,
        cs: CS,
        other: &Self
    ) -> Result<Self, SynthesisError>
    where
        CS: ConstraintSystem<F>,
        F: PrimeField
;
pub fn sub_unsafe<F, CS>(
        &self,
        cs: CS,
        other: &Self
    ) -> Result<Self, SynthesisError>
    where
        CS: ConstraintSystem<F>,
        F: PrimeField
;
pub fn mul<F, CS>(
        &self,
        cs: CS,
        other: &Self
    ) -> Result<Self, SynthesisError>
    where
        CS: ConstraintSystem<F>,
        F: PrimeField
;
pub fn div<F, CS>(
        &self,
        cs: CS,
        other: &Self
    ) -> Result<Self, SynthesisError>
    where
        CS: ConstraintSystem<F>,
        F: PrimeField
;
pub fn pow<F, CS>(
        &self,
        cs: CS,
        other: &Self
    ) -> Result<Self, SynthesisError>
    where
        CS: ConstraintSystem<F>,
        F: Field + PrimeField
; pub fn result_is_constant(first: &Self, second: &Self) -> bool { ... } }

Required methods

pub fn negate(&self) -> Self[src]

Returns the inverse UInt

pub fn is_constant(&self) -> bool[src]

Returns true if all bits in this UInt are constant

pub fn to_bits_le(&self) -> Vec<Boolean, Global>[src]

Turns this UInt into its little-endian byte order representation. LSB-first means that we can easily get the corresponding field element via double and add.

pub fn from_bits_le(bits: &[Boolean]) -> Self[src]

Converts a little-endian byte order representation of bits into a UInt.

pub fn rotr(&self, by: usize) -> Self[src]

Rotate self bits by size

pub fn xor<F, CS>(&self, cs: CS, other: &Self) -> Result<Self, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: Field
[src]

XOR this UInt with another UInt

pub fn addmany<F, CS>(cs: CS, operands: &[Self]) -> Result<Self, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Perform modular addition of several UInt objects.

pub fn sub<F, CS>(&self, cs: CS, other: &Self) -> Result<Self, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Perform modular subtraction of two UInt objects.

pub fn sub_unsafe<F, CS>(
    &self,
    cs: CS,
    other: &Self
) -> Result<Self, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Perform unsafe subtraction of two UInt objects which returns 0 if overflowed

pub fn mul<F, CS>(&self, cs: CS, other: &Self) -> Result<Self, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Perform Bitwise multiplication of two UInt objects. Reference: https://en.wikipedia.org/wiki/Binary_multiplier

pub fn div<F, CS>(&self, cs: CS, other: &Self) -> Result<Self, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Perform long division of two UInt objects. Reference: https://en.wikipedia.org/wiki/Division_algorithm

pub fn pow<F, CS>(&self, cs: CS, other: &Self) -> Result<Self, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: Field + PrimeField
[src]

Bitwise exponentiation of two UInt64 objects. Reference: /snarkVM/models/src/curves/field.rs

Loading content...

Provided methods

pub fn result_is_constant(first: &Self, second: &Self) -> bool[src]

Returns true if both UInt objects have constant bits

Loading content...

Implementors

impl UInt for UInt8[src]

pub fn sub_unsafe<F, CS>(
    &self,
    cs: CS,
    other: &UInt8
) -> Result<UInt8, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Used for division. Evaluates a - b, and when a - b < 0, returns 0.

impl UInt for UInt16[src]

pub fn sub_unsafe<F, CS>(
    &self,
    cs: CS,
    other: &UInt16
) -> Result<UInt16, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Used for division. Evaluates a - b, and when a - b < 0, returns 0.

impl UInt for UInt32[src]

pub fn sub_unsafe<F, CS>(
    &self,
    cs: CS,
    other: &UInt32
) -> Result<UInt32, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Used for division. Evaluates a - b, and when a - b < 0, returns 0.

impl UInt for UInt64[src]

pub fn sub_unsafe<F, CS>(
    &self,
    cs: CS,
    other: &UInt64
) -> Result<UInt64, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Used for division. Evaluates a - b, and when a - b < 0, returns 0.

impl UInt for UInt128[src]

pub fn negate(&self) -> UInt128[src]

Returns the inverse UInt128

pub fn is_constant(&self) -> bool[src]

Returns true if all bits in this UInt128 are constant

pub fn to_bits_le(&self) -> Vec<Boolean, Global>[src]

Turns this UInt128 into its little-endian byte order representation.

pub fn from_bits_le(bits: &[Boolean]) -> UInt128[src]

Converts a little-endian byte order representation of bits into a UInt128.

pub fn xor<F, CS>(
    &self,
    cs: CS,
    other: &UInt128
) -> Result<UInt128, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: Field
[src]

XOR this UInt128 with another UInt128

pub fn addmany<F, CS>(
    cs: CS,
    operands: &[UInt128]
) -> Result<UInt128, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Perform modular addition of several UInt128 objects.

pub fn sub<F, CS>(
    &self,
    cs: CS,
    other: &UInt128
) -> Result<UInt128, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Perform modular subtraction of two UInt128 objects.

pub fn sub_unsafe<F, CS>(
    &self,
    cs: CS,
    other: &UInt128
) -> Result<UInt128, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Perform unsafe subtraction of two UInt128 objects which returns 0 if overflowed

pub fn mul<F, CS>(
    &self,
    cs: CS,
    other: &UInt128
) -> Result<UInt128, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Bitwise multiplication of two UInt128 objects. Reference: https://en.wikipedia.org/wiki/Binary_multiplier

pub fn div<F, CS>(
    &self,
    cs: CS,
    other: &UInt128
) -> Result<UInt128, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: PrimeField
[src]

Perform long division of two UInt128 objects. Reference: https://en.wikipedia.org/wiki/Division_algorithm

pub fn pow<F, CS>(
    &self,
    cs: CS,
    other: &UInt128
) -> Result<UInt128, SynthesisError> where
    CS: ConstraintSystem<F>,
    F: Field + PrimeField
[src]

Bitwise multiplication of two UInt128 objects. Reference: /snarkVM/models/src/curves/field.rs

Loading content...