DidKeyGenerator
Generates W3C did:key identifiers from P-256 public keys.
The DID is derived from the root passkey's P-256 public key — one DID per user, stable across all Midnight dApps. This is the sigil's identity facet.
Format: did:key:z<base58btc(varint(0x1200) || compressed_P256_pubkey)>
Where:
0x1200is the multicodec identifier for P-256 public keysvarint encoding of
0x1200=[0x80, 0x24]compressed P-256 public key = 33 bytes (0x02/0x03 prefix + 32-byte x coordinate)
base58btc = Bitcoin-style base58 encoding (multibase prefix
z)
References:
did:key spec: https://w3c-ccg.github.io/did-method-key/
Multicodec table: https://github.com/multiformats/multicodec
Multibase: https://github.com/multiformats/multibase
Functions
Compresses a P-256 public key from x/y coordinates.
Generates a did:key from a compressed P-256 public key.
Generates a did:key from a Java ECPublicKey (P-256).
Generates a did:key from a 32-byte Ed25519 public key.
Generates a did:key from uncompressed P-256 x/y coordinates.
True when did uses the legacy P-256 multicodec encoding.
Extracts the compressed P-256 public key from a did:key string.