[][src]Struct g2poly::G2PolyProd

pub struct G2PolyProd(pub u128);

The result of multiplying two G2Poly

This type is used to represent the result of multiplying two G2Polys. Since this could overflow when relying on just a u64, this type uses an internal u128. The only operation implemented on this type is % which reduces the result back to a G2Poly.

let a = G2Poly(0xff_00_00_00_00_00_00_00);
assert_eq!(a * a, G2PolyProd(0x55_55_00_00_00_00_00_00_00_00_00_00_00_00_00_00));
assert_eq!(a * a % G2Poly(0b100), G2Poly(0));

Methods

impl G2PolyProd[src]

pub fn to_poly(self) -> G2Poly[src]

Convert to G2Poly

Panics

Panics, if the internal representation exceeds the maximum value for G2Poly.

Example


let a = G2Poly(0x40_00_00_00_00_00_00_00) * G2Poly(2);
assert_eq!(G2Poly(0x80_00_00_00_00_00_00_00), a.to_poly());

// Next line would panics!
// (G2Poly(0x40_00_00_00_00_00_00_00) * G2Poly(4)).to_poly();

pub fn try_to_poly(self) -> Option<G2Poly>[src]

Convert to G2Poly if possible

In case the value would not fit into G2Poly, return None

Example

assert_eq!((G2Poly(0x40_00_00_00_00_00_00_00) * G2Poly(2)).try_to_poly(), Some(G2Poly(0x80_00_00_00_00_00_00_00)));
assert_eq!((G2Poly(0x40_00_00_00_00_00_00_00) * G2Poly(4)).try_to_poly(), None);

Trait Implementations

impl PartialEq<G2PolyProd> for G2PolyProd[src]

impl Clone for G2PolyProd[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Ord for G2PolyProd[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl Eq for G2PolyProd[src]

impl Copy for G2PolyProd[src]

impl PartialOrd<G2PolyProd> for G2PolyProd[src]

impl Debug for G2PolyProd[src]

impl Rem<G2Poly> for G2PolyProd[src]

type Output = G2Poly

The resulting type after applying the % operator.

fn rem(self, rhs: G2Poly) -> G2Poly[src]

Calculate the polynomial remainder of the product of polynomials

When calculating a % b this computes the value of r in a = q * b + r such that |r| < |b|.

Example

let a = G2Poly(0x12_34_56_78_9A_BC_DE);
let m = G2Poly(0x00_00_00_01_00_00);
assert!((a * a % m).degree().expect("Positive degree") < m.degree().expect("Positive degree"));
assert_eq!(G2Poly(0b0101_0001_0101_0100), a * a % m);

Auto Trait Implementations

impl Send for G2PolyProd

impl Sync for G2PolyProd

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]