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

Fix zellic finding 14 #580

Merged
merged 2 commits into from
Jul 6, 2023
Merged
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
22 changes: 21 additions & 1 deletion zkevm-circuits/src/rlp_circuit_fsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ impl<F: Field> RlpCircuitConfig<F> {
},
);

// if (tx_id' == tx_id and format' != format) or (tx_id' != tx_id and tx_id' != 0)
// These two cases are not the very last non-padding RLP instance.
// 1. (tx_id' == tx_id and format' != format)
// 2. (tx_id' != tx_id and tx_id' != 0)
cb.condition(
sum::expr([
// case 1
Expand Down Expand Up @@ -572,6 +574,23 @@ impl<F: Field> RlpCircuitConfig<F> {
},
);

// For the very last non-padding RLP instance, we have
// tx_id' != tx_id && tx_id' == 0
cb.condition(
and::expr([
is_padding_in_dt.expr(Rotation::next())(meta),
not::expr(tx_id_check_in_dt.is_equal_expression.expr()),
]),
|cb| {
// byte_rev_idx == 1
cb.require_equal(
"byte_rev_idx is 1 at the last index",
meta.query_advice(data_table.byte_rev_idx, Rotation::cur()),
1.expr(),
);
},
);

cb.gate(meta.query_fixed(q_enabled, Rotation::cur()))
});

Expand Down Expand Up @@ -1224,6 +1243,7 @@ impl<F: Field> RlpCircuitConfig<F> {
]);
cb.condition(cond.expr(), |cb| {
// assertions.
do_not_emit!(meta, cb);
constrain_eq!(meta, cb, is_tag_begin, true);

// state transitions
Expand Down