Skip to main content

Fp

Struct Fp 

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

An element of GF(p) for a prime p < 2^64 chosen at runtime.

Fp::zero() and Fp::one() carry no modulus (p = 0) and adopt the modulus of whatever they meet, so generic code that starts from F::zero() or F::one() works unchanged.

Implementations§

Source§

impl Fp

Source

pub const fn new(v: u64, p: u64) -> Self

v modulo p, or an unbound constant when p = 0.

Source

pub fn from_i64(x: i64, p: u64) -> Self

Source

pub fn from_rational(q: &BigRational, p: u64) -> Option<Self>

q modulo p, or None when p divides its denominator.

Source

pub const fn value(self) -> u64

Source

pub const fn modulus(self) -> u64

The prime, or 0 for a constant not yet bound to one.

Source

pub const fn try_inverse(self) -> Option<Self>

The inverse, or None for a non-unit: zero, a residue sharing a factor with a composite modulus, or an unbound constant other than 1 and -1.

Source

pub fn bind(self, p: u64) -> Self

Trait Implementations§

Source§

impl Add for Fp

Source§

type Output = Fp

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Clone for Fp

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Fp

Source§

impl Debug for Fp

Source§

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

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

impl Display for Fp

Source§

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

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

impl Div for Fp

Source§

type Output = Fp

The resulting type after applying the / operator.
Source§

fn div(self, o: Self) -> Self

Performs the / operation. Read more
Source§

impl Eq for Fp

Source§

impl From<i32> for Fp

Source§

fn from(x: i32) -> Self

An unbound constant.

Source§

impl Hash for Fp

Hashes the symmetric residue, so equal elements of one field hash alike and an unbound constant hashes like its binding whenever it is below p / 2 in magnitude.

Source§

fn hash<H: Hasher>(&self, h: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Modular for Fp

Source§

fn modulus(&self) -> u64

The prime, or 0 for a constant not yet bound to one.
Source§

fn residue(&self) -> u64

The stored residue; a signed integer in two’s complement while unbound.
Source§

fn from_residue(v: u64, p: u64) -> Self

Source§

fn residue_mod(&self, p: u64) -> u64

The residue in [0, p), binding an unbound constant to p.
Source§

impl Mul for Fp

Source§

type Output = Fp

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Neg for Fp

Source§

type Output = Fp

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl One for Fp

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl PartialEq for Fp

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Sub for Fp

Source§

type Output = Fp

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Zero for Fp

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.

Auto Trait Implementations§

§

impl Freeze for Fp

§

impl RefUnwindSafe for Fp

§

impl Send for Fp

§

impl Sync for Fp

§

impl Unpin for Fp

§

impl UnsafeUnpin for Fp

§

impl UnwindSafe for Fp

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<F> Field for F
where F: Debug + Zero + One + Neg<Output = F> + Sub<Output = F> + Clone + Div<Output = F> + PartialEq,

Source§

fn inverse(&self) -> Option<Self>

The multiplicative inverse, or None for zero.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.