Num

Struct Num 

Source
#[repr(transparent)]
pub struct Num<Fp: PrimeField>(pub Fp);

Tuple Fields§

§0: Fp

Implementations§

Source§

impl<Fp: PrimeField> Num<Fp>

Source

pub const ZERO: Self

Source

pub const ONE: Self

Source

pub const MODULUS: NumRepr<Fp::Inner>

Source

pub const MODULUS_BITS: u32 = Fp::MODULUS_BITS

Source

pub fn is_even(&self) -> bool

Source

pub fn is_odd(&self) -> bool

Source

pub fn double(self) -> Self

Source

pub fn square(self) -> Self

Source

pub fn new(n: Fp) -> Self

Source

pub fn checked_inv(self) -> Option<Self>

Source

pub fn is_zero(self) -> bool

Source

pub fn from_uint(v: NumRepr<Fp::Inner>) -> Option<Self>

Source

pub fn from_uint_reduced(v: NumRepr<Fp::Inner>) -> Self

Source

pub fn from_mont_uint(v: NumRepr<Fp::Inner>) -> Option<Self>

Source

pub fn from_uint_unchecked(v: NumRepr<Fp::Inner>) -> Self

Source

pub fn from_mont_uint_unchecked(v: NumRepr<Fp::Inner>) -> Self

Source

pub fn sqrt(&self) -> Option<Self>

Source

pub fn even_sqrt(&self) -> Option<Self>

Source

pub fn to_uint(&self) -> NumRepr<Fp::Inner>

Source

pub fn to_mont_uint(&self) -> NumRepr<Fp::Inner>

Source

pub fn as_mont_uint(&self) -> &NumRepr<Fp::Inner>

Source

pub fn as_mont_uint_mut(&mut self) -> &mut NumRepr<Fp::Inner>

Source

pub fn to_other<Fq: PrimeField>(&self) -> Option<Num<Fq>>

Source

pub fn to_other_reduced<Fq: PrimeField>(&self) -> Num<Fq>

Trait Implementations§

Source§

impl<'macro_lifetime_a, 'macro_lifetime_b, U: PrimeField> Add<&'macro_lifetime_a Num<U>> for &'macro_lifetime_b Num<U>

Source§

type Output = Num<U>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'macro_lifetime_a Num<U>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> Add<&'macro_lifetime Num<U>> for Num<U>

Source§

type Output = Num<U>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'macro_lifetime Num<U>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> Add<Num<U>> for &'macro_lifetime Num<U>

Source§

type Output = Num<U>

The resulting type after applying the + operator.
Source§

fn add(self, other: Num<U>) -> Self::Output

Performs the + operation. Read more
Source§

impl<U: PrimeField> Add for Num<U>

Source§

type Output = Num<U>

The resulting type after applying the + operator.
Source§

