Struct galois_2p8::field::PrimitivePolynomialField
source · pub struct PrimitivePolynomialField { /* private fields */ }
Expand description
Implements field arithmetic compatible with primitive IrreducablePolynomial
s.
Recall that there are two strategies for optimizing field arithmetic in
GF(2^8)
: accessing direct multiplication and division tables, and
manipulating logarithms and exponentials. The latter method requires fewer
operations, but is only possible if the given IrreducablePolynomial
is
primitive.
This struct uses exponentiation and logarithm tables, and is only
compatible with primitive IrreducablePolynomial
s. For an implementation
compatible with all IrreducablePolynomial
s, see GeneralField
.
Note that this implementation may also use multiplication and division
tables for its vectorized operations. See the Field
documentation
for more details.
Implementations§
source§impl PrimitivePolynomialField
impl PrimitivePolynomialField
sourcepub fn new(poly: IrreducablePolynomial) -> Option<Self>
pub fn new(poly: IrreducablePolynomial) -> Option<Self>
Constructs a new PrimitivePolynomialField
with all tables initialized.
If the given poly
argument is not primitive, this function returns
None
; otherwise it returns Some(f: PrimitivePolynomialField)
.
In situations where the use of Option<PrimitivePolynomialField>
is
less ideal than incurring a panic, consider new_might_panic
.
sourcepub fn new_might_panic(poly: IrreducablePolynomial) -> Self
pub fn new_might_panic(poly: IrreducablePolynomial) -> Self
Constructs a new PrimitivePolynomialField
with all tables initialized.
If the given poly
argument is not primitive, this function panics.
The contents of the resulting error message are not defined.
In situations where incurring a panic is less ideal than the use of
Option<PrimitivePolynomialField>
, consider new
.
Trait Implementations§
source§impl Field for PrimitivePolynomialField
impl Field for PrimitivePolynomialField
source§fn polynomial(&self) -> IrreducablePolynomial
fn polynomial(&self) -> IrreducablePolynomial
source§fn div(&self, src: u8, scale: u8) -> u8
fn div(&self, src: u8, scale: u8) -> u8
src / scale
in this field. Read moresource§fn mult_two_pow(&self, scale: u8, x: u8) -> u8
fn mult_two_pow(&self, scale: u8, x: u8) -> u8
scale * 2^x
in this field.source§unsafe fn add_ptr_scaled_len(
&self,
dst: *mut u8,
src: *const u8,
scale: u8,
len: usize
)
unsafe fn add_ptr_scaled_len(
&self,
dst: *mut u8,
src: *const u8,
scale: u8,
len: usize
)
scale * src[0..len]
into dst[0..len]
in place.source§unsafe fn mult_ptr_len(&self, dst: *mut u8, scale: u8, len: usize)
unsafe fn mult_ptr_len(&self, dst: *mut u8, scale: u8, len: usize)
dst[0..len]
by scale
in place.source§unsafe fn add_ptr_len(&self, dst: *mut u8, src: *const u8, len: usize)
unsafe fn add_ptr_len(&self, dst: *mut u8, src: *const u8, len: usize)
src[0..len]
into dst[0..len]
.source§fn add_multiword(&self, dst: &mut [u8], src: &[u8])
fn add_multiword(&self, dst: &mut [u8], src: &[u8])
source§unsafe fn sub_ptr_len(&self, dst: *mut u8, src: *const u8, len: usize)
unsafe fn sub_ptr_len(&self, dst: *mut u8, src: *const u8, len: usize)
src[0..len]
from dst[0..len]
in place.source§unsafe fn sub_ptr_scaled_len(
&self,
dst: *mut u8,
src: *const u8,
scale: u8,
len: usize
)
unsafe fn sub_ptr_scaled_len(
&self,
dst: *mut u8,
src: *const u8,
scale: u8,
len: usize
)
scale * src[0..len]
from dst[0..len]
in place.source§fn sub_multiword(&self, dst: &mut [u8], src: &[u8])
fn sub_multiword(&self, dst: &mut [u8], src: &[u8])
source§fn mult_multiword(&self, dst: &mut [u8], scale: u8)
fn mult_multiword(&self, dst: &mut [u8], scale: u8)
dst
by scale
in place.