Trait PackedFe32
pub trait PackedFe32:
Copy
+ PartialEq
+ Eq
+ BitXor<Output = Self> {
const ONE: Self;
const WIDTH: usize = _;
// Required methods
fn unpack(&self, n: usize) -> u8;
fn mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8;
}
Expand description
Trait describing an integer type which can be used as a “packed” sequence of Fe32s.
This is implemented for u32, u64 and u128, as a way to treat these primitive types as packed coefficients of polynomials over GF32 (up to some maximal degree, of course).
This is useful because then multiplication by x reduces to simply left-shifting by 5, and addition of entire polynomials can be done by xor.
Required Associated Constants§
const ONE: Self
const ONE: Self
The one constant, for which stdlib provides no existing trait.
Provided Associated Constants§
Required Methods§
fn mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8
fn mul_by_x_then_add(&mut self, degree: usize, add: u8) -> u8
Multiply the polynomial by x, drop its highest coefficient (and return it), and add a new field element to the now-0 constant coefficient.
Takes the degree of the polynomial as an input; for checksum applications
this should basically always be Checksum::CHECKSUM_WIDTH
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.