Struct galois_2p8::field::GeneralField
source · pub struct GeneralField { /* private fields */ }
Expand description
Implements field arithmetic compatible with all 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 direct multiplication and division tables for its
operations, and is compatible with all IrreducablePolynomial
s,
including primitive ones. Operations are expected to be less performant
than those implemented by PrimitivePolynomialField
, with the exception
of vector operations, which may be accelerated in both using multiplication
and division tables. See the Field
documentation for more details
regarding vector operations.
Implementations§
source§impl GeneralField
impl GeneralField
sourcepub fn new(poly: IrreducablePolynomial) -> Self
pub fn new(poly: IrreducablePolynomial) -> Self
Constructs a new GeneralField
with all tables initialized.
Trait Implementations§
source§impl Field for GeneralField
impl Field for GeneralField
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.