1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! # dig-session
//!
//! The DIG **session / keystore layer**: a small, custody-safe facade that
//! turns stored, encrypted key material into a live signer and injects a bare
//! signing primitive into downstream consumers.
//!
//! It composes two lower-level crates and adds no cryptography of its own:
//!
//! - [`dig_keystore`] — encrypted, per-scheme secret-key storage
//! (`Keystore::<K>::load -> unlock -> SignerHandle<K>`, AES-256-GCM + Argon2id).
//! - [`dig_identity`] — the canonical DIG BLS identity derivation
//! (`master_secret_key_from_seed` then `derive_identity_sk` at the hardened
//! path `m/12381'/8444'/9'/0'`).
//!
//! ## What this crate deliberately does NOT do
//!
//! There is **no seal / decap** (recipient message encryption) here. That
//! composition belongs to `dig-message` (the same 10-primitives level); adding
//! it here would duplicate a cross-repo contract and invite byte-drift. This
//! crate's first cut is strictly **unlock / sign / inject**.
//!
//! ## Enrollment stores the derived key with `L1WalletBls`, not `BlsSigning`
//!
//! The identity signing key is a key that dig-identity has *already derived*
//! (via EIP-2333 hardened steps). To reconstruct it on unlock byte-identically,
//! storage must use a scheme that round-trips raw secret-key bytes through
//! `chia_bls::SecretKey::from_bytes` — that is [`L1WalletBls`].
//!
//! [`BlsSigning`] instead treats its stored 32 bytes as a *seed* and runs them
//! through `chia_bls::SecretKey::from_seed` on every unlock. Storing an
//! already-derived key under `BlsSigning` would therefore re-derive a
//! *different* key (the documented dig_ecosystem #64 / #57 pitfall), and the
//! resulting public key would not match the DID-anchored identity key. So the
//! identity path uses `L1WalletBls`; a regression test asserts the unlocked
//! public key equals `dig_identity::public_key_bytes(derive_identity_sk(master))`.
//!
//! [`Session::unlock`] stays generic over the scheme, so `BlsSigning` is still
//! available for seed-derived validator keys.
//!
//! ## Example
//!
//! ```no_run
//! use std::sync::Arc;
//! use dig_session::{Session, FileBackend, BackendKey, Password};
//!
//! # fn main() -> dig_session::Result<()> {
//! let backend = Arc::new(FileBackend::new("/var/lib/dig/keys"));
//! let identity = Session::enroll_identity(
//! backend,
//! BackendKey::new("identity"),
//! Password::from("correct horse battery staple"),
//! b"BIP-39 seed bytes go here",
//! )?;
//!
//! // Hand a downstream a bare signing primitive — it never sees a session type.
//! let sign = identity.signing_fn();
//! let _sig = sign(b"message");
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use Session;
pub use ;
// Re-export the storage/scheme types a caller needs, so a consumer depends on
// JUST dig-session rather than reaching into dig-keystore directly.
pub use ;
pub use ;
pub use ;