dig_did/lib.rs
1//! # dig-did — the DIG Network canonical Chia DID expert crate
2//!
3//! `dig-did` is a **pure, key-free, network-free** SpendBundle-builder for Chia Decentralized
4//! Identifiers (DIDs). It constructs the exact [`CoinSpend`]s for every DID
5//! lifecycle operation and reports — via [`required_signatures`] — the exact signatures a caller
6//! must produce. It never holds a secret key, never signs, and never touches the network. The
7//! consumer signs the reported messages, assembles the `SpendBundle`, and broadcasts.
8//!
9//! ## Invariants
10//!
11//! These four invariants hold across the entire crate and are the contract every unit is built to
12//! (SPEC §1):
13//!
14//! - **INV-1 — No network.** dig-did performs NO network or chain I/O. Every function is a pure
15//! transform of its inputs; the caller fetches coins and broadcasts bundles.
16//! - **INV-2 — No keys.** dig-did never accepts, holds, derives, or logs a secret key. It computes
17//! what must be signed ([`required_signatures`]); the caller's signer produces the signatures.
18//! - **INV-3 — Unsigned output.** Every operation returns an unsigned [`DidSpend`] — coin spends
19//! plus the recreated child DID. Signatures are always the caller's responsibility.
20//! - **INV-4 — SDK byte-source-of-truth.** Every puzzle, layer, and coin-spend byte is produced by
21//! `chia-wallet-sdk` (pinned to the 0.30 / chia-protocol 0.26 family). dig-did adds DID-workflow
22//! ergonomics on top; it never re-implements a puzzle or hand-rolls a spend bundle.
23//!
24//! ## Consumer pattern
25//!
26//! ```text
27//! build an unsigned DidSpend -> required_signatures(&spend.coin_spends, &constants)
28//! -> caller signs each reported message -> assemble SpendBundle -> broadcast
29//! ```
30//!
31//! ## Status
32//!
33//! This is the U1 foundation: the type surface, the error taxonomy, the inner-spend helpers, and
34//! the signing boundary. The DID operations (create, update, recovery, transfer, launch, melt,
35//! attest, hydrate, resolve, did:chia codec) land in their own units against this foundation; their
36//! modules are declared below as doc-only stubs so the layout is final.
37
38// Internal helpers — not part of the public surface.
39mod context;
40
41// Public modules.
42pub mod error;
43pub mod sign;
44pub mod types;
45
46// DID operation modules — declared now so the crate layout is final; each is filled in its own unit
47// (doc-only until then, so they add no untested surface).
48pub mod attest;
49pub mod create;
50pub mod did_string;
51pub mod hydrate;
52pub mod launch;
53pub mod melt;
54pub mod recovery;
55pub mod resolve;
56pub mod transfer;
57pub mod update;
58
59// The curated public surface — consumers depend on these paths, not the module layout.
60pub use error::{DidError, DidResult};
61pub use sign::required_signatures;
62pub use types::{Bytes32, Coin, CoinSpend, Did, DidInfo, DidSpend, LineageProof, Owner, Proof};
63
64// Re-export the signing types a consumer needs to CALL [`required_signatures`] and consume its
65// result, so a downstream crate need not add a direct chia-wallet-sdk dependency for them.
66pub use chia_wallet_sdk::signer::{AggSigConstants, RequiredSignature};