diff --git a/benches/plonk.rs b/benches/plonk.rs index bf48509..1204336 100644 --- a/benches/plonk.rs +++ b/benches/plonk.rs @@ -20,7 +20,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) { // Initialize the polynomial commitment parameters let params: Params = Params::new(k); - #[derive(Copy, Clone)] + #[derive(Clone)] struct PLONKConfig { a: Column, b: Column, @@ -31,7 +31,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) { sc: Column, sm: Column, - perm: usize, + perm: Permutation, } trait StandardCS { @@ -156,21 +156,13 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) { )) } fn copy(&mut self, left: Variable, right: Variable) -> Result<(), Error> { - let left_column = match left.0 { - x if x == self.config.a => 0, - x if x == self.config.b => 1, - x if x == self.config.c => 2, - _ => unreachable!(), - }; - let right_column = match right.0 { - x if x == self.config.a => 0, - x if x == self.config.b => 1, - x if x == self.config.c => 2, - _ => unreachable!(), - }; - - self.cs - .copy(self.config.perm, left_column, left.1, right_column, right.1) + self.cs.copy( + &self.config.perm, + left.0.into(), + left.1, + right.0.into(), + right.1, + ) } } diff --git a/examples/circuit-layout.rs b/examples/circuit-layout.rs index ccd9338..14417e8 100644 --- a/examples/circuit-layout.rs +++ b/examples/circuit-layout.rs @@ -2,7 +2,7 @@ use halo2::{ arithmetic::FieldExt, dev::circuit_layout, pasta::Fp, - plonk::{Advice, Assignment, Circuit, Column, ConstraintSystem, Error, Fixed}, + plonk::{Advice, Assignment, Circuit, Column, ConstraintSystem, Error, Fixed, Permutation}, poly::Rotation, }; use plotters::prelude::*; @@ -30,8 +30,8 @@ fn main() { sl: Column, sl2: Column, - perm: usize, - perm2: usize, + perm: Permutation, + perm2: Permutation, } trait StandardCS { @@ -195,26 +195,18 @@ fn main() { )) } fn copy(&mut self, left: Variable, right: Variable) -> Result<(), Error> { - let left_column = match left.0 { - x if x == self.config.a => 0, - x if x == self.config.b => 1, - x if x == self.config.c => 2, - _ => unreachable!(), - }; - let right_column = match right.0 { - x if x == self.config.a => 0, - x if x == self.config.b => 1, - x if x == self.config.c => 2, - _ => unreachable!(), - }; - - self.cs - .copy(self.config.perm, left_column, left.1, right_column, right.1)?; self.cs.copy( - self.config.perm2, - left_column, + &self.config.perm, + left.0.into(), left.1, - right_column, + right.0.into(), + right.1, + )?; + self.cs.copy( + &self.config.perm2, + left.0.into(), + left.1, + right.0.into(), right.1, ) } diff --git a/src/dev/graph.rs b/src/dev/graph.rs index 6484864..cce172f 100644 --- a/src/dev/graph.rs +++ b/src/dev/graph.rs @@ -1,7 +1,9 @@ use ff::Field; use tabbycat::{AttrList, Edge, GraphBuilder, GraphType, Identity, StmtList}; -use crate::plonk::{Advice, Assignment, Circuit, Column, ConstraintSystem, Error, Fixed}; +use crate::plonk::{ + Advice, Any, Assignment, Circuit, Column, ConstraintSystem, Error, Fixed, Permutation, +}; pub mod layout; @@ -118,10 +120,10 @@ impl Assignment for Graph { fn copy( &mut self, + _: &Permutation, + _: Column, _: usize, - _: usize, - _: usize, - _: usize, + _: Column, _: usize, ) -> Result<(), crate::plonk::Error> { // Do nothing; we don't care about permutations in this context. diff --git a/src/dev/graph/layout.rs b/src/dev/graph/layout.rs index 71a91fc..5883253 100644 --- a/src/dev/graph/layout.rs +++ b/src/dev/graph/layout.rs @@ -6,7 +6,9 @@ use plotters::{ use std::cmp; use std::collections::HashSet; -use crate::plonk::{Advice, Any, Assignment, Circuit, Column, ConstraintSystem, Error, Fixed}; +use crate::plonk::{ + Advice, Any, Assignment, Circuit, Column, ConstraintSystem, Error, Fixed, Permutation, +}; /// Renders the circuit layout on the given drawing area. /// @@ -251,10 +253,10 @@ impl Assignment for Layout { fn copy( &mut self, + _: &Permutation, + _: Column, _: usize, - _: usize, - _: usize, - _: usize, + _: Column, _: usize, ) -> Result<(), crate::plonk::Error> { // Do nothing; we don't care about permutations in this context. diff --git a/src/plonk/circuit.rs b/src/plonk/circuit.rs index 4893ddd..2f1bba6 100644 --- a/src/plonk/circuit.rs +++ b/src/plonk/circuit.rs @@ -201,7 +201,7 @@ pub trait Assignment { A: FnOnce() -> AR, AR: Into; - /// Assign two advice columns to have the same value + /// Assign two cells to have the same value fn copy( &mut self, permutation: &Permutation,