Update tests

This commit is contained in:
therealyingtong 2021-02-19 15:24:21 +08:00
parent 5a341b0f8f
commit 4ae21a905d
5 changed files with 35 additions and 47 deletions

View file

@ -20,7 +20,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) {
// Initialize the polynomial commitment parameters
let params: Params<EqAffine> = Params::new(k);
#[derive(Copy, Clone)]
#[derive(Clone)]
struct PLONKConfig {
a: Column<Advice>,
b: Column<Advice>,
@ -31,7 +31,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) {
sc: Column<Fixed>,
sm: Column<Fixed>,
perm: usize,
perm: Permutation,
}
trait StandardCS<FF: FieldExt> {
@ -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,
)
}
}

View file

@ -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<Fixed>,
sl2: Column<Fixed>,
perm: usize,
perm2: usize,
perm: Permutation,
perm2: Permutation,
}
trait StandardCS<FF: FieldExt> {
@ -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,
)
}

View file

@ -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<F: Field> Assignment<F> for Graph {
fn copy(
&mut self,
_: &Permutation,
_: Column<Any>,
_: usize,
_: usize,
_: usize,
_: usize,
_: Column<Any>,
_: usize,
) -> Result<(), crate::plonk::Error> {
// Do nothing; we don't care about permutations in this context.

View file

@ -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<F: Field> Assignment<F> for Layout {
fn copy(
&mut self,
_: &Permutation,
_: Column<Any>,
_: usize,
_: usize,
_: usize,
_: usize,
_: Column<Any>,
_: usize,
) -> Result<(), crate::plonk::Error> {
// Do nothing; we don't care about permutations in this context.

View file

@ -201,7 +201,7 @@ pub trait Assignment<F: Field> {
A: FnOnce() -> AR,
AR: Into<String>;
/// Assign two advice columns to have the same value
/// Assign two cells to have the same value
fn copy(
&mut self,
permutation: &Permutation,