mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
Modify Assignment::copy() to take Column<Any> instead of usize
This commit is contained in:
parent
d82a0c85b1
commit
5a341b0f8f
7 changed files with 53 additions and 58 deletions
|
|
@ -157,24 +157,11 @@ impl<'a, FF: FieldExt, CS: Assignment<FF>> StandardCS<FF> for StandardPLONK<'a,
|
|||
))
|
||||
}
|
||||
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.0.into(),
|
||||
left.1,
|
||||
right_column,
|
||||
right.0.into(),
|
||||
right.1,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -320,22 +320,11 @@ impl<'r, 'a, C: Chip, CS: Assignment<C::Field> + 'a> RegionLayouter<C>
|
|||
left: Cell,
|
||||
right: Cell,
|
||||
) -> Result<(), Error> {
|
||||
let left_column = permutation
|
||||
.mapping()
|
||||
.iter()
|
||||
.position(|c| c == &left.column)
|
||||
.ok_or(Error::SynthesisError)?;
|
||||
let right_column = permutation
|
||||
.mapping()
|
||||
.iter()
|
||||
.position(|c| c == &right.column)
|
||||
.ok_or(Error::SynthesisError)?;
|
||||
|
||||
self.layouter.cs.copy(
|
||||
permutation,
|
||||
left_column,
|
||||
left.column,
|
||||
*self.layouter.regions[*left.region_index] + left.row_offset,
|
||||
right_column,
|
||||
right.column,
|
||||
*self.layouter.regions[*right.region_index] + right.row_offset,
|
||||
)?;
|
||||
|
||||
|
|
|
|||
24
src/dev.rs
24
src/dev.rs
|
|
@ -5,7 +5,7 @@ use ff::Field;
|
|||
use crate::{
|
||||
arithmetic::{FieldExt, Group},
|
||||
plonk::{
|
||||
permutation, Advice, Assignment, Circuit, Column, ColumnType, ConstraintSystem, Error,
|
||||
permutation, Advice, Any, Assignment, Circuit, Column, ColumnType, ConstraintSystem, Error,
|
||||
Expression, Fixed, Permutation,
|
||||
},
|
||||
poly::Rotation,
|
||||
|
|
@ -212,9 +212,9 @@ impl<F: Field + Group> Assignment<F> for MockProver<F> {
|
|||
fn copy(
|
||||
&mut self,
|
||||
permutation: &Permutation,
|
||||
left_column: usize,
|
||||
left_column: Column<Any>,
|
||||
left_row: usize,
|
||||
right_column: usize,
|
||||
right_column: Column<Any>,
|
||||
right_row: usize,
|
||||
) -> Result<(), crate::plonk::Error> {
|
||||
// Check bounds first
|
||||
|
|
@ -222,7 +222,23 @@ impl<F: Field + Group> Assignment<F> for MockProver<F> {
|
|||
return Err(Error::BoundsFailure);
|
||||
}
|
||||
|
||||
self.permutations[permutation.index()].copy(left_column, left_row, right_column, right_row)
|
||||
let left_column_index = permutation
|
||||
.mapping()
|
||||
.iter()
|
||||
.position(|c| c == &left_column)
|
||||
.ok_or(Error::SynthesisError)?;
|
||||
let right_column_index = permutation
|
||||
.mapping()
|
||||
.iter()
|
||||
.position(|c| c == &right_column)
|
||||
.ok_or(Error::SynthesisError)?;
|
||||
|
||||
self.permutations[permutation.index()].copy(
|
||||
left_column_index,
|
||||
left_row,
|
||||
right_column_index,
|
||||
right_row,
|
||||
)
|
||||
}
|
||||
|
||||
fn push_namespace<NR, N>(&mut self, _: N)
|
||||
|
|
|
|||
21
src/plonk.rs
21
src/plonk.rs
|
|
@ -380,31 +380,18 @@ fn test_proving() {
|
|||
))
|
||||
}
|
||||
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.0.into(),
|
||||
left.1,
|
||||
right_column,
|
||||
right.0.into(),
|
||||
right.1,
|
||||
)?;
|
||||
self.cs.copy(
|
||||
&self.config.perm2,
|
||||
left_column,
|
||||
left.0.into(),
|
||||
left.1,
|
||||
right_column,
|
||||
right.0.into(),
|
||||
right.1,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,9 +205,9 @@ pub trait Assignment<F: Field> {
|
|||
fn copy(
|
||||
&mut self,
|
||||
permutation: &Permutation,
|
||||
left_column: usize,
|
||||
left_column: Column<Any>,
|
||||
left_row: usize,
|
||||
right_column: usize,
|
||||
right_column: Column<Any>,
|
||||
right_row: usize,
|
||||
) -> Result<(), Error>;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use ff::Field;
|
|||
use group::Curve;
|
||||
|
||||
use super::{
|
||||
circuit::{Advice, Assignment, Circuit, Column, ConstraintSystem, Fixed},
|
||||
circuit::{Advice, Any, Assignment, Circuit, Column, ConstraintSystem, Fixed},
|
||||
permutation, Error, LagrangeCoeff, Permutation, Polynomial, ProvingKey, VerifyingKey,
|
||||
};
|
||||
use crate::arithmetic::CurveAffine;
|
||||
|
|
@ -117,9 +117,9 @@ impl<F: Field> Assignment<F> for Assembly<F> {
|
|||
fn copy(
|
||||
&mut self,
|
||||
permutation: &Permutation,
|
||||
left_column: usize,
|
||||
left_column: Column<Any>,
|
||||
left_row: usize,
|
||||
right_column: usize,
|
||||
right_column: Column<Any>,
|
||||
right_row: usize,
|
||||
) -> Result<(), Error> {
|
||||
// Check bounds first
|
||||
|
|
@ -127,7 +127,23 @@ impl<F: Field> Assignment<F> for Assembly<F> {
|
|||
return Err(Error::BoundsFailure);
|
||||
}
|
||||
|
||||
self.permutations[permutation.index()].copy(left_column, left_row, right_column, right_row)
|
||||
let left_column_index = permutation
|
||||
.mapping()
|
||||
.iter()
|
||||
.position(|c| c == &left_column)
|
||||
.ok_or(Error::SynthesisError)?;
|
||||
let right_column_index = permutation
|
||||
.mapping()
|
||||
.iter()
|
||||
.position(|c| c == &right_column)
|
||||
.ok_or(Error::SynthesisError)?;
|
||||
|
||||
self.permutations[permutation.index()].copy(
|
||||
left_column_index,
|
||||
left_row,
|
||||
right_column_index,
|
||||
right_row,
|
||||
)
|
||||
}
|
||||
|
||||
fn push_namespace<NR, N>(&mut self, _: N)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use group::Curve;
|
|||
use std::iter;
|
||||
|
||||
use super::{
|
||||
circuit::{Advice, Assignment, Circuit, Column, ConstraintSystem, Fixed},
|
||||
circuit::{Advice, Any, Assignment, Circuit, Column, ConstraintSystem, Fixed},
|
||||
lookup, permutation, vanishing, ChallengeBeta, ChallengeGamma, ChallengeTheta, ChallengeX,
|
||||
ChallengeY, Error, Permutation, ProvingKey,
|
||||
};
|
||||
|
|
@ -160,9 +160,9 @@ pub fn create_proof<C: CurveAffine, T: TranscriptWrite<C>, ConcreteCircuit: Circ
|
|||
fn copy(
|
||||
&mut self,
|
||||
_: &Permutation,
|
||||
_: Column<Any>,
|
||||
_: usize,
|
||||
_: usize,
|
||||
_: usize,
|
||||
_: Column<Any>,
|
||||
_: usize,
|
||||
) -> Result<(), Error> {
|
||||
// We only care about advice columns here
|
||||
|
|
|
|||
Loading…
Reference in a new issue