Skip to main content

F2Ext

Struct F2Ext 

Source
pub struct F2Ext<const LIMBS: usize, P>
where P: BinaryIrreducible<LIMBS>,
{ pub value: Uint<LIMBS>, /* private fields */ }
Expand description

An extension of $\mathbb{F}_2$ given by a polynomial P.

Fields§

§value: Uint<LIMBS>

The value of an element of $\mathbb{F}_{2^M}$

Implementations§

Source§

impl<const LIMBS: usize, P> F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source

pub fn new(x: Uint<LIMBS>) -> Self

Make an element from the limbs

Source

pub fn from_u64(x: u64) -> Self

Make an element from a u64

Source

pub fn from_uint(x: Uint<LIMBS>) -> Self

Make an element from a Uint<LIMBS>

Source

pub fn as_uint(&self) -> Uint<LIMBS>

Get a Unit<LIMBS> from an element

Source

pub fn degree() -> usize

Get the degree of the field extension

Trait Implementations§

Source§

impl<const LIMBS: usize, P> Add for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

type Output = F2Ext<LIMBS, P>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<const LIMBS: usize, P> Clone for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const LIMBS: usize, P> ConditionallySelectable for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
Source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
Source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
Source§

impl<const LIMBS: usize, P> ConstantTimeEq for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl<const LIMBS: usize, P> Debug for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const LIMBS: usize, P> Default for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const LIMBS: usize, P> Display for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const LIMBS: usize, P> FieldFromRepr for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

type Repr = Uint<LIMBS>

The representation type accepted by this field.
Source§

fn from_repr(x: Self::Repr) -> Self

Constructs a field element from the given representation.
Source§

impl<const LIMBS: usize, P> FieldOps for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

fn zero() -> Self

Create the constant zero
Source§

fn one() -> Self

Create the constant one
Source§

fn from_u64(x: u64) -> Self

Convert u64 to the field.
Source§

fn is_zero(&self) -> Choice

Check if element is zero
Source§

fn is_one(&self) -> Choice

Check if element is one
Source§

fn negate(&self) -> Self

Negate self to -self
Source§

fn add(&self, rhs: &Self) -> Self

Add rhs to self
Source§

fn sub(&self, rhs: &Self) -> Self

Sub rhs from self
Source§

fn mul(&self, rhs: &Self) -> Self

Multipliy self by rhs
Source§

fn square(&self) -> Self

Square self
Source§

fn double(&self) -> Self

Double self
Source§

fn invert(&self) -> CtOption<Self>

Invert self
Source§

fn frobenius(&self) -> Self

Compute self^p the frobenius acting on self
Source§

fn trace(&self) -> Self

compute the trace of self down to $\mathbb{F}_p$ (as an element of type Self)
Source§

fn norm(&self) -> Self

compute the norm of self down to $\mathbb{F}_p$ (as an element of type Self)
Source§

fn sqrt(&self) -> CtOption<Self>

Returns a squareroot if it exists Read more
Source§

fn legendre(&self) -> i8

Computes the “Legendre symbol” i.e., if 0,1,-1 depending if self is 0, a square or a nonsquare.
Source§

fn characteristic() -> Vec<u64>

Returns the characteristic of the field.
Source§

fn degree() -> u32

Returns the extension degree of the field.
Source§

fn div(&self, rhs: &Self) -> CtOption<Self>

Divide self by rhs
Source§

fn pow_vartime(&self, exp: &[u64]) -> Self

self^exp using square-and multiply (litte-endian bit order) Read more
Source§

fn pow(&self, exp: &[u64]) -> Self

self^pow in constant time using a Montgomery ladder Read more
Source§

fn frobenius_pow(&self, k: u32) -> Self

Compute self^{p^k} a power of the frobenius
Source§

fn inverse_and_sqrt(&self) -> (CtOption<Self>, CtOption<Self>)

Computes the inverse and square root of self Read more
Source§

fn inv_sqrt(&self) -> CtOption<Self>

Computes the square root the inverse of self Read more
Source§

fn invertme_sqrtother(&self, rhs: &Self) -> (CtOption<Self>, CtOption<Self>)

Computes the inverse of self and square root of rhs Read more
Source§

fn sqrt_ratio(&self, rhs: &Self) -> CtOption<Self>

Computes the squareroot of a ratio self/rhs Read more
Source§

impl<const LIMBS: usize, P> FieldRandom for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

fn random(rng: &mut (impl CryptoRng + Rng)) -> Self

Sample a uniformly random element of F_{2^m} using a CSPRNG.

Fills a Uint<LIMBS> with random bytes, masks to m bits, and wraps via F2Ext::new (which reduces mod the irreducible).

Source§

impl<const LIMBS: usize, P> Mul for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

type Output = F2Ext<LIMBS, P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl<const LIMBS: usize, P> Neg for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

type Output = F2Ext<LIMBS, P>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<const LIMBS: usize, P> PartialEq for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const LIMBS: usize, P> Sub for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

type Output = F2Ext<LIMBS, P>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl<const LIMBS: usize, P> Copy for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Source§

impl<const LIMBS: usize, P> Eq for F2Ext<LIMBS, P>
where P: BinaryIrreducible<LIMBS>,

Auto Trait Implementations§

§

impl<const LIMBS: usize, P> Freeze for F2Ext<LIMBS, P>

§

impl<const LIMBS: usize, P> RefUnwindSafe for F2Ext<LIMBS, P>
where P: RefUnwindSafe,

§

impl<const LIMBS: usize, P> Send for F2Ext<LIMBS, P>
where P: Send,

§

impl<const LIMBS: usize, P> Sync for F2Ext<LIMBS, P>
where P: Sync,

§

impl<const LIMBS: usize, P> Unpin for F2Ext<LIMBS, P>
where P: Unpin,

§

impl<const LIMBS: usize, P> UnsafeUnpin for F2Ext<LIMBS, P>

§

impl<const LIMBS: usize, P> UnwindSafe for F2Ext<LIMBS, P>
where P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.