Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 2369228

Browse files
authored
fix padding pos issue in sha256 circuit (#1096)
1 parent e19d40d commit 2369228

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

zkevm-circuits/src/sha256_circuit/circuit.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ impl CircuitConfig {
466466
) -> Result<BlockInheritments, Error> {
467467
// if no padding or the padding is in padding size pos, this block is not final
468468
let is_final = if let Some(pos) = padding_pos {
469-
pos <= 24
469+
pos < 56
470470
} else {
471471
false
472472
};
@@ -1199,13 +1199,21 @@ mod tests {
11991199
}
12001200

12011201
#[test]
1202-
fn sha256_padding_continue() {
1203-
let circuit = MyCircuit(vec![(vec![b'a'; 62], None)]);
1204-
let prover = match MockProver::<Fr>::run(17, &circuit, vec![]) {
1205-
Ok(prover) => prover,
1206-
Err(e) => panic!("{e:#?}"),
1207-
};
1208-
assert_eq!(prover.verify(), Ok(()));
1202+
fn sha256_padding() {
1203+
for sz in [32usize, 37, 55, 56, 58, 62, 64] {
1204+
let circuit = MyCircuit(vec![
1205+
(vec![0xff; sz], None),
1206+
(vec![], Some(DIGEST_NIL)),
1207+
(vec![], Some(DIGEST_NIL)),
1208+
(vec![], Some(DIGEST_NIL)),
1209+
(vec![], Some(DIGEST_NIL)),
1210+
]);
1211+
let prover = match MockProver::<Fr>::run(17, &circuit, vec![]) {
1212+
Ok(prover) => prover,
1213+
Err(e) => panic!("{e:#?}"),
1214+
};
1215+
assert_eq!(prover.verify(), Ok(()));
1216+
}
12091217
}
12101218

12111219
#[test]

0 commit comments

Comments
 (0)