Skip to content

Commit

Permalink
Merge pull request zcash#181 from privacy-scaling-explorations/featur…
Browse files Browse the repository at this point in the history
…e/more-getters

Add more getters to expose internal fields
  • Loading branch information
ed255 authored May 15, 2023
2 parents be95568 + 73b66d0 commit d374610
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
11 changes: 11 additions & 0 deletions halo2_proofs/src/dev/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ pub struct Column {
pub(super) index: usize,
}

impl Column {
/// Return the column type.
pub fn column_type(&self) -> Any {
self.column_type
}
/// Return the column index.
pub fn index(&self) -> usize {
self.index
}
}

impl fmt::Display for Column {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Column('{:?}', {})", self.column_type, self.index)
Expand Down
23 changes: 20 additions & 3 deletions halo2_proofs/src/plonk/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ impl Selector {
self.1
}

/// Returns index of this selector
pub fn index(&self) -> usize {
self.0
}

/// Return expression from selector
pub fn expr<F: Field>(&self) -> Expression<F> {
Expression::Selector(*self)
Expand Down Expand Up @@ -1498,11 +1503,13 @@ pub struct Gate<F: Field> {
}

impl<F: Field> Gate<F> {
pub(crate) fn name(&self) -> &str {
/// Returns the gate name.
pub fn name(&self) -> &str {
self.name.as_str()
}

pub(crate) fn constraint_name(&self, constraint_index: usize) -> &str {
/// Returns the name of the constraint at index `constraint_index`.
pub fn constraint_name(&self, constraint_index: usize) -> &str {
self.constraint_names[constraint_index].as_str()
}

Expand Down Expand Up @@ -1903,7 +1910,7 @@ impl<F: Field> ConstraintSystem<F> {
/// find which fixed column corresponds with a given `Selector`.
///
/// Do not call this twice. Yes, this should be a builder pattern instead.
pub(crate) fn compress_selectors(mut self, selectors: Vec<Vec<bool>>) -> (Self, Vec<Vec<F>>) {
pub fn compress_selectors(mut self, selectors: Vec<Vec<bool>>) -> (Self, Vec<Vec<F>>) {
// The number of provided selector assignments must be the number we
// counted for this constraint system.
assert_eq!(selectors.len(), self.num_selectors);
Expand Down Expand Up @@ -2240,6 +2247,11 @@ impl<F: Field> ConstraintSystem<F> {
self.num_instance_columns
}

/// Returns number of selectors
pub fn num_selectors(&self) -> usize {
self.num_selectors
}

/// Returns number of challenges
pub fn num_challenges(&self) -> usize {
self.num_challenges
Expand All @@ -2263,6 +2275,11 @@ impl<F: Field> ConstraintSystem<F> {
&self.gates
}

/// Returns general column annotations
pub fn general_column_annotations(&self) -> &HashMap<metadata::Column, String> {
&self.general_column_annotations
}

/// Returns advice queries
pub fn advice_queries(&self) -> &Vec<(Column<Advice>, Rotation)> {
&self.advice_queries
Expand Down
5 changes: 5 additions & 0 deletions halo2_proofs/src/plonk/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,9 @@ impl<F: Field> Argument<F> {
pub fn table_expressions(&self) -> &Vec<Expression<F>> {
&self.table_expressions
}

/// Returns name of this argument
pub fn name(&self) -> &str {
&self.name
}
}

0 comments on commit d374610

Please sign in to comment.