Struct FiniteField

Source
pub struct FiniteField {}
Expand description

A struct which implements the bottom layer finite field group needed to operate with the coordinates of the elliptic curve group.

Implementations§

Source§

impl FiniteField

Source

pub fn add( a: &BigUint, b: &BigUint, p: &BigUint, ) -> Result<BigUint, FiniteFieldError>

Adds to elements in the set

a + b = a mod p

Source

pub fn mult( a: &BigUint, b: &BigUint, p: &BigUint, ) -> Result<BigUint, FiniteFieldError>

Multiplies to elements in the set

a * b = a mod p

Source

pub fn inv_add(a: &BigUint, p: &BigUint) -> Result<BigUint, FiniteFieldError>

Finds the additive inverse of an element in the set:

a + (-a) = 0 mod p

Source

pub fn subtract( a: &BigUint, b: &BigUint, p: &BigUint, ) -> Result<BigUint, FiniteFieldError>

Subtract two elements in the set:

a - b = a + (-b) = a mod p

Source

pub fn inv_mult_prime( a: &BigUint, p: &BigUint, ) -> Result<BigUint, FiniteFieldError>

Finds the multiplicative inverse of an element in the set if p is a prime number using Fermat’s Little Theorem:

a^(-1) mod p = a^(p-2) mod p

Such that: a * a^(-1) = 1 mod p

Source

pub fn divide( a: &BigUint, b: &BigUint, p: &BigUint, ) -> Result<BigUint, FiniteFieldError>

Divides two elements in the set:

a / b = a * b^(-1) = a mod p

Source

pub fn check_less_than(a: &BigUint, b: &BigUint) -> Result<(), FiniteFieldError>

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> 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, 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.