raw-crypto Library For CryptoNote Based Crypto Currencies

codecov

Intro

Raw Crypto Library is to provide crypto implementations in C/C++ with rust. Currently the library has implemented all hash functions provided by the cryptonote foundation in it's referential coin forging code base.

Now this library provide the follow interfaces:

  1. Hash
    Hash::slow -> cnslowhash
    Hash::fast -> cnfasthash

  2. Chacha(with ChachaKey, ChachaIV generators)
    Chacha::generate -> chacha8

  3. Key
    Key::generateprivatekey -> generateprivatekey
    Key::secrettopublic -> secretkeytopublickey
    Key::generatekeypair -> generatekeys
    Key::check
    publickey -> checkpublickey
    Key::generate
    keyderivation -> generatekeyderivation
    Key::derive
    publickey -> derivepublickey
    Key::underive
    publickey -> underivepublickey
    Key::derive
    secretkey -> derivesecretkey
    Key::generate
    signature -> generatesignature
    Key::check
    signature -> checksignature
    Key::generate
    keyimage -> generatekey_image

  4. Ring

Ring::generatesignature -> generateringsignature Ring::checksignature -> checkringsignature

  1. Scalars
    EllipticCurveScalar::random -> randomscalar
    EllipticCurveScalar::check -> check
    scalar
    EllipticCurveScalar::tohash -> hashtoscalar
    EllipticCurveScalar::from
    hash -> hashtoec
    EllipticCurvePoint::fromhash -> hashto_point

Usage

Usage can be found in tests.

``` // Generate key let key = ChachaKey::generate(String::from(""));

// Generate iv
let iv = ChachaIV::from([0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18]);

// Generate chacha object
let chacha = Chacha::new(key, iv);

// Prepare plain text
let plain = *b"hello world!";

// Encrypt with chacha8
let cipher = chacha.encrypt(&plain[..]);

// Encrypt again will get the original plain text
let recipher = chacha.encrypt(&cipher[..]);

// they should be equal
assert!(plain == recipher.as_slice());

```