diff --git a/tfhe/src/integer/server_key/radix_parallel/shift.rs b/tfhe/src/integer/server_key/radix_parallel/shift.rs index 6e183b212b..249f9fa55a 100644 --- a/tfhe/src/integer/server_key/radix_parallel/shift.rs +++ b/tfhe/src/integer/server_key/radix_parallel/shift.rs @@ -391,12 +391,13 @@ impl ServerKey { } BarrelShifterOperation::LeftRotate => { let shifted = (input << shift_within_block) % self.message_modulus().0; - let wrapped = input >> (shift_within_block); + let wrapped = input >> (message_bits_per_block - shift_within_block); shifted | wrapped } BarrelShifterOperation::RightRotate => { let shifted = input >> shift_within_block; - let wrapped = (input << shift_within_block) % self.message_modulus().0; + let wrapped = (input << (message_bits_per_block - shift_within_block)) + % self.message_modulus().0; wrapped | shifted } BarrelShifterOperation::RightShift => {