pub struct FpNum<const P: u128>(_);
Expand description
An integer modulo P
.
Example
use libbgs::numbers::FpNum;
let x = FpNum::<7>::from(5);
let y = FpNum::<7>::from(6);
let z = x * y;
assert_eq!(z, FpNum::from(30 % 7));
For more informtion on the internal representation, see: Montgomery, Peter (April 1985). “Modular Multiplication Without Trial Division”. Mathematics of Computation. 44 (170): 519-521.
Implementations§
source§impl<const P: u128> FpNum<P>
impl<const P: u128> FpNum<P>
sourcepub const fn legendre(&self) -> FpNum<P>
pub const fn legendre(&self) -> FpNum<P>
Returns the Legendre symbol of a
modulo P
, i.e.,
$$\left(\frac{a}{p}\right)_L = a^{\frac{p - 1}{2}} \mod p$$.
sourcepub const fn int_sqrt(&self) -> Option<FpNum<P>>
pub const fn int_sqrt(&self) -> Option<FpNum<P>>
Calculates this number’s square root, if it is a quadratic residue; otherwise, returns
None
.
sourcepub const fn find_nonresidue() -> FpNum<P>
pub const fn find_nonresidue() -> FpNum<P>
Returns a quadratic nonresidue modulo p
.
Trait Implementations§
source§impl<const P: u128> GroupElem for FpNum<P>
impl<const P: u128> GroupElem for FpNum<P>
source§fn multiply(&self, other: &FpNum<P>) -> FpNum<P>
fn multiply(&self, other: &FpNum<P>) -> FpNum<P>
Returns the product of two elements under the group binary operator.
If you implement this trait, you must guarantee that the operation is associative; that is,
a.multiply(b.multiply(c)) == a.multiply(b).multiply(c)
.source§fn inverse(&self) -> FpNum<P>
fn inverse(&self) -> FpNum<P>
Returns the multiplicative inverse of this element.
If you implement this trait, you must guarantee
x.inverse().multiply(x)
and
x.multiply(x.inverse())
both evaluate to ONE
.source§const ONE_256: [Self; 256] = _
const ONE_256: [Self; 256] = _
👎Deprecated: To be replaced by inline
const
expressions once stabilized.! 256 copies of
Self::ONE
in an array.source§impl<const P: u128> MulAssign<FpNum<P>> for FpNum<P>
impl<const P: u128> MulAssign<FpNum<P>> for FpNum<P>
source§fn mul_assign(&mut self, rhs: FpNum<P>)
fn mul_assign(&mut self, rhs: FpNum<P>)
Performs the
*=
operation. Read moresource§impl<const P: u128> PartialEq<FpNum<P>> for FpNum<P>
impl<const P: u128> PartialEq<FpNum<P>> for FpNum<P>
source§impl<S, const P: u128> SylowDecomposable<S> for FpNum<P>where
FpNum<P>: Factor<S>,
impl<S, const P: u128> SylowDecomposable<S> for FpNum<P>where FpNum<P>: Factor<S>,
source§fn find_sylow_generator(i: usize) -> FpNum<P>
fn find_sylow_generator(i: usize) -> FpNum<P>
Finds a Sylow generator for the Sylow subgroup of prime power index
i
.source§fn is_sylow_generator(candidate: &Self, d: (u128, usize)) -> Option<Self>
fn is_sylow_generator(candidate: &Self, d: (u128, usize)) -> Option<Self>
True if the given element is a generator of the Sylow subgroup of the prime power
represented by
d
.source§fn count_elements_of_order(ds: &[usize]) -> u128
fn count_elements_of_order(ds: &[usize]) -> u128
Returns the number of elements of a particular order.
The argument is the powers of the prime factors of the group’s order.
impl<const P: u128> Copy for FpNum<P>
impl<const P: u128> Eq for FpNum<P>
impl<const P: u128> StructuralEq for FpNum<P>
impl<const P: u128> StructuralPartialEq for FpNum<P>
Auto Trait Implementations§
impl<const P: u128> RefUnwindSafe for FpNum<P>
impl<const P: u128> Send for FpNum<P>
impl<const P: u128> Sync for FpNum<P>
impl<const P: u128> Unpin for FpNum<P>
impl<const P: u128> UnwindSafe for FpNum<P>
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