From ac8d163fbbe2a9d9057d484f9b8d5302c1f43e77 Mon Sep 17 00:00:00 2001 From: Robin Salen Date: Fri, 4 Aug 2023 15:43:36 -0400 Subject: [PATCH] Prevent overflow --- evm/src/witness/operation.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/evm/src/witness/operation.rs b/evm/src/witness/operation.rs index 16999a33bb..465e63b4a5 100644 --- a/evm/src/witness/operation.rs +++ b/evm/src/witness/operation.rs @@ -492,7 +492,11 @@ fn append_shift( } // Convert the shift, and log the corresponding arithmetic operation. - let input0 = U256::from(2).pow(input0); + let input0 = if input0 > U256::from(255u64) { + U256::zero() + } else { + U256::from(2).pow(input0) + }; let operator = if row.op.shl.is_one() { BinaryOperator::Mul } else {