Skip to main content

Crate dig_account

Crate dig_account 

Source
Expand description

§dig-account

The DIG Network user Account — the fat, strictly-logical (zero-UI, headless-testable) encapsulation of everything an account can do.

An Account is one master seed plus one or more Profiles (exactly one default). A Profile is a DID + dig-store + SMT-of-profile-info, minted and signed with the account seed’s key at that profile index and recorded as a registry::ProfileAnchor.

This crate owns the object model, the unlock policy + keystore crypto, the in-process identity+money signer, per-profile key/DEK derivation, the on-chain DID mint, and all wallet ops, including the STORE half of a profile mint — a dig-store singleton launched from the DID’s own coin, committed to a seeded profile SMT. It NEVER draws UI or drives an OS auth ceremony — the host harness (dig-app) injects a UI/auth provider that this crate calls back through for unlock and spend-confirm ceremonies.

§Custody split (the harness seam)

dig-account is headless: it owns the account STATE machine + the crypto, but it never collects a password, renders a spend prompt, or drives an OS auth ceremony. The host harness (dig-app) implements AuthProvider and injects it; dig-account calls back through that seam for every unlock and every spend confirmation. The private key never leaves the crate; the UI never sees a seed.

See SPEC.md for the normative contract.

§What carries a real implementation

Everything below is implemented and tested against a real consensus validator or real crypto — there are no stubbed bodies left. The object model, the profile registry (registry — which profiles exist, which is active, which mints are half-finished), keystore (store), unlock policy (auth::policy), per-profile key/DEK derivation, and the money path (wallet — the canonical WalletKey + the concrete MoneySigner over dig-wallet-backend’s LocalSigner, with the structured SpendSummary) carry real, tested implementations, as does the on-chain DID mint (mint — build, sign, push, and prove a did:chia: against real chain evidence) and the full profile mint (mint::profile — the two-bundle ceremony that binds a DID to a dig-store launched from its coin, resumable across a restart).

A profile mint is deliberately THREE calls rather than one, because it spans two on-chain confirmations with a minutes-wide window between them in which the DID is already paid for: ProfileMinter::begin_profile_mint, ProfileMinter::advance_profile_mint and ProfileMinter::profile_mint_status.

Re-exports§

