hoprd_keypair/
lib.rs

1//! Generates, reads, and writes hopr key material following the Ethereum KeyStore standard.
2//!
3//! Reimplements the `eth_keystore` crate to support WASM which cannot be used because using custom FS access is not
4//! foreseen and utilized version of `uuid` cannot use JS `getrandom` entropy.
5//!
6//! Automatically migrates keyStore that only have a `chain_key` to those who also store a `packet_key`.
7//!
8//! # Key format
9//! ```json
10//! {
11//!   "version": 2,
12//!   "chain_key": "7a714c922cd769ab6702ffac411fb1a4d28500613e2ac8bf71f14c3604bba091",
13//!   "packet_key": "5d147b58bce1664f88e60921a9aa8195cc54081e587b24e66005bbf60fbf480c"
14//! }
15//! ```
16//!
17//! # Example
18//! Key store file (password: `e2e-test`)
19//!
20//! ```json
21//! {
22//!   "crypto": {
23//!     "cipher": "aes-128-ctr",
24//!     "cipherparams": { "iv": "3b0551f925bfd0ded154ec487dc78d29" },
25//!     "ciphertext": "bbdb25cdbeff683926999baee0e929c4e9922ca0b4c99e90351aa8fa286b10d7a5bcdfe2e58cffc9d4f9df10121d0b4b1ac697f97909e8f9fdf15aff91b555cb7ca8b5e10ed747de9a99c0e9d3c540ed09997689ec5aba0d0a946e5ea167c7e4be91fa67be419fd0169aca1d73229d0049bff82e3f6c3256c7a2ba24bb4b02aefa224f0ad70479a5e117b3cc133adf03021aceb2152b8727ccd559ce3758bf523e429a4f4806b58fa5597532",
26//!     "kdf": "scrypt",
27//!     "kdfparams": {
28//!       "dklen": 32,
29//!       "n": 2,
30//!       "p": 1,
31//!       "r": 8,
32//!       "salt": "01da6de6a096ba594fd1119ad907e8fbf531874a4bcc234a3a88b2e9e4d8cb06"
33//!     },
34//!     "mac": "a18ae65efbc0d0085ff6a26956695f704509cdb6a05ee168e2017c4399e8be43"
35//!   },
36//!   "id": "68172b5b-e4e7-4ac9-9932-352a95f11561",
37//!   "version": 3
38//! }
39//! ```
40//!
41//! leading to following PeerIds:
42//! ```shell
43//!   chain_key 16Uiu2HAmJqfGeZPa8VJ8263NDjehHkMXYqYzbi4zqhH7Y3RKsEoV (secp256k1)
44//!   packet_key 12D3KooWPGsW7vZ8VsmJ9Lws9vsKaBiACZXQ3omRm3rFUho5BpvF (ed25519)
45//! ```
46
47pub mod errors;
48pub mod key_pair;
49pub mod keystore;