Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Account-id derivations

All ids are 32 bytes. Each derived account id is the SHA-256 of an input that starts with a 32-byte domain prefix, so ids of different kinds do not collide.

Account ids

KindInputs after the prefixPrefix beginsSource
Public, key-ownedthe commitment to the account’s nonce-0 key, double hashed with a per-key-type prefix/LEE/v0.3/AccountId/Public/AccountId::for_initial_key. The key can change at every nonce; the id commits only to the first. See Keys, nonces and rotation
Public PDAprogram account id, seed/LEE/v0.2/AccountId/PDA/AccountId::for_public_pda
Private, regularnullifier public key, viewing public key/LEE/v0.3/AccountId/Private/lee/state_machine/core/src/nullifier.rs
Private PDAprogram account id, seed, nullifier public key, viewing public key/LEE/v0.3/AccountId/PrivatePDA/AccountId::for_private_pda
Blinded addressaccount id, 32-byte factor/LEE/v0.3/AccountId/Blinded/AccountId::blinded
System programa public PDA of system_upgrader, whose seed hashes the name, padded to 32 bytes, after /LEE/SystemUpgrader/v1/Name/LEE/v0.2/AccountId/PDA/AccountId::from_system_program_name, PdaSeed::for_system_program
Shadow programthe image id’s eight u32 words, each as 4 little-endian bytes/LEE/v0.3/AccountId/Shadow/AccountId::for_shadow_program
Immutable-program mirrorthe program header’s account id/LEE/v0.3/AccountId/ImmutMirror/AccountId::for_immutable_mirror

The functions without a file are in lee/state_machine/core/src/program/mod.rs, except AccountId::for_initial_key, which is in lee/state_machine/core/src/account.rs.

Fixed ids

IdValueMeaning
NATIVE_TOKEN_PROGRAM_ID32 zero bytesthe native token
PROGRAM_LOADER_ACCOUNT_ID32 bytes of 0xFEthe program loader
SYSTEM_UPGRADER_ACCOUNT_ID32 bytes of 0xFDsystem_upgrader, the owner every system program’s id derives from
CLOCK_PROGRAM_ACCOUNT_ID/LEZ/ClockProgramAccount/0000000the account the clock’s actor lives on, not the clock program’s id, which derives from its name. One account; a read picks its own granularity

What follows from the derivations

  • A public PDA is the same for everyone: program and seed fix it.
  • A private PDA is per key holder: two groups using the same program and seed get different accounts, because their keys differ.
  • A blinded address is per factor. One account has as many addresses as its owner cares to make, and without the factors nobody can tell from the addresses that they name the same account.
  • A program deployed twice has two ids, so two disjoint PDA families.

Keys

One mnemonic feeds two trees that share only the BIP-39 seed. Both are hardened-only.

KeyDerivation
seedmnemonic.to_seed(passphrase), 64 bytes. The reference wallet uses an empty passphrase
public tree root secretfrom the seed, keyed by a master domain string
public tree child secretfirst32(HMAC-SHA512("/LEE-Keys/v1/Child/Public" ‖ index_be) keyed by the parent secret). Hardened only, and there is no chain code: the parent secret is the HMAC key
a public account’s keyderived per nonce from that secret, so the signing key rotates with use. See Keys and rotation
private tree root ssk, cccHMAC-SHA512 keyed "/LEE-Keys/v1/Master/Private" over the seed, split in two: ssk the first 32 bytes, chain code ccc the last 32
private tree child ssk, cccHMAC-SHA512("/LEE-Keys/v1/Seed/Private" ‖ SHA256("/LEE-Keys/v1/Parent/Private" ‖ nsk ‖ d ‖ z) ‖ index_be) keyed by the parent’s ccc, split the same way. nsk, d, z are the parent’s
askSHA256("/LEE-Keys/v1/Authorization/Secret" ‖ ssk ‖ index_be), where index is the node’s child index (0 at the root)
nskSHA256("/LEE-Keys/v1/Nullifier/Secret" ‖ ask)
npkSHA256("/LEE-Keys/v1/Nullifier/Public" ‖ nsk)
vsk = (d, z)HMAC-SHA512("/LEE-Keys/v1/Viewing/Secret" ‖ ssk ‖ index_be) keyed "/LEE-Keys/v1/Viewing/Seed", split in two
vpkthe ML-KEM-768 encapsulation key from seed (d, z)

A standalone KeyChain (KeyChain::new_mnemonic or KeyChain::new_os_random) derives its ssk as first32 of HMAC-SHA512 keyed "LEE_seed" iterated 2048 times over the seed; the wallet’s trees do not use it. Sources: lee/key_protocol/src/key_management/secret_holders.rs, lee/key_protocol/src/key_management/key_tree/keys_private.rs, lee/key_protocol/src/key_management/key_tree/keys_public.rs.

Group keys

A group secret derives keys for shared accounts (lee/key_protocol/src/key_management/group_key_holder.rs):

ForDerived from
a group-owned private PDAthe secret, the program’s image id, the seed
a shared regular accountthe secret, a derivation seed

The two use different domain prefixes. Every member derives the same keys, hence the same account ids.