pub use auth::factors::AuthFactors;
pub use auth::policy::AllOf;
pub use auth::policy::AuthPolicy;
pub use auth::policy::PasswordOnlyPolicy;
pub use auth::policy::UnlockError;
pub use auth::policy::UnlockGate;
pub use auth::provider::AuthProvider;
pub use auth::provider::SpendConfirmRequest;
pub use auth::provider::SpendDecision;
pub use auth::provider::UnlockRequest;
pub use auth::second_factor::SecondFactor;
pub use auth::second_factors::Challenge;
pub use auth::second_factors::ChallengeIssuer;
pub use auth::second_factors::CoseAlgorithm;
pub use auth::second_factors::PasskeyClock;
pub use auth::second_factors::PasskeyCredential;
pub use auth::second_factors::PasskeyError;
pub use auth::second_factors::PasskeyFactor;
pub use auth::second_factors::SystemPasskeyClock;
pub use auth::second_factors::SystemTimeSource;
pub use auth::second_factors::TimeSource;
pub use auth::second_factors::TotpAlgorithm;
pub use auth::second_factors::TotpError;
pub use auth::second_factors::TotpFactor;
pub use auth::second_factors::TotpParams;
pub use auth::second_factors::TotpSecret;
pub use auth::second_factors::UserVerification;
pub use chain_confirm::confirm_all_spendable_by_name;
pub use chain_confirm::confirm_spendable_by_name;
pub use chain_confirm::UnconfirmedInput;
pub use constants::MAINNET_ADDRESS_PREFIX;
pub use edit::read_profile;
pub use edit::CommittedEdit;
pub use edit::EditError;
pub use edit::EditResult;
pub use edit::EditStatus;
pub use edit::ProfileContentSource;
pub use edit::ProfileEdit;
pub use edit::ProfileEditor;
pub use edit::ProfileFields;
pub use edit::ProfileSlot;
pub use edit::ProfileSnapshot;
pub use error::AccountError;
pub use error::Result;
pub use id::AccountId;
pub use id::ProfileIx;
pub use keys::dek::profile_dek;
pub use keys::wallet_key::WalletKey;
pub use mint::reward_distributor::begin_reward_distributor_mint;
pub use mint::reward_distributor::RewardDistributorMintRequest;
pub use mint::reward_distributor::SignedRewardDistributorMint;
pub use mint::reward_distributor::OFFER_XCH_AMOUNT;
pub use mint::reward_distributor_clawback::begin_reward_distributor_clawback;
pub use mint::reward_distributor_clawback::RewardDistributorClawbackRequest;
pub use mint::reward_distributor_clawback::SignedRewardDistributorClawback;
pub use mint::reward_distributor_refill::begin_reward_distributor_refill;
pub use mint::reward_distributor_refill::RewardDistributorRefillRequest;
pub use mint::reward_distributor_refill::SignedRewardDistributorRefill;
pub use mint::interpret_push_answer;
pub use mint::push_tx_request_json;
pub use mint::ChainUnavailable;
pub use mint::CoinsetPublisher;
pub use mint::ConfirmedRewardDistributor;
pub use mint::ConfirmedStore;
pub use mint::HttpAnswer;
pub use mint::MintError;
pub use mint::MintNetwork;
pub use mint::MintOptions;
pub use mint::MintResult;
pub use mint::MintStatus;
pub use mint::MintedDid;
pub use mint::OwnershipProof;
pub use mint::PendingMint;
pub use mint::PendingRewardDistributor;
pub use mint::PendingRewardDistributorRecord;
pub use mint::PendingStoreLaunch;
pub use mint::ProfileMintStatus;
pub use mint::ProfileSeed;
pub use mint::PushOutcome;
pub use mint::PushTransport;
pub use mint::RecordField;
pub use mint::RecordRejection;
pub use mint::RewardDistributorStatus;
pub use mint::SpendPublisher;
pub use mint::COINSET_MAINNET_PUSH_URL;
pub use mint::MAX_MINT_FEE_MOJOS;
pub use mint::MIN_CONFIRMATION_DEPTH;
pub use model::Account;
pub use model::AccountRecord;
pub use model::Profile;
pub use profile_mint::ProfileMinter;
pub use profile_resolve::resolve_profile_store;
pub use profile_resolve::ProfileResolveError;
pub use profile_resolve::ProfileStoreResolution;
pub use profile_resolve::MAX_PROFILE_LAUNCHES_PER_DID;
pub use profile_resolve::PROFILE_INTERMEDIATE_PUZZLE_HASH;
pub use registry::ActiveProfile;
pub use registry::ActiveSwitch;
pub use registry::ConfirmedStoreRecord;
pub use registry::MintStage;
pub use registry::MintedDidRecord;
pub use registry::PendingMintRecord;
pub use registry::PendingStoreLaunchRecord;
pub use registry::ProfileAnchor;
pub use registry::ProfileEnd;
pub use registry::ProfileEndOutcome;
pub use registry::ProfileEntry;
pub use registry::ProfileMintInProgress;
pub use registry::ProfileRegistry;
pub use registry::ProfileVisibility;
pub use reward_distributor_mint::RewardDistributorMinter;
pub use session::AccountSession;
pub use session_residency::Residency;
pub use signer::ProfileSigner;
pub use store::AccountStore;
pub use store::AccountStoreError;
pub use unlocked::UnlockedAccount;
pub use wallet::approval::PendingApproval;
pub use wallet::approval::SpendApproval;
pub use wallet::approval::SpendRuling;
pub use wallet::authorizer::WalletOps;
pub use wallet::autosend::AutoSendPolicy;
pub use wallet::autosend::OpClassLimits;
pub use wallet::autosend::SpendOpClass;
pub use wallet::autosend::DEFAULT_PERIOD_SECONDS;
pub use wallet::cat_transfer::amount_in_dig;
pub use wallet::cat_transfer::cat_coins;
pub use wallet::cat_transfer::cat_curried_puzzle_hash;
pub use wallet::cat_transfer::dig_cat_coins;
pub use wallet::cat_transfer::dig_curried_puzzle_hash;
pub use wallet::cat_transfer::CatCoinListing;
pub use wallet::cat_transfer::CatTransferError;
pub use wallet::cat_transfer::CatTransferPlan;
pub use wallet::cat_transfer::CatTransferRequest;
pub use wallet::cat_transfer::CatTransferResult;
pub use wallet::cat_transfer::DIG_BASE_UNITS_PER_TOKEN;
pub use wallet::cat_transfer::MAX_CAT_TRANSFER_INPUT_COINS;
pub use wallet::cat_transfer::MAX_LISTED_CAT_COINS;
pub use wallet::clock::Clock;
pub use wallet::clock::FixedClock;
pub use wallet::clock::SystemClock;
pub use wallet::enforcer::PolicyAuthorizer;
pub use wallet::money_signer::LocalMoneySigner;
pub use wallet::money_signer::MoneySigner;
pub use wallet::policy::CustodyPolicy;
pub use wallet::policy::HotWallet;
pub use wallet::policy::Vault;
pub use wallet::summary::SpendDestination;
pub use wallet::summary::SpendRecipient;
pub use wallet::summary::SpendSummary;
pub use wallet::summary::SpendTier;
pub use wallet::transfer::transfer_status;
pub use wallet::transfer::ConfirmedTransfer;
pub use wallet::transfer::PayableDestination;
pub use wallet::transfer::PendingTransfer;
pub use wallet::transfer::TransferError;
pub use wallet::transfer::TransferPlan;
pub use wallet::transfer::TransferRequest;
pub use wallet::transfer::TransferResult;
pub use wallet::transfer::TransferStatus;
pub use wallet::transfer::MAX_TRANSFER_INPUT_COINS;
pub use wallet::vault_move::VaultMove;

