Code Monkey home page Code Monkey logo

crypto-gmp's People

Contributors

dmytrotym avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

crypto-gmp's Issues

Cover `curv`'s BigInt API

In order to add this lib to curv as another bigint backend, we need cover these operations:

Arithmetic:

  • Addition
    • &BigInt + &BigInt
    • &BigInt + {u8, u16, u32} (and vice-versa)
      #1
  • Subtraction
    • &BigInt - &BigInt
    • &BigInt - {u8, u16, u32, u64} (and vice-versa)
  • Multiplication
    • &BigInt * &BigInt
    • &BigInt * {u8, u16, u32, u64} (and vice-versa)
  • Division
    • &BigInt / &BigInt
    • &BigInt / {u8, u16, u32, u64} (no need to do it vice-versa)
  • Reminder
    • &BigInt % &BigInt
    • &BigInt % {u8, u16, u32, u64} (no need to do it vice-versa)
  • Exponentiation
    Ie 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
    Function that finds next prime number using probabilistic algorithms
  • fn is_probable_prime(&self, n: u32) -> bool
    Function that probabilistically determines whether number is prime

Extended GCD algorithm:

  • fn egcd(a: &BigInt, b: &BigInt) -> (BigInt, BigInt, BigInt)
    Function that returns 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
  • BitXor: &BigInt ^ &BigInt
  • BitAnd: &BigInt & &BigInt
  • Shl / Shr: &BigInt << usize, &BigInt >> usize

Conversion:

  • BigInt -> u64
    Ie impl TryFrom<&BigInt> for u64
  • {u8, u16, u32, u64} -> BigInt
    Ie impl From<u64> for BigInt and so on
  • To bytes / from bytes
    impl BigInt {
        pub fn to_bytes(&self) -> Vec<u8> { /* ... */ }
        pub fn from_bytes(bytes: &[u8]) -> Result<Self> { /* ... */ }
    }

Other traits:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.