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
| Kind | Inputs after the prefix | Prefix begins | Source |
|---|---|---|---|
| Public, key-owned | the 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 PDA | program account id, seed | /LEE/v0.2/AccountId/PDA/ | AccountId::for_public_pda |
| Private, regular | nullifier public key, viewing public key | /LEE/v0.3/AccountId/Private/ | lee/state_machine/core/src/nullifier.rs |
| Private PDA | program account id, seed, nullifier public key, viewing public key | /LEE/v0.3/AccountId/PrivatePDA/ | AccountId::for_private_pda |
| Blinded address | account id, 32-byte factor | /LEE/v0.3/AccountId/Blinded/ | AccountId::blinded |
| System program | a 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 program | the image id’s eight u32 words, each as 4 little-endian bytes | /LEE/v0.3/AccountId/Shadow/ | AccountId::for_shadow_program |
| Immutable-program mirror | the 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
| Id | Value | Meaning |
|---|---|---|
NATIVE_TOKEN_PROGRAM_ID | 32 zero bytes | the native token |
PROGRAM_LOADER_ACCOUNT_ID | 32 bytes of 0xFE | the program loader |
SYSTEM_UPGRADER_ACCOUNT_ID | 32 bytes of 0xFD | system_upgrader, the owner every system program’s id derives from |
CLOCK_PROGRAM_ACCOUNT_ID | /LEZ/ClockProgramAccount/0000000 | the 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.
| Key | Derivation |
|---|---|
| seed | mnemonic.to_seed(passphrase), 64 bytes. The reference wallet uses an empty passphrase |
| public tree root secret | from the seed, keyed by a master domain string |
| public tree child secret | first32(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 key | derived per nonce from that secret, so the signing key rotates with use. See Keys and rotation |
private tree root ssk, ccc | HMAC-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, ccc | HMAC-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 |
ask | SHA256("/LEE-Keys/v1/Authorization/Secret" ‖ ssk ‖ index_be), where index is the node’s child index (0 at the root) |
nsk | SHA256("/LEE-Keys/v1/Nullifier/Secret" ‖ ask) |
npk | SHA256("/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 |
vpk | the 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):
| For | Derived from |
|---|---|
| a group-owned private PDA | the secret, the program’s image id, the seed |
| a shared regular account | the secret, a derivation seed |
The two use different domain prefixes. Every member derives the same keys, hence the same account ids.