mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-06 20:20:34 +00:00
Add generic query_any_index() and get_any_query_index methods
This commit is contained in:
parent
075988ae4e
commit
34c6cba537
1 changed files with 33 additions and 1 deletions
|
|
@ -399,6 +399,17 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
index
|
index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Query an Any column at a relative position
|
||||||
|
fn query_any_index(&mut self, column: Column<Any>, at: i32) -> usize {
|
||||||
|
let index = match column.column_type {
|
||||||
|
Any::Advice => self.query_advice_index(Column::<Advice>::from(column), at),
|
||||||
|
Any::Fixed => self.query_fixed_index(Column::<Fixed>::from(column), at),
|
||||||
|
Any::Aux => self.query_aux_index(Column::<Aux>::from(column), at),
|
||||||
|
};
|
||||||
|
|
||||||
|
index
|
||||||
|
}
|
||||||
|
|
||||||
/// Query an auxiliary column at a relative position
|
/// Query an auxiliary column at a relative position
|
||||||
pub fn query_aux(&mut self, column: Column<Aux>, at: i32) -> Expression<F> {
|
pub fn query_aux(&mut self, column: Column<Aux>, at: i32) -> Expression<F> {
|
||||||
Expression::Aux(self.query_aux_index(column, at))
|
Expression::Aux(self.query_aux_index(column, at))
|
||||||
|
|
@ -412,7 +423,7 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
panic!("get_advice_query_index called for non-existant query");
|
panic!("get_advice_query_index called for non-existent query");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_fixed_query_index(&self, column: Column<Fixed>, at: i32) -> usize {
|
pub(crate) fn get_fixed_query_index(&self, column: Column<Fixed>, at: i32) -> usize {
|
||||||
|
|
@ -426,6 +437,27 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
panic!("get_fixed_query_index called for non-existent query");
|
panic!("get_fixed_query_index called for non-existent query");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_aux_query_index(&self, column: Column<Aux>, at: i32) -> usize {
|
||||||
|
let at = Rotation(at);
|
||||||
|
for (index, aux_query) in self.aux_queries.iter().enumerate() {
|
||||||
|
if aux_query == &(column, at) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
panic!("get_aux_query_index called for non-existent query");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_any_query_index(&self, column: Column<Any>, at: i32) -> usize {
|
||||||
|
let index = match column.column_type {
|
||||||
|
Any::Advice => self.get_advice_query_index(Column::<Advice>::from(column), at),
|
||||||
|
Any::Fixed => self.get_fixed_query_index(Column::<Fixed>::from(column), at),
|
||||||
|
Any::Aux => self.get_aux_query_index(Column::<Aux>::from(column), at),
|
||||||
|
};
|
||||||
|
|
||||||
|
index
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a new gate
|
/// Create a new gate
|
||||||
pub fn create_gate(&mut self, f: impl FnOnce(&mut Self) -> Expression<F>) {
|
pub fn create_gate(&mut self, f: impl FnOnce(&mut Self) -> Expression<F>) {
|
||||||
let poly = f(self);
|
let poly = f(self);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue