zengo-x / crypto-gmp Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
In order to add this lib to curv
as another bigint backend, we need cover these operations:
Arithmetic:
&BigInt + &BigInt
&BigInt + {u8, u16, u32}
(and vice-versa)&BigInt + u64
(and vice-versa)&BigInt - &BigInt
&BigInt - {u8, u16, u32, u64}
(and vice-versa)&BigInt * &BigInt
&BigInt * {u8, u16, u32, u64}
(and vice-versa)&BigInt / &BigInt
&BigInt / {u8, u16, u32, u64}
(no need to do it vice-versa)&BigInt % &BigInt
&BigInt % {u8, u16, u32, u64}
(no need to do it vice-versa)fn pow(&self, e: u32) -> Self
Modular arithmetic:
fn modulus(&self, m: &BigInt) -> BigInt;
fn mod_pow(&self, e: &BigInt, m: &BigInt) -> BigInt
fn mod_mul(&self, rhs: &BigInt, m: &BigInt) -> BigInt
fn mod_sub(&self, rhs: &BigInt, m: &BigInt) -> BigInt
fn mod_add(&self, rhs: &BigInt, m: &BigInt) -> BigInt
fn mod_inv(&self, m: &Self) -> Option<Self>;
Primes:
fn next_prime(&self) -> BigInt
fn is_probable_prime(&self, n: u32) -> bool
Extended GCD algorithm:
fn egcd(a: &BigInt, b: &BigInt) -> (BigInt, BigInt, BigInt)
gcd(a,b)
, p
, q
such as gcd(a,b) = a*p + b*q
Bits manipulations:
fn set_bit(&mut self, bit: usize, bit_val: bool)
fn test_bit(&self, bit: usize) -> bool
fn bit_length(&self) -> usize
&BigInt ^ &BigInt
&BigInt & &BigInt
&BigInt << usize
, &BigInt >> usize
Conversion:
BigInt -> u64
impl TryFrom<&BigInt> for u64
{u8, u16, u32, u64} -> BigInt
impl From<u64> for BigInt
and so onimpl BigInt {
pub fn to_bytes(&self) -> Vec<u8> { /* ... */ }
pub fn from_bytes(bytes: &[u8]) -> Result<Self> { /* ... */ }
}
Other traits:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.