Modules§

auth
Authentication + unlock authorization: the seam between the harness’s OS-native auth ceremony and dig-account’s custody logic.
chain_confirm
confirm_spendable_by_name — the second, disagreeing question every spend builder must ask about every coin it is about to spend.
constants
Values that MUST be identical everywhere this crate uses them.
edit
Editing a profile that already exists: read its published fields, change some, commit a new root.
error
The crate-wide error type and result alias.
id
Stable identifiers used across the account model.
keys
Per-profile key derivation: the wallet (money) key and the data-encryption key (DEK), both deterministically derived from the account master seed at a profile index.
melt
Deleting a profile: melting BOTH of its singletons in one bundle.
mint
The on-chain mint: build, sign, push, and PROVE.
model
The account object model, split into an OFFLINE half and an ONLINE half.
profile_mint
Minting a new profile: a DID + dig-store are launched on-chain and bound together into a ProfileAnchor, signed with the account seed’s key at the profile index.
profile_resolve
Resolving a profile’s dig-store from its DID — the reverse of the mint, by LINEAGE.
registry
The profile registry: the offline, always-readable record of which profiles an account has, which one is active, and which mints are half-finished.
reward_distributor_mint
RewardDistributorMinter — the facade that drives a reward-distributor mint (§6BB) through an unlocked account, so the raw money key never crosses the public API.
session
The LOCKED account handle: a sealed reference to an account that can be unlocked into a live UnlockedAccount through the harness-injected auth ceremony.
session_residency
Residency — the shared liveness token that makes lock() authoritative.
signer
The in-process IDENTITY signer: a dig_ipc_protocol::SessionSigner backed by a profile’s derived identity key.
store
Multi-account master-seed persistence — the registry the single-account dig-session facade lacks.
unlocked
The UNLOCKED account: holds the live master seed and hands out the per-profile capabilities (identity signer, wallet ops, DEKs) derived from it.
wallet
The money path: wallet ops, the ENFORCING spend-authorization gate, the money-signer seam, the two-tier custody policy, and the vault’s time-locked exit.