Skip to main content

CircuitAnalyzer

Struct CircuitAnalyzer 

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

A Fancy object which counts gates and depth of a crate::circuit::Circuit.

Specifically, CircuitAnalyzer stores the number of inputs, ands, xors, negations, constants, multiplications, additions, subtractions, and multiplicative depth of the computation.

Implementations§

Source§

impl CircuitAnalyzer

Source

pub fn new() -> CircuitAnalyzer

Create a new CircuitAnalyzer.

Source

pub fn nands(&self) -> usize

The number of AND gates in the circuit.

Source

pub fn ninputs(&self) -> usize

The number of input wires of the circuit.

Source

pub fn nconstants(&self) -> usize

The number of constant wires of the circuit.

Source

pub fn nxors(&self) -> usize

The number of XOR gates in the circuit.

Source

pub fn eval<C: CircuitInputMapper<CircuitAnalyzer>>( &mut self, circuit: &C, ) -> Result<()>

Evaluate a circuit using CircuitAnalyzer.

The circuit needs to implement CircuitInputMapper as the circuit analysis is input-size-dependent.

Trait Implementations§

Source§

impl Clone for CircuitAnalyzer

Source§

fn clone(&self) -> CircuitAnalyzer

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CircuitAnalyzer

Source§

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

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

impl Default for CircuitAnalyzer

Source§

fn default() -> CircuitAnalyzer

Returns the “default value” for a type. Read more
Source§

impl Display for CircuitAnalyzer

Source§

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

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

impl Fancy for CircuitAnalyzer

Source§

type Item = AnalyzerItem

The underlying wire representation of this Fancy object.
Source§

fn constant( &mut self, _val: u16, q: u16, _: &mut Channel<'_>, ) -> Result<Self::Item>

Encode a constant x with modulus q.
Source§

impl FancyArithmetic for CircuitAnalyzer

Source§

fn add(&mut self, x: &Self::Item, y: &Self::Item) -> Self::Item

Add x and y. Read more
Source§

fn sub(&mut self, x: &Self::Item, y: &Self::Item) -> Self::Item

Subtract x and y. Read more
Source§

fn cmul(&mut self, x: &Self::Item, _y: u16) -> Self::Item

Multiply x with the constant c.
Source§

fn mul( &mut self, x: &Self::Item, y: &Self::Item, _: &mut Channel<'_>, ) -> Result<Self::Item>

Multiply x and y.
Source§

impl FancyBinary for CircuitAnalyzer

Source§

fn xor(&mut self, x: &Self::Item, y: &Self::Item) -> Self::Item

Binary XOR.
Source§

fn and( &mut self, x: &Self::Item, y: &Self::Item, _: &mut Channel<'_>, ) -> Result<Self::Item>

Binary AND.
Source§

fn negate(&mut self, x: &Self::Item) -> Self::Item

Binary negation.
Source§

fn or( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Binary OR.
Source§

impl FancyEncode for CircuitAnalyzer

Source§

fn receive_many( &mut self, moduli: &[u16], _: &mut Channel<'_>, ) -> Result<Vec<Self::Item>>

Receive many wires for unknown values.
Source§

fn encode_many( &mut self, _: &[u16], _: &[u16], _: &mut Channel<'_>, ) -> Result<Vec<Self::Item>>

Encode many wires for known values.
Source§

fn encode( &mut self, value: u16, modulus: u16, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Encode a wire for a known value.
Source§

fn receive( &mut self, modulus: u16, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Receive a wire for an unknown value.
Source§

impl FancyOutput for CircuitAnalyzer

Source§

fn output(&mut self, x: &Self::Item, _: &mut Channel<'_>) -> Result<Option<u16>>

Output the value associated with wire x. Read more
Source§

fn outputs( &mut self, xs: &[Self::Item], channel: &mut Channel<'_>, ) -> Result<Option<Vec<u16>>>

Output the values associated with a slice of wires. Read more
Source§

impl FancyProj for CircuitAnalyzer

Source§

fn proj( &mut self, _: &Self::Item, _: u16, _: Option<Vec<u16>>, _: &mut Channel<'_>, ) -> Result<Self::Item>

Project x according to the truth table tt. Resulting wire has modulus q. Read more
Source§

impl Ord for CircuitAnalyzer

Source§

fn cmp(&self, other: &CircuitAnalyzer) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for CircuitAnalyzer

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for CircuitAnalyzer

Source§

fn partial_cmp(&self, other: &CircuitAnalyzer) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for CircuitAnalyzer

Source§

impl StructuralPartialEq for CircuitAnalyzer

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<F> BinaryGadgets for F

Source§

fn bin_encode( &mut self, value: u128, nbits: usize, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>

Encode a binary input bundle.
Source§

fn bin_receive( &mut self, nbits: usize, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>

Receive an binary input bundle.
Source§

fn bin_encode_many( &mut self, values: &[u128], nbits: usize, channel: &mut Channel<'_>, ) -> Result<Vec<BinaryBundle<Self::Item>>>

Encode many binary input bundles.
Source§

fn bin_receive_many( &mut self, ninputs: usize, nbits: usize, channel: &mut Channel<'_>, ) -> Result<Vec<BinaryBundle<Self::Item>>>

Receive many binary input bundles.
Source§

fn bin_output( &mut self, x: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Option<u128>>

Output a binary bundle and interpret the result as a u128.
Source§

fn bin_outputs( &mut self, xs: &[BinaryBundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Option<Vec<u128>>>

Output a slice of binary bundles and interpret the results as a u128.
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<F> CrtGadgets for F

Source§

fn crt_encode( &mut self, value: u128, modulus: u128, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>

Encode a CRT input bundle.
Source§

fn crt_receive( &mut self, modulus: u128, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>

Receive an CRT input bundle.
Source§

fn crt_encode_many( &mut self, values: &[u128], modulus: u128, channel: &mut Channel<'_>, ) -> Result<Vec<CrtBundle<Self::Item>>>

Encode many CRT input bundles.
Source§

fn crt_receive_many( &mut self, n: usize, modulus: u128, channel: &mut Channel<'_>, ) -> Result<Vec<CrtBundle<Self::Item>>>

Receive many CRT input bundles.
Source§

fn crt_output( &mut self, x: &CrtBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Option<u128>>

Output a CRT bundle and interpret it mod Q.
Source§

fn crt_outputs( &mut self, xs: &[CrtBundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Option<Vec<u128>>>

Output a slice of CRT bundles and interpret the outputs mod Q.
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> 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> IsSameType<T> for T

§

const WITNESS: Witness<<T as IsSameType<T>>::EqualityProposition> = Witness::EQUAL_TYPES

A [Witness] that Self == T Read more
§

type EqualityProposition = TrueEqualityProposition

The [EqualityProposition] that Self == T
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,