#chia #compatible #rayon #multi-threaded #input #chacha8 #cha-cha8

chiapos-chacha8

A chiapos compatible implementation of chiapos-chacha8. NOTE: This is not an implementation of standard ChaCha8 and should not be used as such.

1 unstable release

0.1.0 Sep 18, 2021

#43 in #rayon

Download history 34/week @ 2024-07-22 48/week @ 2024-07-29 37/week @ 2024-08-05 25/week @ 2024-08-12 29/week @ 2024-08-19 56/week @ 2024-08-26 35/week @ 2024-09-02 33/week @ 2024-09-09 38/week @ 2024-09-16 56/week @ 2024-09-23 45/week @ 2024-09-30 24/week @ 2024-10-07 43/week @ 2024-10-14 40/week @ 2024-10-21 32/week @ 2024-10-28 44/week @ 2024-11-04

160 downloads per month
Used in 11 crates (via block-pseudorand)

Apache-2.0 OR MIT

9KB
125 lines

chiapos-chacha8

This is a byte-for-byte compatible implementation of chiapos' ChaCha8 in Rust. It has been manually verified in a custom implementation of chiapos in Rust to produce identical output.

On top of producing identical output, this implementation is also multi-threaded using Rayon producing data extremely fast.

Usage

This crate has some strict expectations that match the original use-case:

  • Output data must be in 512bit blocks
  • The input key must be 256 bits long (ChaCha8 takes either a 128bit or 256bit input in the original implementation)
  • The IV will be zeroed
// Randomize this key however you would like
let mut key = [0u8; 32];
let chacha8 = ChaCha8::new_from_256bit_key(&key);

// Output data goes in this vec, note that 64 * 8 = 512bits
let num_blocks = 128;
let mut chacha_blocks = vec![0u8; 64 * num_blocks];

// pos is the offset in the output keystream
let pos = 0;
chacha8.get_keystream(pos, &mut chacha_blocks);

Benefits

This crate generates pseudorandom data extremely fast in 512bit blocks. The output is also deterministic for the same inputs.

Caveats

This crate makes no guarantees about:

  • Correctness with regards to the original ChaCha8 implementation / specification
  • Cryptographical security

Dependencies

~1.5MB
~25K SLoC