Merge pull request #385 from zcash/perm-not-enabled

Introduce plonk::Error::ColumnNotInPermutation error.
This commit is contained in:
str4d 2021-11-23 22:23:00 +00:00 committed by GitHub
commit 8bfc58b7c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -3,6 +3,8 @@ use std::error;
use std::fmt;
use std::io;
use super::{Any, Column};
/// This is an error that could occur during proving or circuit synthesis.
// TODO: these errors need to be cleaned up
#[derive(Debug)]
@ -32,6 +34,9 @@ pub enum Error {
///
/// [`ConstraintSystem::enable_constant`]: crate::plonk::ConstraintSystem::enable_constant
NotEnoughColumnsForConstants,
/// The instance sets up a copy constraint involving a column that has not been
/// included in the permutation.
ColumnNotInPermutation(Column<Any>),
}
impl From<io::Error> for Error {
@ -69,6 +74,11 @@ impl fmt::Display for Error {
"Too few fixed columns are enabled for global constants usage"
)
}
Error::ColumnNotInPermutation(column) => write!(
f,
"Column {:?} must be included in the permutation.",
column
),
}
}
}

View File

@ -51,12 +51,12 @@ impl Assembly {
.columns
.iter()
.position(|c| c == &left_column)
.ok_or(Error::Synthesis)?;
.ok_or(Error::ColumnNotInPermutation(left_column))?;
let right_column = self
.columns
.iter()
.position(|c| c == &right_column)
.ok_or(Error::Synthesis)?;
.ok_or(Error::ColumnNotInPermutation(right_column))?;
// Check bounds
if left_row >= self.mapping[left_column].len()