pub struct Circuit<F: Field> {
circuit_description: GKRCircuitDescription<F>,
pub circuit_map: CircuitMap,
partial_inputs: HashMap<NodeId, MultilinearExtension<F>>,
}Expand description
A circuit whose structure is fixed, but is not yet ready to be proven or verified because its missing all or some of its input data. This structs provides an API for attaching inputs and generating a form of the circuit that can be proven or verified respectively, for various proving systems (vanilla GKR with Ligero, or Hyrax).
Fields§
§circuit_description: GKRCircuitDescription<F>§circuit_map: CircuitMap§partial_inputs: HashMap<NodeId, MultilinearExtension<F>>Implementations§
Source§impl<F: Field> Circuit<F>
impl<F: Field> Circuit<F>
Sourcefn new(
circuit_description: GKRCircuitDescription<F>,
circuit_map: CircuitMap,
) -> Self
fn new( circuit_description: GKRCircuitDescription<F>, circuit_map: CircuitMap, ) -> Self
Constructor to be used by CircuitBuilder.
Sourcepub fn get_circuit_description(&self) -> &GKRCircuitDescription<F>
pub fn get_circuit_description(&self) -> &GKRCircuitDescription<F>
Return the [GKRCircuitDescription] inside this Circuit.
Sourcepub fn set_input(&mut self, shred_label: &str, data: MultilinearExtension<F>)
pub fn set_input(&mut self, shred_label: &str, data: MultilinearExtension<F>)
Assign data to the Input Shred with label shred_label.
§Panics
If shred_label does not correspond to any Input Shred, or if the this Input Shred has
already been assigned data. Use Self::update_input for replacing the data of a shred.
Sourcepub fn update_input(&mut self, shred_label: &str, data: MultilinearExtension<F>)
pub fn update_input(&mut self, shred_label: &str, data: MultilinearExtension<F>)
Assign data to the Input Shred with label shred_label, discarding any existing data
associated with this Input Shred.
§Panics
If shred_label does not correspond to any Input Shred.
Sourcepub fn contains_layer(&self, label: &str) -> bool
pub fn contains_layer(&self, label: &str) -> bool
Returns whether the circuit contains an Input Layer labeled label.
fn input_shred_contains_data(&self, shred_id: NodeId) -> bool
Sourcepub fn input_layer_contains_data(&self, label: &str) -> Result<bool>
pub fn input_layer_contains_data(&self, label: &str) -> Result<bool>
Returns whether data has already been assigned to the Input Layer labeled label, or an
error if no such input layer exists.
Sourcepub fn get_input_layer_description_ref(
&self,
layer_label: &str,
) -> &InputLayerDescription
pub fn get_input_layer_description_ref( &self, layer_label: &str, ) -> &InputLayerDescription
Returns the Input Layer Description of the Input Layer with label layer_label.
§Panics
If no such layer exists, or if self is in an inconsistent state.
Sourcefn build_input_layer_data(
&self,
layer_id: LayerId,
) -> Result<MultilinearExtension<F>>
fn build_input_layer_data( &self, layer_id: LayerId, ) -> Result<MultilinearExtension<F>>
Builds the layer MLE for layer_id by combining the data in all the input shreds of that layer.
Returns error if layer_id is an invalid input layer ID, or if any shred data is missing.
fn build_public_input_layer_data( &self, verifier_optional_inputs: bool, ) -> Result<HashMap<LayerId, MultilinearExtension<F>>>
fn build_all_input_layer_data( &self, ) -> Result<HashMap<LayerId, MultilinearExtension<F>>>
Sourcefn get_all_committed_input_layer_descriptions_to_ligero(
&self,
) -> Vec<LigeroInputLayerDescription<F>>
fn get_all_committed_input_layer_descriptions_to_ligero( &self, ) -> Vec<LigeroInputLayerDescription<F>>
Helper function for grabbing all of the committed input layers + descriptions from the circuit map.
We do this by first filtering all input layers which are LayerVisibility::Committed, getting all input “shreds” which correspond to those input layers, and aggregating those to compute the number of variables required to represent each input layer.
Finally, we set a default configuration for the Ligero PCS used to commit to each of the committed input layers’ MLEs. TODO(tfHARD team): add support for custom settings for the PCS configurations.
Sourcepub fn gen_hyrax_verifiable_circuit<C>(
&self,
) -> Result<HyraxVerifiableCircuit<C>>where
C: PrimeOrderCurve<Scalar = F>,
pub fn gen_hyrax_verifiable_circuit<C>(
&self,
) -> Result<HyraxVerifiableCircuit<C>>where
C: PrimeOrderCurve<Scalar = F>,
Returns a [HyraxVerifiableCircuit] containing the public input layer data that have been
added to self so far.
Sourcepub fn gen_hyrax_provable_circuit<C>(&self) -> Result<HyraxProvableCircuit<C>>where
C: PrimeOrderCurve<Scalar = F>,
pub fn gen_hyrax_provable_circuit<C>(&self) -> Result<HyraxProvableCircuit<C>>where
C: PrimeOrderCurve<Scalar = F>,
Produces a provable form of this circuit for the Hyrax-GKR proving system which uses Hyrax
as a commitment scheme for private input layers, and offers zero-knowledge guarantees.
Requires all input data to be populated (use Self::set_input() on all input shreds).
§Returns
The generated provable circuit, or an error if the self is missing input data.
Source§impl<F: Halo2FFTFriendlyField> Circuit<F>
impl<F: Halo2FFTFriendlyField> Circuit<F>
Sourcepub fn gen_provable_circuit(&self) -> Result<ProvableCircuit<F>>
pub fn gen_provable_circuit(&self) -> Result<ProvableCircuit<F>>
Produces a provable form of this circuit for the vanilla GKR proving system which uses
Ligero as a commitment scheme for committed input layers, and does not offer any
zero-knowledge guarantees.
Requires all input data to be populated (use Self::set_input() on all input shreds).
§Returns
The generated provable circuit, or an error if the self is missing input data.
Sourcepub fn gen_verifiable_circuit(&self) -> Result<VerifiableCircuit<F>>
pub fn gen_verifiable_circuit(&self) -> Result<VerifiableCircuit<F>>
Returns a [VerifiableCircuit] initialized with all input data which is already known to the verifier, but no commitments to the data in the committed input layers yet.
Trait Implementations§
Source§impl<'de, F> Deserialize<'de> for Circuit<F>where
F: Field,
impl<'de, F> Deserialize<'de> for Circuit<F>where
F: Field,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl<F> Freeze for Circuit<F>
impl<F> RefUnwindSafe for Circuit<F>where
F: RefUnwindSafe,
impl<F> Send for Circuit<F>
impl<F> Sync for Circuit<F>
impl<F> Unpin for Circuit<F>where
F: Unpin,
impl<F> UnwindSafe for Circuit<F>where
F: UnwindSafe,
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> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§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§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.