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
impl FiniteField
Sourcepub fn add(
a: &BigUint,
b: &BigUint,
p: &BigUint,
) -> Result<BigUint, FiniteFieldError>
pub fn add( a: &BigUint, b: &BigUint, p: &BigUint, ) -> Result<BigUint, FiniteFieldError>
Adds to elements in the set
a + b = a mod p
Sourcepub fn mult(
a: &BigUint,
b: &BigUint,
p: &BigUint,
) -> Result<BigUint, FiniteFieldError>
pub fn mult( a: &BigUint, b: &BigUint, p: &BigUint, ) -> Result<BigUint, FiniteFieldError>
Multiplies to elements in the set
a * b = a mod p
Sourcepub fn inv_add(a: &BigUint, p: &BigUint) -> Result<BigUint, FiniteFieldError>
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
Sourcepub fn subtract(
a: &BigUint,
b: &BigUint,
p: &BigUint,
) -> Result<BigUint, FiniteFieldError>
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
Sourcepub fn inv_mult_prime(
a: &BigUint,
p: &BigUint,
) -> Result<BigUint, FiniteFieldError>
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
Sourcepub fn divide(
a: &BigUint,
b: &BigUint,
p: &BigUint,
) -> Result<BigUint, FiniteFieldError>
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
pub fn check_less_than(a: &BigUint, b: &BigUint) -> Result<(), FiniteFieldError>
Auto Trait Implementations§
impl Freeze for FiniteField
impl RefUnwindSafe for FiniteField
impl Send for FiniteField
impl Sync for FiniteField
impl Unpin for FiniteField
impl UnwindSafe for FiniteField
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more