diff --git a/hashes/zkevm/src/sha256/vanilla/columns.rs b/hashes/zkevm/src/sha256/vanilla/columns.rs index 7da47f35..9067ef7e 100644 --- a/hashes/zkevm/src/sha256/vanilla/columns.rs +++ b/hashes/zkevm/src/sha256/vanilla/columns.rs @@ -10,6 +10,8 @@ use super::param::*; /// ShaTable, copied from KeccakTable. However note that `NUM_BYTES_PER_WORD` is different for SHA256 #[derive(Clone, Debug)] pub struct ShaTable { + /// Selector always turned on except in blinding rows. + pub(super) q_enable: Column, /// is_enabled := q_squeeze && is_final /// q_squeeze is selector for dedicated row per input block for squeezing /// is_final is flag for whether this block actually is the last block of an input @@ -25,6 +27,7 @@ pub struct ShaTable { impl ShaTable { /// Construct a new ShaTable pub fn construct(meta: &mut ConstraintSystem) -> Self { + let q_enable = meta.fixed_column(); let is_enabled = meta.advice_column(); let word_value = meta.advice_column(); let length = meta.advice_column(); @@ -35,15 +38,13 @@ impl ShaTable { meta.enable_equality(length); meta.enable_equality(hash_lo); meta.enable_equality(hash_hi); - Self { is_enabled, output: Word::new([hash_lo, hash_hi]), word_value, length } + Self { q_enable, is_enabled, output: Word::new([hash_lo, hash_hi]), word_value, length } } } /// Columns for the Sha256 circuit #[derive(Clone, Debug)] pub struct Sha256CircuitConfig { - /// Selector always turned on except in blinding rows. - pub(super) q_enable: Column, pub(super) q_first: Column, pub(super) q_extend: Column, pub(super) q_start: Column, diff --git a/hashes/zkevm/src/sha256/vanilla/constraints.rs b/hashes/zkevm/src/sha256/vanilla/constraints.rs index 185827ab..979b757a 100644 --- a/hashes/zkevm/src/sha256/vanilla/constraints.rs +++ b/hashes/zkevm/src/sha256/vanilla/constraints.rs @@ -27,7 +27,6 @@ use super::param::*; impl Sha256CircuitConfig { pub fn new(meta: &mut ConstraintSystem) -> Self { - let q_enable = meta.fixed_column(); let q_first = meta.fixed_column(); let q_extend = meta.fixed_column(); let q_start = meta.fixed_column(); @@ -47,6 +46,7 @@ impl Sha256CircuitConfig { let hash_table = ShaTable::construct(meta); let is_enabled = hash_table.is_enabled; let length = hash_table.length; + let q_enable = hash_table.q_enable; // State bits let mut w_ext = vec![0u64.expr(); NUM_BITS_PER_WORD_W]; @@ -427,7 +427,6 @@ impl Sha256CircuitConfig { info!("degree: {}", meta.degree()); Sha256CircuitConfig { - q_enable, q_first, q_extend, q_start, diff --git a/hashes/zkevm/src/sha256/vanilla/witness.rs b/hashes/zkevm/src/sha256/vanilla/witness.rs index f2d31687..82bb7736 100644 --- a/hashes/zkevm/src/sha256/vanilla/witness.rs +++ b/hashes/zkevm/src/sha256/vanilla/witness.rs @@ -135,7 +135,7 @@ impl Sha256CircuitConfig { // Fixed values for (_name, column, value) in &[ - ("q_enable", self.q_enable, F::from(true)), + ("q_enable", self.hash_table.q_enable, F::from(true)), ("q_first", self.q_first, F::from(offset == 0)), ( "q_extend",