sp1-core 1.1.0

SP1 is a performant, 100% open-source, contributor-friendly zkVM.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::BYTE_SIZE;

/// Calculate the number of bytes to shift by.
///
/// Note that we take the least significant 5 bits per the RISC-V spec.
pub const fn nb_bytes_to_shift(shift_amount: u32) -> usize {
    let n = (shift_amount % 32) as usize;
    n / BYTE_SIZE
}

/// Calculate the number of bits shift by.
///
/// Note that we take the least significant 5 bits per the RISC-V spec.
pub const fn nb_bits_to_shift(shift_amount: u32) -> usize {
    let n = (shift_amount % 32) as usize;
    n % BYTE_SIZE
}