mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-07 20:30:34 +00:00
Update tests
This commit is contained in:
parent
5a341b0f8f
commit
4ae21a905d
5 changed files with 35 additions and 47 deletions
|
|
@ -20,7 +20,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) {
|
||||||
// Initialize the polynomial commitment parameters
|
// Initialize the polynomial commitment parameters
|
||||||
let params: Params<EqAffine> = Params::new(k);
|
let params: Params<EqAffine> = Params::new(k);
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Clone)]
|
||||||
struct PLONKConfig {
|
struct PLONKConfig {
|
||||||
a: Column<Advice>,
|
a: Column<Advice>,
|
||||||
b: Column<Advice>,
|
b: Column<Advice>,
|
||||||
|
|
@ -31,7 +31,7 @@ fn bench_with_k(name: &str, k: u32, c: &mut Criterion) {
|
||||||
sc: Column<Fixed>,
|
sc: Column<Fixed>,
|
||||||
sm: Column<Fixed>,
|
sm: Column<Fixed>,
|
||||||
|
|
||||||
perm: usize,
|
perm: Permutation,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait StandardCS<FF: FieldExt> {
|
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> {
|
fn copy(&mut self, left: Variable, right: Variable) -> Result<(), Error> {
|
||||||
let left_column = match left.0 {
|
self.cs.copy(
|
||||||
x if x == self.config.a => 0,
|
&self.config.perm,
|
||||||
x if x == self.config.b => 1,
|
left.0.into(),
|
||||||
x if x == self.config.c => 2,
|
left.1,
|
||||||
_ => unreachable!(),
|
right.0.into(),
|
||||||
};
|
right.1,
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use halo2::{
|
||||||
arithmetic::FieldExt,
|
arithmetic::FieldExt,
|
||||||
dev::circuit_layout,
|
dev::circuit_layout,
|
||||||
pasta::Fp,
|
pasta::Fp,
|
||||||
plonk::{Advice, Assignment, Circuit, Column, ConstraintSystem, Error, Fixed},
|
plonk::{Advice, Assignment, Circuit, Column, ConstraintSystem, Error, Fixed, Permutation},
|
||||||
poly::Rotation,
|
poly::Rotation,
|
||||||
};
|
};
|
||||||
use plotters::prelude::*;
|
use plotters::prelude::*;
|
||||||
|
|
@ -30,8 +30,8 @@ fn main() {
|
||||||
sl: Column<Fixed>,
|
sl: Column<Fixed>,
|
||||||
sl2: Column<Fixed>,
|
sl2: Column<Fixed>,
|
||||||
|
|
||||||
perm: usize,
|
perm: Permutation,
|
||||||
perm2: usize,
|
perm2: Permutation,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait StandardCS<FF: FieldExt> {
|
trait StandardCS<FF: FieldExt> {
|
||||||
|
|
@ -195,26 +195,18 @@ fn main() {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
fn copy(&mut self, left: Variable, right: Variable) -> Result<(), Error> {
|
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.cs.copy(
|
||||||
self.config.perm2,
|
&self.config.perm,
|
||||||
left_column,
|
left.0.into(),
|
||||||
left.1,
|
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,
|
right.1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
use tabbycat::{AttrList, Edge, GraphBuilder, GraphType, Identity, StmtList};
|
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;
|
pub mod layout;
|
||||||
|
|
||||||
|
|
@ -118,10 +120,10 @@ impl<F: Field> Assignment<F> for Graph {
|
||||||
|
|
||||||
fn copy(
|
fn copy(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
_: &Permutation,
|
||||||
|
_: Column<Any>,
|
||||||
_: usize,
|
_: usize,
|
||||||
_: usize,
|
_: Column<Any>,
|
||||||
_: usize,
|
|
||||||
_: usize,
|
|
||||||
_: usize,
|
_: usize,
|
||||||
) -> Result<(), crate::plonk::Error> {
|
) -> Result<(), crate::plonk::Error> {
|
||||||
// Do nothing; we don't care about permutations in this context.
|
// Do nothing; we don't care about permutations in this context.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@ use plotters::{
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::collections::HashSet;
|
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.
|
/// Renders the circuit layout on the given drawing area.
|
||||||
///
|
///
|
||||||
|
|
@ -251,10 +253,10 @@ impl<F: Field> Assignment<F> for Layout {
|
||||||
|
|
||||||
fn copy(
|
fn copy(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
_: &Permutation,
|
||||||
|
_: Column<Any>,
|
||||||
_: usize,
|
_: usize,
|
||||||
_: usize,
|
_: Column<Any>,
|
||||||
_: usize,
|
|
||||||
_: usize,
|
|
||||||
_: usize,
|
_: usize,
|
||||||
) -> Result<(), crate::plonk::Error> {
|
) -> Result<(), crate::plonk::Error> {
|
||||||
// Do nothing; we don't care about permutations in this context.
|
// Do nothing; we don't care about permutations in this context.
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ pub trait Assignment<F: Field> {
|
||||||
A: FnOnce() -> AR,
|
A: FnOnce() -> AR,
|
||||||
AR: Into<String>;
|
AR: Into<String>;
|
||||||
|
|
||||||
/// Assign two advice columns to have the same value
|
/// Assign two cells to have the same value
|
||||||
fn copy(
|
fn copy(
|
||||||
&mut self,
|
&mut self,
|
||||||
permutation: &Permutation,
|
permutation: &Permutation,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue