Skip to main content

F2Element

Struct F2Element 

Source
pub struct F2Element { /* private fields */ }
Expand description

Element of the finite field $\mathbb{F}_2$

Implementations§

Source§

impl F2Element

Source

pub const ZERO: Self

The constant zero

Source

pub const ONE: Self

The constant one

Source

pub fn from_u64(x: u64) -> Self

Create a new element of $\mathbb{F}_2$ from a u64

Source

pub fn value(&self) -> Uint<1>

Get the Uint<1> from an element of $\mathbb{F}_2$

Source

pub fn as_u8(&self) -> u8

Get the u8 from an element of $\mathbb{F}_2$

Trait Implementations§

Source§

impl Add for F2Element

Source§

type Output = F2Element

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Clone for F2Element

Source§

fn clone(&self) -> F2Element

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 ConditionallySelectable for F2Element

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 ConstantTimeEq for F2Element

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 Debug for F2Element

Source§

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

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

impl Default for F2Element

Source§

fn default() -> Self

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

impl Display for F2Element

Source§

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

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

impl FieldFromRepr for F2Element

Source§

type Repr = Uint<1>

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 FieldOps for F2Element

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 norm(&self) -> Self

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

fn trace(&self) -> Self

compute the trace 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 FieldRandom for F2Element

Source§

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

Sample a uniformly random element using a cryptographic RNG.
Source§

impl Mul for F2Element

Source§

type Output = F2Element

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Neg for F2Element

Source§

type Output = F2Element

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for F2Element

Source§

fn eq(&self, other: &F2Element) -> 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 Sub for F2Element

Source§

type Output = F2Element

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Copy for F2Element

Source§

impl Eq for F2Element

Source§

impl StructuralPartialEq for F2Element

Auto Trait Implementations§

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.