mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 14:23:07 +00:00
Prevent shift ops from panicking (#1073)
This commit is contained in:
parent
55b29cacf8
commit
2cf31f5f2d
@ -468,7 +468,12 @@ pub(crate) fn generate_shl<F: Field>(
|
||||
) -> Result<(), ProgramError> {
|
||||
let [(input0, log_in0), (input1, log_in1)] =
|
||||
stack_pop_with_log_and_fill::<2, _>(state, &mut row)?;
|
||||
let result = input1 << input0;
|
||||
|
||||
let result = if input0 > U256::from(255u64) {
|
||||
U256::zero()
|
||||
} else {
|
||||
input1 << input0
|
||||
};
|
||||
append_shift(state, row, input0, log_in0, log_in1, result)
|
||||
}
|
||||
|
||||
@ -478,7 +483,12 @@ pub(crate) fn generate_shr<F: Field>(
|
||||
) -> Result<(), ProgramError> {
|
||||
let [(input0, log_in0), (input1, log_in1)] =
|
||||
stack_pop_with_log_and_fill::<2, _>(state, &mut row)?;
|
||||
let result = input1 >> input0;
|
||||
|
||||
let result = if input0 > U256::from(255u64) {
|
||||
U256::zero()
|
||||
} else {
|
||||
input1 >> input0
|
||||
};
|
||||
append_shift(state, row, input0, log_in0, log_in1, result)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user