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: 5 additions & 2 deletions hashes/zkevm/src/sha256/vanilla/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ pub struct ShaTable {
pub io: Column<Advice>,
/// Length in bytes of the input processed so far. Does not include padding.
pub length: Column<Advice>,
/// Advice to represent if this input block is the last one for a variable length input.
/// The advice value should only be used in the last row of each [SHA256_NUM_ROWS] block.
pub(super) is_final: Column<Advice>,
}

impl ShaTable {
Expand All @@ -36,7 +39,8 @@ impl ShaTable {
meta.enable_equality(length);
meta.enable_equality(hash_lo);
meta.enable_equality(hash_hi);
Self { q_enable, io, length }
let is_final = meta.advice_column();
Self { q_enable, io, length, is_final }
}
}

Expand All @@ -59,7 +63,6 @@ pub struct Sha256CircuitConfig<F> {
pub(super) word_w: [Column<Advice>; NUM_BITS_PER_WORD_W],
pub(super) word_a: [Column<Advice>; NUM_BITS_PER_WORD_EXT],
pub(super) word_e: [Column<Advice>; NUM_BITS_PER_WORD_EXT],
pub(super) is_final: Column<Advice>,
pub(super) is_paddings: [Column<Advice>; ABSORB_WIDTH_PER_ROW_BYTES],
pub(super) round_cst: Column<Fixed>,
pub(super) h_a: 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 @@ -38,14 +38,14 @@ impl<F: Field> Sha256CircuitConfig<F> {
let word_w = array_init::array_init(|_| meta.advice_column());
let word_a = array_init::array_init(|_| meta.advice_column());
let word_e = array_init::array_init(|_| meta.advice_column());
let is_final = meta.advice_column();
let is_paddings = array_init::array_init(|_| meta.advice_column());
let round_cst = meta.fixed_column();
let h_a = meta.fixed_column();
let h_e = meta.fixed_column();
let hash_table = ShaTable::construct(meta);
let length = hash_table.length;
let q_enable = hash_table.q_enable;
let is_final = hash_table.is_final;

// State bits
let mut w_ext = vec![0u64.expr(); NUM_BITS_PER_WORD_W];
Expand Down Expand Up @@ -508,7 +508,6 @@ impl<F: Field> Sha256CircuitConfig<F> {
word_w,
word_a,
word_e,
is_final,
is_paddings,
round_cst,
h_a,
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 @@ -204,7 +204,7 @@ impl<F: Field> Sha256CircuitConfig<F> {
F::ZERO
};
let [is_final, io, length] = [
(self.is_final, F::from(row.is_final)),
(self.hash_table.is_final, F::from(row.is_final)),
(self.hash_table.io, io_value),
(self.hash_table.length, F::from(row.length as u64)),
]
Expand Down