Trait crypto_bigint::BitOps

source ·
pub trait BitOps {
Show 15 methods // Required methods fn bits_precision(&self) -> u32; fn bytes_precision(&self) -> usize; fn bit(&self, index: u32) -> Choice; fn set_bit(&mut self, index: u32, bit_value: Choice); fn trailing_zeros(&self) -> u32; fn trailing_ones(&self) -> u32; fn leading_zeros(&self) -> u32; fn bit_vartime(&self, index: u32) -> bool; fn set_bit_vartime(&mut self, index: u32, bit_value: bool); fn trailing_zeros_vartime(&self) -> u32; fn trailing_ones_vartime(&self) -> u32; // Provided methods fn log2_bits(&self) -> u32 { ... } fn bits(&self) -> u32 { ... } fn bits_vartime(&self) -> u32 { ... } fn leading_zeros_vartime(&self) -> u32 { ... }
}
Expand description

Bit counting and bit operations.

Required Methods§

source

fn bits_precision(&self) -> u32

Precision of this integer in bits.

source

fn bytes_precision(&self) -> usize

Precision of this integer in bytes.

source

fn bit(&self, index: u32) -> Choice

Calculate the number of bits needed to represent this number.

source

fn set_bit(&mut self, index: u32, bit_value: Choice)

Sets the bit at index to 0 or 1 depending on the value of bit_value.

source

fn trailing_zeros(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number.

source

fn trailing_ones(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number.

source

fn leading_zeros(&self) -> u32

Calculate the number of leading zeros in the binary representation of this number.

source

fn bit_vartime(&self, index: u32) -> bool

Returns true if the bit at position index is set, false otherwise.

Remarks

This operation is variable time with respect to index only.

source

fn set_bit_vartime(&mut self, index: u32, bit_value: bool)

Sets the bit at index to 0 or 1 depending on the value of bit_value, variable time in self.

source

fn trailing_zeros_vartime(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number in variable-time with respect to self.

source

fn trailing_ones_vartime(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number, variable time in self.

Provided Methods§

source

fn log2_bits(&self) -> u32

floor(log2(self.bits_precision())).

source

fn bits(&self) -> u32

Calculate the number of bits required to represent a given number.

source

fn bits_vartime(&self) -> u32

Calculate the number of bits required to represent a given number in variable-time with respect to self.

source

fn leading_zeros_vartime(&self) -> u32

Calculate the number of leading zeros in the binary representation of this number.

Implementors§

source§

impl BitOps for BoxedUint

Available on crate feature alloc only.
source§

impl<const LIMBS: usize> BitOps for Uint<LIMBS>