Skip to main content

Module did_key

Module did_key 

Source
Expand description

Shared did:key (Ed25519) ⇄ raw-key codec.

This is the single source of truth for the ed25519-pub multicodec prefix, the base58btc multibase encoding, and DID-URL fragment/query stripping used to convert between a raw 32-byte Ed25519 public key and its did:key:z6Mk… / Multikey publicKeyMultibase forms.

It is compiled on all targets (unlike did:web resolution, which is native-only, and iroh_peer, which is wasm32-only) precisely so the native did:web admission resolver and the wasm32 iroh_peer browser identity helpers share one implementation and can never drift (#281/#475). hyprstream_rpc::did_web re-exports decode_ed25519_multikey, did_key_to_ed25519, and ed25519_to_did_key for source compatibility with existing callers.

This module is the single canonical home for the multicodec constants (MULTICODEC_ED25519_PUB, MULTICODEC_ML_DSA_65_PUB) and the generic decode_multikey helper (#916); previously these were duplicated in hyprstream::auth::mesh_trust and hyprstream-rpc’s service_entry.

Constants§

MULTICODEC_ED25519_PUB
Multicodec ed25519-pub unsigned-varint prefix (0xed01 → bytes 0xed 0x01).
MULTICODEC_ML_DSA_65_PUB
Multicodec ml-dsa-65-pub unsigned-varint prefix (0x1211 → bytes 0x91 0x24).

Functions§

decode_ed25519_multikey
Decode a Multikey publicKeyMultibase string into raw Ed25519 key bytes.
decode_multikey
Decode a Multikey publicKeyMultibase string into raw key bytes, verifying the base58btc multibase prefix (z) and the expected multicodec header.
did_key_to_ed25519
Decode a did:key (Ed25519) identifier into its raw 32-byte Ed25519 key.
ed25519_to_did_key
Encode a raw 32-byte Ed25519 public key as a did:key (Ed25519) identifier (did:key:z6Mk…).