mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
Abstract add_rotation() helper in plonk::circuit
This commit is contained in:
parent
4273bbb2ba
commit
e5f55a8576
1 changed files with 10 additions and 18 deletions
|
|
@ -344,9 +344,7 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
pub fn permutation(&mut self, columns: &[Column<Advice>]) -> usize {
|
pub fn permutation(&mut self, columns: &[Column<Advice>]) -> usize {
|
||||||
let index = self.permutations.len();
|
let index = self.permutations.len();
|
||||||
if self.permutations.is_empty() {
|
if self.permutations.is_empty() {
|
||||||
let at = Rotation(-1);
|
self.add_rotation(Rotation(-1));
|
||||||
let len = self.rotations.len();
|
|
||||||
self.rotations.entry(at).or_insert(PointIndex(len));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for column in columns {
|
for column in columns {
|
||||||
|
|
@ -370,9 +368,7 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
|
|
||||||
let index = self.lookups.len();
|
let index = self.lookups.len();
|
||||||
if self.lookups.is_empty() {
|
if self.lookups.is_empty() {
|
||||||
let at = Rotation(-1);
|
self.add_rotation(Rotation(-1));
|
||||||
let len = self.rotations.len();
|
|
||||||
self.rotations.entry(at).or_insert(PointIndex(len));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for input in input_columns {
|
for input in input_columns {
|
||||||
|
|
@ -389,10 +385,7 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
|
|
||||||
fn query_fixed_index(&mut self, column: Column<Fixed>, at: i32) -> usize {
|
fn query_fixed_index(&mut self, column: Column<Fixed>, at: i32) -> usize {
|
||||||
let at = Rotation(at);
|
let at = Rotation(at);
|
||||||
{
|
self.add_rotation(at);
|
||||||
let len = self.rotations.len();
|
|
||||||
self.rotations.entry(at).or_insert(PointIndex(len));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return existing query, if it exists
|
// Return existing query, if it exists
|
||||||
for (index, fixed_query) in self.fixed_queries.iter().enumerate() {
|
for (index, fixed_query) in self.fixed_queries.iter().enumerate() {
|
||||||
|
|
@ -415,10 +408,7 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
|
|
||||||
pub(crate) fn query_advice_index(&mut self, column: Column<Advice>, at: i32) -> usize {
|
pub(crate) fn query_advice_index(&mut self, column: Column<Advice>, at: i32) -> usize {
|
||||||
let at = Rotation(at);
|
let at = Rotation(at);
|
||||||
{
|
self.add_rotation(at);
|
||||||
let len = self.rotations.len();
|
|
||||||
self.rotations.entry(at).or_insert(PointIndex(len));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return existing query, if it exists
|
// Return existing query, if it exists
|
||||||
for (index, advice_query) in self.advice_queries.iter().enumerate() {
|
for (index, advice_query) in self.advice_queries.iter().enumerate() {
|
||||||
|
|
@ -441,10 +431,7 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
|
|
||||||
fn query_aux_index(&mut self, column: Column<Aux>, at: i32) -> usize {
|
fn query_aux_index(&mut self, column: Column<Aux>, at: i32) -> usize {
|
||||||
let at = Rotation(at);
|
let at = Rotation(at);
|
||||||
{
|
self.add_rotation(at);
|
||||||
let len = self.rotations.len();
|
|
||||||
self.rotations.entry(at).or_insert(PointIndex(len));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return existing query, if it exists
|
// Return existing query, if it exists
|
||||||
for (index, aux_query) in self.aux_queries.iter().enumerate() {
|
for (index, aux_query) in self.aux_queries.iter().enumerate() {
|
||||||
|
|
@ -568,4 +555,9 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
self.num_aux_columns += 1;
|
self.num_aux_columns += 1;
|
||||||
tmp
|
tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_rotation(&mut self, at: Rotation) {
|
||||||
|
let len = self.rotations.len();
|
||||||
|
self.rotations.entry(at).or_insert(PointIndex(len));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue