Skip to main content

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//! The foundation (type surface, error taxonomy, inner-spend helpers, signing boundary) ships
34//! alongside **create** ([`create_did`], [`create_simple_did`], [`create_eve_did_only`]),
35//! **hydrate** ([`hydrate_did_from_parent_spend`], [`parse_did_coin_spend`],
36//! [`did_info_from_puzzle`]), and the **did:chia:** string codec ([`did_string_from_launcher_id`],
37//! [`launcher_id_from_did_string`]). The remaining DID operations (update, recovery, transfer,
38//! launch, melt, attest, resolve) land in their own units against this foundation; their modules are
39//! declared below as doc-only stubs so the layout is final.
40
41// Internal helpers — not part of the public surface.
42mod context;
43
44// Public modules.
45pub mod error;
46pub mod sign;
47pub mod types;
48
49// DID creation, hydration, and the did:chia string codec — shipped.
50pub mod create;
51pub mod did_string;
52pub mod hydrate;
53
54// The remaining DID operation modules — declared now so the crate layout is final; each is filled
55// in its own unit (doc-only until then, so they add no untested surface).
56pub mod attest;
57pub mod launch;
58pub mod melt;
59pub mod recovery;
60pub mod resolve;
61pub mod transfer;
62pub mod update;
63
64// The curated public surface — consumers depend on these paths, not the module layout.
65pub use create::{create_did, create_eve_did_only, create_simple_did};
66pub use did_string::{did_string_from_launcher_id, launcher_id_from_did_string, DID_CHIA_PREFIX};
67pub use error::{DidError, DidResult};
68pub use hydrate::{did_info_from_puzzle, hydrate_did_from_parent_spend, parse_did_coin_spend};
69pub use sign::required_signatures;
70pub use types::{Bytes32, Coin, CoinSpend, Did, DidInfo, DidSpend, LineageProof, Owner, Proof};
71
72// Re-export the signing types a consumer needs to CALL [`required_signatures`] and consume its
73// result, so a downstream crate need not add a direct chia-wallet-sdk dependency for them.
74pub use chia_wallet_sdk::signer::{AggSigConstants, RequiredSignature};