fn add(self, other: Num<U>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> AddAssign<&'macro_lifetime Num<U>> for Num<U>

Source§

fn add_assign(&mut self, other: &'macro_lifetime Num<U>)

Performs the += operation. Read more
Source§

impl<U: PrimeField> AddAssign for Num<U>

Source§

fn add_assign(&mut self, other: Num<U>)

Performs the += operation. Read more
Source§

impl<Fp: PrimeField> BitIterBE for Num<Fp>

Source§

impl<Fp: PrimeField> BitIterLE for Num<Fp>

Source§

impl<Fp: PrimeField> BorshDeserialize for Num<Fp>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

impl<Fp: PrimeField> BorshSerialize for Num<Fp>

Source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
Source§

impl<Fp: Clone + PrimeField> Clone for Num<Fp>

Source§

fn clone(&self) -> Num<Fp>

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<Fp: PrimeField> Debug for Num<Fp>

Source§

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

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

impl<'de, Fp: PrimeField> Deserialize<'de> for Num<Fp>

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<Fp: PrimeField> Display for Num<Fp>

Source§

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

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

impl<'macro_lifetime_a, 'macro_lifetime_b, U: PrimeField> Div<&'macro_lifetime_a Num<U>> for &'macro_lifetime_b Num<U>

Source§

type Output = Num<U>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'macro_lifetime_a Num<U>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> Div<&'macro_lifetime Num<U>> for Num<U>

Source§

type Output = Num<U>

The resulting type after applying the / operator.
Source§

fn div(self, other: &'macro_lifetime Num<U>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> Div<Num<U>> for &'macro_lifetime Num<U>

Source§

type Output = Num<U>

The resulting type after applying the / operator.
Source§

fn div(self, other: Num<U>) -> Self::Output

Performs the / operation. Read more
Source§

impl<U: PrimeField> Div for Num<U>

Source§

type Output = Num<U>

The resulting type after applying the / operator.
Source§

fn div(self, other: Num<U>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> DivAssign<&'macro_lifetime Num<U>> for Num<U>

Source§

fn div_assign(&mut self, other: &'macro_lifetime Num<U>)

Performs the /= operation. Read more
Source§

impl<U: PrimeField> DivAssign for Num<U>

Source§

fn div_assign(&mut self, other: Num<U>)

Performs the /= operation. Read more
Source§

impl<Fp: PrimeField> From<&'static str> for Num<Fp>

Source§

fn from(s: &'static str) -> Self

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<bool> for Num<Fp>

Source§

fn from(n: bool) -> Self

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<i128> for Num<Fp>

Source§

fn from(value: i128) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<i16> for Num<Fp>

Source§

fn from(value: i16) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<i32> for Num<Fp>

Source§

fn from(value: i32) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<i64> for Num<Fp>

Source§

fn from(value: i64) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<i8> for Num<Fp>

Source§

fn from(value: i8) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<u128> for Num<Fp>

Source§

fn from(value: u128) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<u16> for Num<Fp>

Source§

fn from(value: u16) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<u32> for Num<Fp>

Source§

fn from(value: u32) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<u64> for Num<Fp>

Source§

fn from(value: u64) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> From<u8> for Num<Fp>

Source§

fn from(value: u8) -> Num<Fp>

Converts to this type from the input type.
Source§

impl<Fp: PrimeField> FromStr for Num<Fp>

Source§

type Err = <Fp as FromStr>::Err

The associated error which can be returned from parsing.
Source§

fn from_str(value: &str) -> Result<Num<Fp>, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<'macro_lifetime_a, 'macro_lifetime_b, U: PrimeField> Mul<&'macro_lifetime_a Num<U>> for &'macro_lifetime_b Num<U>

Source§

type Output = Num<U>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'macro_lifetime_a Num<U>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> Mul<&'macro_lifetime Num<U>> for Num<U>

Source§

type Output = Num<U>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'macro_lifetime Num<U>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> Mul<Num<U>> for &'macro_lifetime Num<U>

Source§

type Output = Num<U>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Num<U>) -> Self::Output

Performs the * operation. Read more
Source§

impl<U: PrimeField> Mul for Num<U>

Source§

type Output = Num<U>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Num<U>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> MulAssign<&'macro_lifetime Num<U>> for Num<U>

Source§

fn mul_assign(&mut self, other: &'macro_lifetime Num<U>)

Performs the *= operation. Read more
Source§

impl<U: PrimeField> MulAssign for Num<U>

Source§

fn mul_assign(&mut self, other: Num<U>)

Performs the *= operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> Neg for &'macro_lifetime Num<U>

Source§

type Output = Num<U>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Num<U>

Performs the unary - operation. Read more
Source§

impl<U: PrimeField> Neg for Num<U>

Source§

type Output = Num<U>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Num<U>

Performs the unary - operation. Read more
Source§

impl<Fp: PrimeField> PartialEq for Num<Fp>

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<Fp: PrimeField> RefCast for Num<Fp>

Source§

type From = Fp

Source§

fn ref_cast(_from: &Self::From) -> &Self

Source§

fn ref_cast_mut(_from: &mut Self::From) -> &mut Self

Source§

impl<Fp: PrimeField> SeedBoxGen<Num<Fp>> for SeedboxChaCha20

Source§

fn gen(&mut self) -> Num<Fp>

Source§

impl<Fp: PrimeField> Serialize for Num<Fp>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<'macro_lifetime_a, 'macro_lifetime_b, U: PrimeField> Sub<&'macro_lifetime_a Num<U>> for &'macro_lifetime_b Num<U>

Source§

type Output = Num<U>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'macro_lifetime_a Num<U>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> Sub<&'macro_lifetime Num<U>> for Num<U>

Source§

type Output = Num<U>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'macro_lifetime Num<U>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> Sub<Num<U>> for &'macro_lifetime Num<U>

Source§

type Output = Num<U>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Num<U>) -> Self::Output

Performs the - operation. Read more
Source§

impl<U: PrimeField> Sub for Num<U>

Source§

type Output = Num<U>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Num<U>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'macro_lifetime, U: PrimeField> SubAssign<&'macro_lifetime Num<U>> for Num<U>

Source§

fn sub_assign(&mut self, other: &'macro_lifetime Num<U>)

Performs the -= operation. Read more
Source§

impl<U: PrimeField> SubAssign for Num<U>

Source§

fn sub_assign(&mut self, other: Num<U>)

Performs the -= operation. Read more
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for bool

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<bool, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for i128

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<i128, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for i16

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<i16, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for i32

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<i32, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for i64

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<i64, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for i8

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<i8, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for u128

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<u128, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for u16

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<u16, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for u32

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<u32, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for u64

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<u64, &'static str>

Performs the conversion.
Source§

impl<Fp: PrimeField> TryFrom<Num<Fp>> for u8

Source§

type Error = &'static str

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

fn try_from(u: Num<Fp>) -> Result<u8, &'static str>

Performs the conversion.
Source§

impl<Fp: Copy + PrimeField> Copy for Num<Fp>

Source§

impl<Fp: PrimeField> Eq for Num<Fp>

Auto Trait Implementations§

§

impl<Fp> Freeze for Num<Fp>
where Fp: Freeze,

§

impl<Fp> RefUnwindSafe for Num<Fp>
where Fp: RefUnwindSafe,

§

impl<Fp> Send for Num<Fp>
where Fp: Send,

§

impl<Fp> Sync for Num<Fp>
where Fp: Sync,

§

impl<Fp> Unpin for Num<Fp>
where Fp: Unpin,

§

impl<Fp> UnwindSafe for Num<Fp>
where Fp: 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<Out, S> FromSeed<S> for Out
where S: SeedBoxGen<Out>,

Source§

fn from_seed(seed: &[u8]) -> Out

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,