[−][src]Trait clacc::bigint::BigInt
A trait describing an arbitrary precision integer.
Required methods
fn next_prime(&self) -> Self
Returns the next prime greater than self
.
fn gcdext<'a>(&self, y: &'a Self) -> (Self, Self, Self)
Returns the greatest common divisor of self
and the coefficients a
and b
satisfying a*x + b*y = g
.
fn modulus<'a>(&self, m: &'a Self) -> Self
Return the modulus of self / m
.
fn powm<'a>(&self, e: &'a Self, m: &Self) -> Self
Returns self^e mod m
.
fn invert<'a>(&self, m: &'a Self) -> Option<Self>
Returns self^-1 mod m
.
fn to_vec(&self) -> Vec<u8>
Export the number as a u8 vector.
Implementors
impl BigInt for BigIntGmp
[src]
fn next_prime(&self) -> Self
[src]
use clacc::bigint::{BigInt, BigIntGmp}; let x: BigIntGmp = 32.into(); let p = x.next_prime(); assert_eq!(p, 37.into());
fn gcdext(&self, y: &Self) -> (Self, Self, Self)
[src]
use clacc::bigint::{BigInt, BigIntGmp}; let x: BigIntGmp = 240.into(); let y: BigIntGmp = 46.into(); let (g, a, b) = x.gcdext(&y); assert_eq!(g, 2.into()); assert_eq!(a, (-9).into()); assert_eq!(b, 47.into());
fn modulus(&self, m: &Self) -> Self
[src]
use clacc::bigint::{BigInt, BigIntGmp}; let b: BigIntGmp = 11.into(); let n: BigIntGmp = 7.into(); let m = b.modulus(&n); assert_eq!(m, 4.into());
fn powm(&self, e: &Self, m: &Self) -> Self
[src]
use clacc::bigint::{BigInt, BigIntGmp}; let b: BigIntGmp = 5.into(); let e: BigIntGmp = 3.into(); let m: BigIntGmp = 13.into(); let c = b.powm(&e, &m); assert_eq!(c, 8.into());
fn invert(&self, m: &Self) -> Option<Self>
[src]
use clacc::bigint::{BigInt, BigIntGmp}; let a: BigIntGmp = 123.into(); let n: BigIntGmp = 4567.into(); let i = a.invert(&n).unwrap(); assert_eq!(i, 854.into());
fn to_vec(&self) -> Vec<u8>
[src]
use clacc::bigint::{BigInt, BigIntGmp}; let x: BigIntGmp = 15.into(); assert_eq!(x.to_vec(), vec![0x0f]);