Skip to content

Commit cf4b8ce

Browse files
committed
Update the README.
1 parent 473cdb8 commit cf4b8ce

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,59 @@
44
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://kernelmethod.github.io/ChaChaCiphers.jl/dev)
55
[![Build Status](https://github.com/kernelmethod/ChaChaCiphers.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/kernelmethod/ChaChaCiphers.jl/actions/workflows/CI.yml?query=branch%3Amain)
66
[![Coverage](https://codecov.io/gh/kernelmethod/ChaChaCiphers.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/kernelmethod/ChaChaCiphers.jl)
7+
8+
`ChaChaCiphers` is a Julia package that provides a CUDA-compatible
9+
implementation of the ChaCha stream cipher family, and implements the
10+
`Random.AbstractDevice` interface to use ChaCha for cryptographically secure
11+
random number generation (CRNG).
12+
13+
This package seeks to accomplish the following goals:
14+
15+
- Provide performant and reproducible CRNG for CPU and GPU computations
16+
- Implement basic cryptographic primitives that can be used as a building block
17+
in higher-level cryptographic code (e.g. for building ChaCha20-Poly1305).
18+
19+
## Usage
20+
21+
You can start using ChaChaCiphers.jl for random number generation by creating a
22+
`ChaChaStream` instance:
23+
24+
```julia
25+
julia> using ChaChaCiphers
26+
27+
julia> rng = ChaChaStream();
28+
```
29+
30+
This will create a `ChaChaStream` with a randomly-generated key. Alternatively,
31+
you can specify a key and pass it in to `ChaChaStream` to create a reproducible
32+
random number stream
33+
34+
```julia
35+
julia> key = UInt32.([
36+
0xe2e39848, 0x70bb974d, 0x845f88b4, 0xb30725e4,
37+
0x15c309dc, 0x72d545bb, 0x466e99e3, 0x6a759f91
38+
]);
39+
40+
julia> rng = ChaChaStream(key);
41+
```
42+
43+
You can then pass `rng` into random number generation functions like `rand` or
44+
`randn`:
45+
46+
```julia
47+
julia> rand(rng, UInt8)
48+
0x18
49+
50+
julia> rand(rng, 1:10, 3)
51+
3-element Vector{Int64}:
52+
8
53+
4
54+
3
55+
56+
julia> randn(rng, 3)
57+
3-element Vector{Float64}:
58+
0.4899558093907058
59+
-0.4164526650672216
60+
-0.864497576500388
61+
```
62+

0 commit comments

Comments
 (0)