Crates.io | secret-tree |
lib.rs | secret-tree |
version | 0.5.0 |
source | src |
created_at | 2018-12-23 18:44:29.446022 |
updated_at | 2022-07-21 13:25:25.375733 |
description | Hierarchical secret derivation with Blake2b |
homepage | |
repository | https://github.com/slowli/secret-tree |
max_upload_size | |
id | 103458 |
size | 89,670 |
secret-tree
allows deriving multiple secrets from a single seed value
in a secure and forward-compatible way.
The derivation procedure is hierarchical: a seed can be used to derive child seeds,
which have the same functionality as the original.
Add this to your Crate.toml
:
[dependencies]
secret-tree = "0.5.0"
Basic usage:
use secret_tree::{SecretTree, Name};
use rand::{Rng, thread_rng};
use secrecy::Secret;
let tree = SecretTree::new(&mut thread_rng());
// Create 2 children from the tree: an ordinary secret
// and a CSPRNG with a fixed seed.
let secret: Secret<[u8; 32]> = tree
.child(Name::new("secret"))
.create_secret();
let other_secret_rng = tree
.child(Name::new("other_secret"))
.rng();
See crate documentation for more details how to use the crate.
Blake2b is used to derive secrets in a similar (and mostly compatible) way it is used for key derivation in libsodium. Derived CSPRNGs are based on the ChaCha cipher, which has been extensively studied and has much smaller state size that alternatives (~160 bytes vs several kilobytes), limiting the threat of state leakage.
Crate documentation provides more implementation details.
Licensed under the Apache-2.0 license.