mirror of https://github.com/zcash/halo2.git
Add bounds check to Assignment::query_instance impls.
This commit is contained in:
parent
c4e2554654
commit
9023161988
|
@ -297,6 +297,10 @@ impl<F: Field + Group> Assignment<F> for MockProver<F> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query_instance(&self, column: Column<Instance>, row: usize) -> Result<Option<F>, Error> {
|
fn query_instance(&self, column: Column<Instance>, row: usize) -> Result<Option<F>, Error> {
|
||||||
|
if !self.usable_rows.contains(&row) {
|
||||||
|
return Err(Error::BoundsFailure);
|
||||||
|
}
|
||||||
|
|
||||||
self.instance
|
self.instance
|
||||||
.get(column.index())
|
.get(column.index())
|
||||||
.and_then(|column| column.get(row))
|
.and_then(|column| column.get(row))
|
||||||
|
|
|
@ -308,8 +308,6 @@ impl<F: Field> Assignment<F> for Layout {
|
||||||
self.assign_fixed(annotation, selector.0, row, || Ok(F::one()))
|
self.assign_fixed(annotation, selector.0, row, || Ok(F::one()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query the value of the cell of an instance column at a particular
|
|
||||||
/// absolute row, if known.
|
|
||||||
fn query_instance(&self, _: Column<Instance>, _: usize) -> Result<Option<F>, Error> {
|
fn query_instance(&self, _: Column<Instance>, _: usize) -> Result<Option<F>, Error> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,11 @@ impl<F: Field> Assignment<F> for Assembly<F> {
|
||||||
self.assign_fixed(annotation, selector.0, row, || Ok(F::one()))
|
self.assign_fixed(annotation, selector.0, row, || Ok(F::one()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query_instance(&self, _: Column<Instance>, _: usize) -> Result<Option<F>, Error> {
|
fn query_instance(&self, _: Column<Instance>, row: usize) -> Result<Option<F>, Error> {
|
||||||
|
if !self.usable_rows.contains(&row) {
|
||||||
|
return Err(Error::BoundsFailure);
|
||||||
|
}
|
||||||
|
|
||||||
// There is no instance in this context.
|
// There is no instance in this context.
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,10 @@ pub fn create_proof<
|
||||||
column: Column<Instance>,
|
column: Column<Instance>,
|
||||||
row: usize,
|
row: usize,
|
||||||
) -> Result<Option<F>, Error> {
|
) -> Result<Option<F>, Error> {
|
||||||
|
if !self.usable_rows.contains(&row) {
|
||||||
|
return Err(Error::BoundsFailure);
|
||||||
|
}
|
||||||
|
|
||||||
self.instances
|
self.instances
|
||||||
.get(column.index())
|
.get(column.index())
|
||||||
.and_then(|column| column.get(row))
|
.and_then(|column| column.get(row))
|
||||||
|
|
Loading…
Reference in New Issue