[][src]Trait snarkos_models::gadgets::utilities::uint::unsigned_integer::UInt

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

Required methods

fn negate(&self) -> Self

Returns the inverse UInt

fn is_constant(&self) -> bool

Returns true if all bits in this UInt are constant

fn to_bits_le(&self) -> Vec<Boolean>

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.

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

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

fn rotr(&self, by: usize) -> Self

Rotate self bits by size

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

XOR this UInt with another UInt

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

Perform modular addition of several UInt objects.

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

Perform modular subtraction of two UInt objects.

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

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

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

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

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

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

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

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

Loading content...

Provided methods

fn result_is_constant(first: &Self, second: &Self) -> bool

Returns true if both UInt objects have constant bits

Loading content...

Implementors

impl UInt for UInt128[src]

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

Returns the inverse UInt128

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

Returns true if all bits in this UInt128 are constant

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

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

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

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

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

XOR this UInt128 with another UInt128

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

Perform modular addition of several UInt128 objects.

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

Perform modular subtraction of two UInt128 objects.

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

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

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

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

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

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

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

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

impl UInt for UInt8[src]

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

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

impl UInt for UInt16[src]

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

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

impl UInt for UInt32[src]

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

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

impl UInt for UInt64[src]

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

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

Loading content...