0x02 Addresses, AuthRegistry & Wallet KDF
TL;DR: Keep
types.Addressat exact 20 bytes (z1...Bech32) so all 12 embedded contracts, ABI words,AccountHeaders (60 B), and storage keys remain 100% unchanged. Introduce user class byte0x02(z1p.../z1r...under HRP"z") for fresh post-quantum accounts, deploy a13thembedded contractAuthRegistryContract(0x01...) so existing0x00addresses with lockedStake,Pillar, orSentinelstate can rotate to a PQ key in place, and derive all PQ keys deterministically from existing 24-wordBIP-39seeds.
1. Preserving the 20-Byte types.Address Invariant
In go-zenon-v1/internal/types/address.go:11-28, Address is a [20]byte value type permeated throughout consensus:
- Every ABI
"address"parameter across all 12 embedded contracts (internal/codec/abi/) unpacks into[20]byte. types.AccountHeader(internal/types/account_header.go) is a fixed60-bytetupleAddress[20] || Hash[32] || Height[8]sorted lexicographically insideMomentum.Content.AccountBlock.ComputeHash()(internal/nom/account_block.go:152-153) placesAddressat bytes104..124andToAddressat124..144of the fixed306-bytepreimage.
Changing AddressSize from 20 to 32 bytes would fork every ABI selector, storage key (ProducingPillarNameKey, DelegationInfoKey, etc.), RPC payload, and AccountBlock hash preimage. Instead, Zenon's existing class byte addr[0] cleanly namespaces post-quantum accounts within the exact 20-byte envelope:
addr[0] | Constant Name | Bech32 Prefix (HRP = "z") | Meaning & Payable Status |
|---|---|---|---|
0x00 | UserAddrByte | z1q... | Legacy Ed25519 user address (may bind a PQ key in AuthRegistry) |
0x01 | ContractAddrByte | z1qxemdedded... | Canonical Embedded Contract address |
0x02 | PQUserAddrByte | z1z... / z1y... | Native Post-Quantum user address (algID ∈ {0x01, 0x02, 0x03, 0x81}) |
internal/types/address.go & ptlc.go- Update
(a Address) IsUserAddress() bool(address.go:197) froma[0] == UserAddrByteto:a[0] == UserAddrByte || (pqSporkActive && a[0] == PQUserAddrByte). - Update
ptlc.IsPayableDestination(addr)(internal/vm/contracts/ptlc/ptlc.go:289) to accept both0x00(if not sunset) and0x02user addresses.
2. Canonical 0x02 Address Derivation Formula
To prevent cross-algorithm preimage collisions, a 0x02 address hashes a domain-separated tag, the 1-byte algID, and the exact canonical public key encoding:
DomainTag = "zenon-pq-addr:v1" // 16 ASCII bytes
Preimage = DomainTag || [algID] || pqPubKey // 17 + len(pqPubKey) bytes
Digest = FIPS202_SHA3_256(Preimage) // 32 bytes
Address[0] = 0x02
Address[1:] = Digest[0:19] // 19 bytes (152 bits)
algID | Scheme | len(pqPubKey) | Exact Preimage Length | Allowed on 0x02 Address? |
|---|---|---|---|---|
0x01 | ML-DSA-44 | 1,312 B | 1,329 B | Yes |
0x02 | FN-DSA-512 | 897 B | 914 B | Yes (post-Phase 2) |
0x03 | SLH-DSA-SHAKE-128s | 32 B | 49 B | Yes |
0x81 | Hybrid Ed25519 + ML-DSA-44 | 32 + 1,312 = 1,344 B | 1,361 B | Yes |
- Bech32 vs. Bech32m Encoding:
internal/types/address.go:175(ParseAddress) already accepts both BIP-173 Bech32 and BIP-350 Bech32m, whileString()emits canonical 40-character lowercase Bech32 (z1...) for full backwards compatibility with existing explorers and RPC clients.
3. In-Place Key Rotation via AuthRegistryContract
Why Sending Funds to a New Address Is Insufficient on Zenon
On Zenon Alphanet, four embedded contracts lock high-value state to an immutable types.Address that cannot be transferred via UserSend:
PillarContract(internal/vm/contracts/pillar/pillar.go:220):UpdatePillarrotatesBlockProducingAddressandRewardWithdrawAddress, but NEVERStakeAddress(15,000 ZNNlocked; revoking destroys the Pillar slot permanently!).StakeContract(internal/vm/contracts/stake/stake.go): Time-locked ZNN stakes (1to12months) can only be cancelled afterexpirationTimeby the originalAddress.SentinelContract(5,000 ZNN + 50,000 QSR): Bound to the registeringAddress.LiquidityContract& Governance (SporkAddress,BridgeInfo.Administrator): Bound to0x00addresses.
AuthRegistryContract Specification
Deploy AuthRegistryContract (0x01 embedded class address z1qxemdeddedxauthregystryxxxxxxxxxx...) gated by PostQuantumAccountsSpork:
[
{"type":"function","name":"RotateKey","inputs":[
{"name":"algId","type":"uint8"},
{"name":"newPublicKey","type":"bytes"},
{"name":"newKeyPopSignature","type":"bytes"},
{"name":"revokeLegacy","type":"bool"}
]},
{"type":"function","name":"RescueWithPoKoS","inputs":[
{"name":"targetAddress","type":"address"},
{"name":"algId","type":"uint8"},
{"name":"newPublicKey","type":"bytes"},
{"name":"starkProof","type":"bytes"}
]},
{"type":"variable","name":"authRecord","inputs":[
{"name":"algId","type":"uint8"},
{"name":"publicKeyHash","type":"hash"},
{"name":"publicKey","type":"bytes"},
{"name":"legacyRevoked","type":"bool"},
{"name":"updatedHeight","type":"uint64"}
]}
]
Storage Layout Inside AuthRegistryContract ([0x04] Contract State)
- Key:
[0x01] || userAddr[20](21 bytes) → ABI-packedauthRecord. - Proof of Possession (
newKeyPopSignature): Prevents a user from bricking their account by accidentally registering a corruptednewPublicKeyfor which they do not hold the secret key.newKeyPopSignatureMUST verify under(algId, newPublicKey)over the 61-byte domain-separated digest:SHA3-256("zenon-auth-rotate:v1" || be_u64(chainId) || sendBlock.Address[20] || be_u64(sendBlock.Height) || [algId]). - Immediate Legacy Lockout (
revokeLegacy = true): OnceAuthRegistryContractexecutesReceiveBlock,legacyRevokedbecomestrue. From the next Momentum onward,accountBlockVerifier.signaturerejectsEd25519(algID = 0x00) onuserAddr—even before the Phase 3 network-wide sunset! - Zero-Exposure First Tx for Untouched
0x00Accounts: During Phase 1–2, an untouched0x00account (Height = 1) whose first block is aUserSend(orUserReceivefollowed immediately in the same Momentum byRotateKey) only exposes itsEd25519key for a single 10-second slot beforelegacyRevoked = truepermanently locks out Shor attacks.
4. Deterministic BIP-39 Key Derivation (Zero New Seed Phrases)
Zenon wallets (syrius, znn_cli_dart, go-zenon-v1/internal/crypto/slip0010.go) currently derive Ed25519 keys from a 24-word BIP-39 mnemonic (64-byte PBKDF2-HMAC-SHA512 seed) along:
Classical Path: m / 44' / 73404' / <accountIndex>' (HMAC-SHA512 key = "ed25519 seed")
To guarantee strict cryptographic domain separation (so compromising a classical SLIP-0010 child key or chain code leaks zero bits about any post-quantum key, even to an unbounded quantum adversary), post-quantum keys MUST use a dedicated master HMAC domain tag and purpose subtree:
Master Node: HMAC-SHA512(Key = "zenon-pq-slip0010:v1", Data = bip39Seed64)
Derivation: m / 44' / 73404' / 1' / <algId>' / <accountIndex>'
algId' Segment | Target Scheme | Seed Extraction from 32-Byte Leaf SLIP0010Key.Key |
|---|---|---|
1' (0x80000001) | ML-DSA-44 | Pass leaf.Key[0:32] directly to mldsa.NewPrivateKey(mldsa.MLDSA44(), leaf.Key[:]) |
2' (0x80000002) | FN-DSA-512 | Expand SHAKE256("zenon-fndsa512-keygen:v1" || leaf.Key[:], 64) into deterministic fixed-point FIPS 206 keygen |
3' (0x80000003) | SLH-DSA-SHAKE-128s | Expand SHAKE256("zenon-slhdsa128s-keygen:v1" || leaf.Key[:], 48) → (SK.seed[16], SK.prf[16], PK.seed[16]) |
Because all three post-quantum tiers derive deterministically from the exact same bip39Seed64, existing Syrius users do not need to write down a new 24-word recovery phrase. Restoring their existing mnemonic in a PQ-upgraded Syrius wallet automatically recovers both their legacy 0x00 accounts and their 0x02 / AuthRegistry-rotated PQ accounts!