API

Keystream types

ChaChaCiphers.CUDAChaChaStreamType
CUDAChaChaStream <: AbstractChaChaStream

CUDAChaChaStream is a CUDA-compatible ChaCha keystream generator for GPU CRNG.

Examples

Create a CUDAChaChaStream with a randomized key, and sample some random numbers with it:

julia> rng = CUDAChaChaStream();

julia> x = CuVector{Float32}(undef, 2^10);

See also: ChaChaStream

ChaChaCiphers.ChaChaStreamType
ChaChaStream <: AbstractChaChaStream

ChaChaStream provides access to the keystream generated by the ChaCha stream cipher. It can be used as a cryptographically secure random number generator (CRNG) for Julia's random number generation functions.

Examples

Create a ChaChaStream with a randomly-generated key and nonce:

julia> stream = ChaCha20Stream();

Create a ChaChaStream with a pre-specified key and nonce, and use it to generate random data:

julia> key = UInt32.([
          0xe2e39848, 0x70bb974d, 0x845f88b4, 0xb30725e4,
          0x15c309dc, 0x72d545bb, 0x466e99e3, 0x6a759f91
       ]);

julia> nonce = UInt64(1234);

julia> stream = ChaCha20Stream(key, nonce);

julia> randn(stream)
0.7689072580509484

julia> randstring(stream, 'a':'z', 8)
"klmptewr"

See also: CUDAChaChaStream

Keystream helpers

ChaChaCiphers.ChaChaStateType
ChaChaState

A NamedTuple storing the current state of a ChaCha keystream. ChaChaState can be used to save and restore the state of a keystream.

ChaChaCiphers.getstateMethod
getstate(stream::AbstractChaChaStream)

Return a NamedTuple containing enough state of the input AbstractChaChaStream to be able to reproduce it.

Encryption and decryption

Index