Skip to main content

Crate dig_identity

Crate dig_identity 

Source
Expand description

§dig-identity — the canonical DIG decentralized-identity profile format

A DIG identity is an identity anchor (a Chia did:chia: singleton in v1) PAIRED with a chip35 DataLayer store that holds the anchor’s profile. The profile is a sparse merkle tree of standard SLOTS — one fixed 256-bit position per field — so any implementation reads and writes the same bytes, and any field can be proved (or proved absent) against a single 32-byte root.

The format core is CHAIN-INDEPENDENT (no chain calls, no chip35 dependency). WU3 adds on-chain DID resolution as a caller-supplied ChainSource TRAIT seam (resolve), so the crate still holds no network dependency and builds unchanged for wasm / no-network targets. The v2 BLS identity key model (bls, SPEC §6a) — the single BLS12-381 G1 key that does both sign (G2) and seal-DH (G1) — is behind the default-on bls feature, so the pure format layer still builds with default-features = false. The DID→dig-store minting driver (WU2) remains a follow-on.

§What lives here

ConcernModule
Slot ids, the v1 slot map, slot-key derivationslot
The tag ‖ len ‖ bytes value encodingvalue
sha256 primitives + the SMT node hasherhash
The mutable tree: set/get/root/provetree
Serializable proofs + root-only verificationproof
The profile reader/writer + key resolutionprofile / keys
The identity anchor (DID) + discovery parsedid
The canonical XCH receive-address field codecxch
The DID↔store bidirectional-pairing predicate + ownership proofpairing
Composed “this datum belongs to this DID” verificationverify
On-chain DID→profile resolution over a caller ChainSource (WU3)resolve
The BLS12-381 G1 identity key model: derivation + sign/seal primitives (§6a)bls
The fail-closed store-update-authority predicate (owner or valid delegate)authority

§Proving a field against a root

use dig_identity::{Profile, Value, slot::standard, proof};

let mut profile = Profile::with_schema_v2();
profile.set(standard::DISPLAY_NAME, Value::Utf8("Ada".into()));

let tree = profile.build_tree().unwrap();
let root = tree.root();

// Prove the display name equals "Ada" using only (root, proof).
let membership = tree.prove_membership(standard::DISPLAY_NAME).unwrap();
let claim = Value::Utf8("Ada".into());
assert!(proof::verify_membership(&root, standard::DISPLAY_NAME, &claim, &membership).unwrap());

// Prove no peer id is present.
let absent = tree.prove_non_membership(standard::PEER_ID).unwrap();
assert!(proof::verify_non_membership(&root, standard::PEER_ID, &absent).unwrap());

Re-exports§

pub use authority::DelegationKind;
pub use authority::StoreUpdateAuthority;
pub use authority::WriterDelegation;
pub use did::parse_did_from_description;
pub use did::Did;
pub use error::Error;
pub use error::Result;
pub use identity_profile::IdentityProfile;
pub use keys::DidKeys;
pub use pairing::evaluate_pairing;
pub use pairing::is_authoritative_profile;
pub use pairing::store_belongs_to_did;
pub use pairing::IdentitySingleton;
pub use pairing::PairingOutcome;
pub use pairing::SingletonLineage;
pub use pairing::StoreOwnershipProof;
pub use pairing::StoreRecord;
pub use profile::resolve_did_keys;
pub use profile::Profile;
pub use proof::verify_membership;
pub use proof::verify_non_membership;
pub use proof::ProfileProof;
pub use resolve::resolve_bls_public_key;
pub use resolve::resolve_identity_profile;
pub use resolve::ChainSource;
pub use resolve::ChainStoreState;
pub use resolve::ResolveError;
pub use bls::derive_identity_sk;
pub use bls::derive_identity_sk_at;
pub use bls::g1_dh;
pub use bls::g1_subgroup_check;
pub use bls::master_secret_key_from_seed;
pub use bls::public_key_bytes;
pub use bls::sign_message;
pub use bls::verify_signature;
pub use bls::IDENTITY_DERIVATION_PATH;
pub use slot::SlotId;
pub use tree::ProfileTree;
pub use value::Value;
pub use value::ValueTag;
pub use verify::verify_profile_field_absent_for_did;
pub use verify::verify_profile_field_for_did;
pub use xch::is_valid_xch_address;
pub use xch::parse_xch_address;

Modules§

authority
The UPDATE-AUTHORITY predicate for a profile’s DataLayer store — the fail-closed guard on the profile-update path (#1361 / #908).
bls
The BLS12-381 identity key model (SPEC §6a) — derivation + the sign/seal primitives.
did
The identity-anchor identifier (a DID) and how it is discovered from a store description.
error
The crate’s single error type.
hash
sha256 primitives shared by slot-key derivation, leaf-value hashing, and the SMT node hasher.
identity_profile
The IdentityProfile primitive — the managed DIG Network “Profile” object.
keys
The cryptographic-key view of a profile — the dig-message / dig-chat / dig-node resolution seam.
pairing
The DID<->store bidirectional-pairing predicate, as pure types over supplied Chia records.
profile
The Profile reader/writer — a slot map that materializes into a ProfileTree.
proof
The serializable proof blob and the root-only verification functions.
resolve
WU3 — on-chain DID resolution: from a did:chia: string to its chain-authenticated profile.
slot
Slot identifiers, the v1 standard slot map, and the deterministic slot-key derivation.
tree
The mutable profile tree: set/get slots, compute the root, and produce proofs.
value
The deterministic tag ‖ len ‖ bytes slot-value encoding.
verify
Composed “this profile datum belongs to this DID” verification — THE consumer seam.
xch
The canonical mainnet XCH receive-address profile field (slot 0x0008).

Structs§

Coin

Type Aliases§

Bytes32