mirror of https://github.com/zcash/halo2.git
query_any: panic if query_fixed is called with non-cur Rotation.
This commit is contained in:
parent
7239a02ea3
commit
153a08c755
|
@ -27,6 +27,10 @@ and this project adheres to Rust's notion of
|
|||
- `halo2_proofs::arithmetic`:
|
||||
- `best_fft, recursive_butterfly_arithmetic` now use the `FftGroup` trait
|
||||
instead of the (now-removed) `pasta_curves::arithmetic::Group` trait.
|
||||
- `halo2::proofs::circuit`
|
||||
- `VirtualCells`
|
||||
- `query_any` now panics if a non-`cur` `Rotation` is used with the
|
||||
`Column<Fixed>` variant.
|
||||
|
||||
## [0.2.0] - 2022-06-23
|
||||
### Added
|
||||
|
|
|
@ -1169,17 +1169,18 @@ impl<F: Field> ConstraintSystem<F> {
|
|||
panic!("get_instance_query_index called for non-existent query");
|
||||
}
|
||||
|
||||
pub(crate) fn get_any_query_index(&self, column: Column<Any>, at: Rotation) -> usize {
|
||||
pub(crate) fn get_any_query_index(&self, column: Column<Any>) -> usize {
|
||||
match column.column_type() {
|
||||
Any::Advice => {
|
||||
self.get_advice_query_index(Column::<Advice>::try_from(column).unwrap(), at)
|
||||
}
|
||||
Any::Fixed => {
|
||||
self.get_fixed_query_index(Column::<Fixed>::try_from(column).unwrap(), at)
|
||||
}
|
||||
Any::Instance => {
|
||||
self.get_instance_query_index(Column::<Instance>::try_from(column).unwrap(), at)
|
||||
}
|
||||
Any::Advice => self.get_advice_query_index(
|
||||
Column::<Advice>::try_from(column).unwrap(),
|
||||
Rotation::cur(),
|
||||
),
|
||||
Any::Fixed => self
|
||||
.get_fixed_query_index(Column::<Fixed>::try_from(column).unwrap(), Rotation::cur()),
|
||||
Any::Instance => self.get_instance_query_index(
|
||||
Column::<Instance>::try_from(column).unwrap(),
|
||||
Rotation::cur(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1526,11 +1527,20 @@ impl<'a, F: Field> VirtualCells<'a, F> {
|
|||
}
|
||||
|
||||
/// Query an Any column at a relative position
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if query_fixed is called with a non-cur Rotation.
|
||||
pub fn query_any<C: Into<Column<Any>>>(&mut self, column: C, at: Rotation) -> Expression<F> {
|
||||
let column = column.into();
|
||||
match column.column_type() {
|
||||
Any::Advice => self.query_advice(Column::<Advice>::try_from(column).unwrap(), at),
|
||||
Any::Fixed => self.query_fixed(Column::<Fixed>::try_from(column).unwrap(), at),
|
||||
Any::Fixed => {
|
||||
if at != Rotation::cur() {
|
||||
panic!("Fixed columns can only be queried at the current rotation");
|
||||
}
|
||||
self.query_fixed(Column::<Fixed>::try_from(column).unwrap(), at)
|
||||
}
|
||||
Any::Instance => self.query_instance(Column::<Instance>::try_from(column).unwrap(), at),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,16 +162,9 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
for (eval, permutation_eval) in columns
|
||||
.iter()
|
||||
.map(|&column| match column.column_type() {
|
||||
Any::Advice => {
|
||||
advice_evals[vk.cs.get_any_query_index(column, Rotation::cur())]
|
||||
}
|
||||
Any::Fixed => {
|
||||
fixed_evals[vk.cs.get_any_query_index(column, Rotation::cur())]
|
||||
}
|
||||
Any::Instance => {
|
||||
instance_evals
|
||||
[vk.cs.get_any_query_index(column, Rotation::cur())]
|
||||
}
|
||||
Any::Advice => advice_evals[vk.cs.get_any_query_index(column)],
|
||||
Any::Fixed => fixed_evals[vk.cs.get_any_query_index(column)],
|
||||
Any::Instance => instance_evals[vk.cs.get_any_query_index(column)],
|
||||
})
|
||||
.zip(permutation_evals.iter())
|
||||
{
|
||||
|
@ -182,15 +175,9 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
let mut current_delta = (*beta * &*x)
|
||||
* &(C::Scalar::DELTA.pow_vartime([(chunk_index * chunk_len) as u64]));
|
||||
for eval in columns.iter().map(|&column| match column.column_type() {
|
||||
Any::Advice => {
|
||||
advice_evals[vk.cs.get_any_query_index(column, Rotation::cur())]
|
||||
}
|
||||
Any::Fixed => {
|
||||
fixed_evals[vk.cs.get_any_query_index(column, Rotation::cur())]
|
||||
}
|
||||
Any::Instance => {
|
||||
instance_evals[vk.cs.get_any_query_index(column, Rotation::cur())]
|
||||
}
|
||||
Any::Advice => advice_evals[vk.cs.get_any_query_index(column)],
|
||||
Any::Fixed => fixed_evals[vk.cs.get_any_query_index(column)],
|
||||
Any::Instance => instance_evals[vk.cs.get_any_query_index(column)],
|
||||
}) {
|
||||
right *= &(eval + ¤t_delta + &*gamma);
|
||||
current_delta *= &C::Scalar::DELTA;
|
||||
|
|
Loading…
Reference in New Issue