Skip to content

cryptonote-rust/crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cryptography Primitives For CryptoNote Based Crypto Currencies

codecov

Usage

  1. Cryptonote Chacha8 functions.

a. Generate ChachaKey

use cryptonote_crypto::chacha::{ChachaKey};
let key = ChachaKey::generate(String::from(""));
let key = ChachaKey::generate(String::from("your password"));

b. Generate Chacha

    let iv = ChachaIV::new();
    let chacha = Chacha::new(key, iv);

c. Cipher a plaintext

    let plain = *b"hello world!";
    let cipher = chacha.encrypt(&plain[..]);
    let cipher1 = chacha.encrypt(&cipher[..]);
    assert!(plain == cipher1.as_slice());
  1. Slow Hash

use cryptonote_crypto::hash;
// Version 6
let a = b"hello world!";
let hash = hash::cn_slow_hash(&a[0..], hash::HashVersion::Version6);

// Version 7
// a must be a byte_string with more than 64 bytes long
let a = byte_string::string_to_u8_array("0707cff699d605f7eb4dbdcad3a38b462b52e9b8ecdf06fb4c95bc5b058a177f84d327f27db739430000000363862429fb90c0fc35fcb9f760c484c8532ee5f2a7cbea4e769d44cd12a7f201");
let hash = hash::cn_slow_hash(&a[0..], hash::HashVersion::Version7);
  1. Fast Hash
use cryptonote_crypto::hash;
let a = b"hello world!";
let hash = hash::cn_fast_hash(&a[0..]);

About

Cryptography Primitives for Cryptonote

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •