Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions hashes/zkevm/src/sha256/vanilla/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Fixed>,
/// 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
Expand All @@ -25,6 +27,7 @@ pub struct ShaTable {
impl ShaTable {
/// Construct a new ShaTable
pub fn construct<F: Field>(meta: &mut ConstraintSystem<F>) -> Self {
let q_enable = meta.fixed_column();
let is_enabled = meta.advice_column();
let word_value = meta.advice_column();
let length = meta.advice_column();
Expand All @@ -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<F> {
/// Selector always turned on except in blinding rows.
pub(super) q_enable: Column<Fixed>,
pub(super) q_first: Column<Fixed>,
pub(super) q_extend: Column<Fixed>,
pub(super) q_start: Column<Fixed>,
Expand Down
3 changes: 1 addition & 2 deletions hashes/zkevm/src/sha256/vanilla/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use super::param::*;

impl<F: Field> Sha256CircuitConfig<F> {
pub fn new(meta: &mut ConstraintSystem<F>) -> 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();
Expand All @@ -47,6 +46,7 @@ impl<F: Field> Sha256CircuitConfig<F> {
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];
Expand Down Expand Up @@ -427,7 +427,6 @@ impl<F: Field> Sha256CircuitConfig<F> {
info!("degree: {}", meta.degree());

Sha256CircuitConfig {
q_enable,
q_first,
q_extend,
q_start,
Expand Down
2 changes: 1 addition & 1 deletion hashes/zkevm/src/sha256/vanilla/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl<F: Field> Sha256CircuitConfig<F> {

// 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",
Expand Down