[−][src]Struct amcl_wrapper::field_elem::FieldElement
Don't derive Copy trait as it can hold secret data and should not be accidentally copied
Implementations
impl FieldElement
[src]
Represents an element of the prime field of the curve. All operations are done modulo the curve order
pub fn new() -> Self
[src]
Creates a new field element with value 0
pub fn zero() -> Self
[src]
pub fn one() -> Self
[src]
pub fn minus_one() -> Self
[src]
pub fn random() -> Self
[src]
Return a random non-zero field element
pub fn random_using_rng<R: RngCore + CryptoRng>(rng: &mut R) -> Self
[src]
Return a random non-zero field element using the given random number generator
pub fn is_zero(&self) -> bool
[src]
pub fn is_one(&self) -> bool
[src]
pub fn to_bytes(&self) -> Vec<u8>
[src]
Return bytes in MSB form
pub fn from_bytes(bytes: &[u8]) -> Result<Self, SerzDeserzError>
[src]
Expects bytes in MSB form
pub fn write_to_slice(&self, target: &mut [u8]) -> Result<(), SerzDeserzError>
[src]
Writes bytes in MSB form to given slice. Raises exception when given slice is not of desired length.
pub fn write_to_slice_unchecked(&self, target: &mut [u8])
[src]
Writes bytes in MSB form to given slice. Will panic when given slice is not of desired length.
pub fn to_bignum(&self) -> BigNum
[src]
pub fn normalize(&mut self)
[src]
pub fn from_msg_hash(msg: &[u8]) -> Self
[src]
Hash an arbitrary sized message using SHAKE and return output as a field element
pub fn add_assign_(&mut self, b: &Self)
[src]
Add a field element to itself. self = self + b
pub fn sub_assign_(&mut self, b: &Self)
[src]
Subtract a field element from itself. self = self - b
pub fn plus(&self, b: &Self) -> Self
[src]
Return sum of a field element and itself. self + b
pub fn minus(&self, b: &Self) -> Self
[src]
Return difference of a field element and itself. self - b
pub fn multiply(&self, b: &Self) -> Self
[src]
Multiply 2 field elements modulus the order of the curve. (field_element_a * field_element_b) % curve_order
pub fn square(&self) -> Self
[src]
Calculate square of a field element modulo the curve order, i.e a^2 % curve_order
pub fn pow(&self, exp: &Self) -> Self
[src]
Exponentiation modulo curve order, i.e. self^exp % CurveOrder
pub fn negation(&self) -> Self
[src]
Return negative of field element
pub fn negate(&mut self)
[src]
pub fn inverse(&self) -> Self
[src]
Calculate inverse of a field element modulo the curve order, i.e a^-1 % curve_order
pub fn inverse_mut(&mut self)
[src]
pub fn shift_right(&self, k: usize) -> Self
[src]
pub fn shift_left(&self, k: usize) -> Self
[src]
pub fn is_even(&self) -> bool
[src]
pub fn is_odd(&self) -> bool
[src]
pub fn to_bitvectors(&self) -> Vec<Vec<u8>>
[src]
Gives vectors of bit-vectors for the Big number. Each limb has a separate bit-vector, hence upto NLEN bit-vectors possible. Least significant bytes come first. NOT SIDE CHANNEL RESISTANT
pub fn to_bits(&self) -> Vec<u8>
[src]
Returns bits. Least significant bits come first
pub fn to_wnaf(&self, w: usize) -> Vec<i8>
[src]
Conversion to wNAF, i.e. windowed Non Adjacent form Taken from Guide to Elliptic Curve Cryptography book, "Algorithm 3.35 Computing the width-w NAF of a positive integer" with modification at step 2.1, if k_i >= 2^(w-1), k_i = k_i - 2^w
pub fn to_power_of_2_base(&self, n: usize) -> Vec<u8>
[src]
Convert to base that is power of 2. Does not handle negative nos or base
higher than 2^7
pub fn from_power_of_2_base(repr: &[u8], n: usize) -> Self
[src]
Convert to base that is power of 2. Does not handle negative nos or base
higher than 2^7
pub fn nth_bit(&self, n: usize) -> u8
[src]
Return n-th bit, n starts from 0
pub fn or(&mut self, other: &Self)
[src]
pub fn batch_invert(elems: &[Self]) -> (Vec<Self>, Self)
[src]
Takes a bunch of field elements and returns the inverse of all field elements.
Also returns the product of all inverses as its computed as a side effect.
For an input of n elements, rather than doing n inversions, does only 1 inversion but 3n multiplications.
eg batch_invert([a, b, c, d])
returns ([1/a, 1/b, 1/c, 1/d], 1/a * 1/b * 1/c * 1/d)
Algorithm taken from Guide to Elliptic Curve Cryptography book, "Algorithm 2.26 Simultaneous inversion"
pub fn to_hex(&self) -> String
[src]
Returns hex string in big endian
pub fn from_hex(s: String) -> Result<Self, SerzDeserzError>
[src]
Create big number from hex string in big endian
pub fn reduce_dmod_curve_order(x: &DoubleBigNum) -> BigNum
[src]
Useful for reducing product of BigNums. Uses Barrett reduction
pub fn parse_hex_as_bignum(val: String) -> Result<BigNum, SerzDeserzError>
[src]
Parse given hex string as BigNum in constant time.
Trait Implementations
impl<'a> Add<&'a FieldElement> for FieldElement
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: &'a FieldElement) -> Self
[src]
impl<'a, '_> Add<&'a FieldElement> for &'_ FieldElement
[src]
type Output = FieldElement
The resulting type after applying the +
operator.
fn add(self, other: &'a FieldElement) -> FieldElement
[src]
impl Add<FieldElement> for FieldElement
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self
[src]
impl<'_> Add<FieldElement> for &'_ FieldElement
[src]
type Output = FieldElement
The resulting type after applying the +
operator.
fn add(self, other: FieldElement) -> FieldElement
[src]
impl<'a> AddAssign<&'a FieldElement> for FieldElement
[src]
fn add_assign(&mut self, other: &'a FieldElement)
[src]
impl AddAssign<FieldElement> for FieldElement
[src]
fn add_assign(&mut self, other: Self)
[src]
impl Clone for FieldElement
[src]
fn clone(&self) -> FieldElement
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for FieldElement
[src]
impl Default for FieldElement
[src]
impl<'a> Deserialize<'a> for FieldElement
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'a>,
[src]
D: Deserializer<'a>,
impl Display for FieldElement
[src]
impl Drop for FieldElement
[src]
impl Eq for FieldElement
[src]
impl<'_> From<&'_ [u8; 48]> for FieldElement
[src]
impl From<BIG> for FieldElement
[src]
impl From<i32> for FieldElement
[src]
impl From<u32> for FieldElement
[src]
impl From<u64> for FieldElement
[src]
impl From<u8> for FieldElement
[src]
impl Hash for FieldElement
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'_> Mul<&'_ FieldElement> for G1
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: &FieldElement) -> Self
[src]
impl<'_, '_> Mul<&'_ FieldElement> for &'_ G1
[src]
type Output = G1
The resulting type after applying the *
operator.
fn mul(self, other: &FieldElement) -> G1
[src]
impl<'_> Mul<&'_ FieldElement> for G2
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: &FieldElement) -> Self
[src]
impl<'_, '_> Mul<&'_ FieldElement> for &'_ G2
[src]
type Output = G2
The resulting type after applying the *
operator.
fn mul(self, other: &FieldElement) -> G2
[src]
impl<'_> Mul<&'_ G1> for FieldElement
[src]
type Output = G1
The resulting type after applying the *
operator.
fn mul(self, other: &G1) -> G1
[src]
impl<'_, '_> Mul<&'_ G1> for &'_ FieldElement
[src]
type Output = G1
The resulting type after applying the *
operator.
fn mul(self, other: &G1) -> G1
[src]
impl<'_> Mul<&'_ G2> for FieldElement
[src]
type Output = G2
The resulting type after applying the *
operator.
fn mul(self, other: &G2) -> G2
[src]
impl<'_, '_> Mul<&'_ G2> for &'_ FieldElement
[src]
type Output = G2
The resulting type after applying the *
operator.
fn mul(self, other: &G2) -> G2
[src]
impl<'a> Mul<&'a FieldElement> for FieldElement
[src]
type Output = FieldElement
The resulting type after applying the *
operator.
fn mul(self, other: &'a FieldElement) -> FieldElement
[src]
impl<'a, '_> Mul<&'a FieldElement> for &'_ FieldElement
[src]
type Output = FieldElement
The resulting type after applying the *
operator.
fn mul(self, other: &'a FieldElement) -> FieldElement
[src]
impl Mul<FieldElement> for FieldElement
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: Self) -> Self
[src]
impl<'_> Mul<FieldElement> for &'_ FieldElement
[src]
type Output = FieldElement
The resulting type after applying the *
operator.
fn mul(self, other: FieldElement) -> FieldElement
[src]
impl Mul<FieldElement> for G1
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: FieldElement) -> Self
[src]
impl<'_> Mul<FieldElement> for &'_ G1
[src]
type Output = G1
The resulting type after applying the *
operator.
fn mul(self, other: FieldElement) -> G1
[src]
impl Mul<FieldElement> for G2
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, other: FieldElement) -> Self
[src]
impl<'_> Mul<FieldElement> for &'_ G2
[src]
type Output = G2
The resulting type after applying the *
operator.
fn mul(self, other: FieldElement) -> G2
[src]
impl Mul<G1> for FieldElement
[src]
type Output = G1
The resulting type after applying the *
operator.
fn mul(self, other: G1) -> G1
[src]
impl<'_> Mul<G1> for &'_ FieldElement
[src]
type Output = G1
The resulting type after applying the *
operator.
fn mul(self, other: G1) -> G1
[src]
impl Mul<G2> for FieldElement
[src]
type Output = G2
The resulting type after applying the *
operator.
fn mul(self, other: G2) -> G2
[src]
impl<'_> Mul<G2> for &'_ FieldElement
[src]
type Output = G2
The resulting type after applying the *
operator.
fn mul(self, other: G2) -> G2
[src]
impl Neg for FieldElement
[src]
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl<'_> Neg for &'_ FieldElement
[src]
type Output = FieldElement
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl Ord for FieldElement
[src]
fn cmp(&self, other: &FieldElement) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<FieldElement> for FieldElement
[src]
fn eq(&self, other: &FieldElement) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<FieldElement> for FieldElement
[src]
fn partial_cmp(&self, other: &FieldElement) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for FieldElement
[src]
impl<'a> Sub<&'a FieldElement> for FieldElement
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: &'a FieldElement) -> Self
[src]
impl<'a, '_> Sub<&'a FieldElement> for &'_ FieldElement
[src]
type Output = FieldElement
The resulting type after applying the -
operator.
fn sub(self, other: &'a FieldElement) -> FieldElement
[src]
impl Sub<FieldElement> for FieldElement
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: Self) -> Self
[src]
impl<'_> Sub<FieldElement> for &'_ FieldElement
[src]
type Output = FieldElement
The resulting type after applying the -
operator.
fn sub(self, other: FieldElement) -> FieldElement
[src]
impl<'a> SubAssign<&'a FieldElement> for FieldElement
[src]
fn sub_assign(&mut self, other: &'a Self)
[src]
impl SubAssign<FieldElement> for FieldElement
[src]
fn sub_assign(&mut self, other: Self)
[src]
impl Zeroize for FieldElement
[src]
Auto Trait Implementations
impl RefUnwindSafe for FieldElement
impl Send for FieldElement
impl Sync for FieldElement
impl Unpin for FieldElement
impl UnwindSafe for FieldElement
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<Z> Zeroize for Z where
Z: DefaultIsZeroes,
[src]
Z: DefaultIsZeroes,