#[repr(align(16))]pub struct FieldElement([u8; 16]);Expand description
An element in POLYVAL’s field.
This type represents an element of the binary field GF(2^128) modulo the irreducible polynomial
x^128 + x^127 + x^126 + x^121 + 1 as described in RFC8452 §3.
Arithmetic in POLYVAL’s field has the following properties:
- All arithmetic operations are performed modulo the polynomial above.
- Addition is equivalent to the XOR operation applied to the two field elements
- Multiplication is carryless
Tuple Fields§
§0: [u8; 16]Implementations§
Source§impl FieldElement
impl FieldElement
Source§impl FieldElement
impl FieldElement
Sourcepub(crate) fn karatsuba_mul(self, rhs: Self) -> Product
pub(crate) fn karatsuba_mul(self, rhs: Self) -> Product
Compute the unreduced 256-bit carryless product of two 128-bit field elements.
Uses a Karatsuba decomposition in which the 128x128 multiplication is reduced to three 64x64 multiplications together with a bit-reversal trick to efficiently recover the high half.
Source§impl FieldElement
impl FieldElement
Sourcepub fn mulx(self) -> Self
pub fn mulx(self) -> Self
The mulX_POLYVAL() function as defined in RFC 8452 Appendix A.
Performs a doubling (a.k.a. “multiply by x”) over GF(2^128). This is useful for implementing GHASH in terms of POLYVAL.
Source§impl FieldElement
impl FieldElement
Trait Implementations§
Source§impl Add for FieldElement
impl Add for FieldElement
Source§impl Clone for FieldElement
impl Clone for FieldElement
Source§fn clone(&self) -> FieldElement
fn clone(&self) -> FieldElement
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FieldElement
impl Debug for FieldElement
Source§impl Default for FieldElement
impl Default for FieldElement
Source§fn default() -> FieldElement
fn default() -> FieldElement
Returns the “default value” for a type. Read more
Source§impl From<&Array<u8, <Polyval as BlockSizeUser>::BlockSize>> for FieldElement
impl From<&Array<u8, <Polyval as BlockSizeUser>::BlockSize>> for FieldElement
Source§impl From<&FieldElement> for Block
impl From<&FieldElement> for Block
Source§fn from(fe: &FieldElement) -> Self
fn from(fe: &FieldElement) -> Self
Converts to this type from the input type.
Source§impl From<Array<u8, <Polyval as BlockSizeUser>::BlockSize>> for FieldElement
impl From<Array<u8, <Polyval as BlockSizeUser>::BlockSize>> for FieldElement
Source§impl From<FieldElement> for Block
impl From<FieldElement> for Block
Source§fn from(fe: FieldElement) -> Self
fn from(fe: FieldElement) -> Self
Converts to this type from the input type.
Source§impl From<FieldElement> for u128
impl From<FieldElement> for u128
Source§fn from(fe: FieldElement) -> Self
fn from(fe: FieldElement) -> Self
Converts to this type from the input type.
Source§impl From<u128> for FieldElement
impl From<u128> for FieldElement
Source§impl Mul for FieldElement
impl Mul for FieldElement
Source§impl MulAssign for FieldElement
impl MulAssign for FieldElement
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreimpl Copy for FieldElement
Auto Trait Implementations§
impl Freeze for FieldElement
impl RefUnwindSafe for FieldElement
impl Send for FieldElement
impl Sync for FieldElement
impl Unpin for FieldElement
impl UnsafeUnpin for FieldElement
impl UnwindSafe for FieldElement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more