16 unstable releases (3 breaking)
0.5.7 | Nov 6, 2019 |
---|---|
0.5.6 | Oct 30, 2019 |
0.5.2 | Sep 23, 2019 |
0.4.0 | Sep 16, 2019 |
0.1.4 | Apr 17, 2019 |
#1 in #cryptonote
46 downloads per month
Used in cryptonote-wallet
5MB
11K
SLoC
raw-crypto Library For CryptoNote Based Crypto Currencies
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:
-
Hash
Hash::slow -> cn_slow_hash
Hash::fast -> cn_fast_hash
Hash::check_with_difficulty -> cryptonote::check_hash -
Chacha(with ChachaKey, ChachaIV generators)
Chacha::generate -> chacha8 -
Key
Key::generate_private_key -> generate_private_key
Key::secret_to_public -> secret_key_to_public_key
Key::generate_key_pair -> generate_keys
Key::check_public_key -> check_public_key
Key::generate_key_derivation -> generate_key_derivation
Key::derive_public_key -> derive_public_key
Key::underive_public_key -> underive_public_key
Key::derive_secret_key -> derive_secret_key
Key::generate_signature -> generate_signature
Key::check_signature -> check_signature
Key::generate_key_image -> generate_key_image -
Ring
Ring::generate_signature -> generate_ring_signature Ring::check_signature -> check_ring_signature -
Scalars
EllipticCurveScalar::random -> random_scalar
EllipticCurveScalar::check -> check_scalar
EllipticCurveScalar::to_hash -> hash_to_scalar
EllipticCurveScalar::from_hash -> hash_to_ec
EllipticCurvePoint::from_hash -> hash_to_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());