Skip to main content

0x02 PQ Addresses (z1q{2,f,g,t}), AuthRegistryContract (#14), 179B PoP & Wallet KDF

60-Second TL;DR (ZNN-SPEC-PHASE1-v4): Keep types.Address at exact 20 bytes (z1q... 40-char Bech32) so all embedded contracts, ABI words, AccountHeaders (60 B), smt-v1 storage keys, and third-party exchange ^z1q regexes remain 100% compatible! Introduce user class byte 0x02 (PQUserAddrByte, encoding deterministically as z1q2... / z1qf... / z1qg... / z1qt... — N02 fix), enforce an explicit {0x00, 0x02} sender class allowlist (M12 fix), add optional PrecommitKey for 256-bit cold-vault binding (B05 fix), upgrade AuthRegistryContract (#14) with explicit expectedRotationNonce + ErrAuthNonceOverflow + 179-byte GenesisHash-bound Proof-of-Possession (B03, M06 fix) evaluated at InclusionMomentumHeight (R4-03 fix), and derive PQ keys cleanly using Go 1.27+ crypto/mldsa and 32-byte fn-dsa v0.3 seeds (B01, M05, R4-09 fix).


1. Preserving the 20-Byte types.Address Invariant, Bech32 Prefixes (N02) & Class Allowlist (M12)​

In go-zenon-v1/internal/types/address.go:11-28, Address is a [20]byte value type encoded in BIP-173 Bech32 with HRP = "z" (40 characters total).

Exact 8-to-5 Bit Bech32 Prefix Table (N02 Verified)​

In Bech32 (CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"), the first 5-bit data symbol encodes the top 5 bits of addr[0], and the second 5-bit symbol encodes ((addr[0] & 0x07) << 2) | (addr[1] >> 6):

addr[0]Constant NameExact Bech32 Prefix SetSender Class Rule (M12 Fix)
0x00UserAddrBytez1qp..., z1qq..., z1qr..., z1qz...Valid user sender (legacy 0x00 sigs disabled at Spork #14; rotated AuthRegistry PQ accounts remain valid forever!)
0x01ContractAddrBytez1q8..., z1q9..., z1qx..., z1qy...Canonical Embedded Contract address (#1..#12 Phase 0, #13 Settlement, #14 AuthRegistry, #15 Channel)
0x02PQUserAddrBytez1q2..., z1qf..., z1qg..., z1qt...Native Post-Quantum user address (enabled at Spork #10; algID in {0x01, 0x02, 0x03}, plus 0x81 pre-sunset)
0x03..0xffUnassigned(Reserved for future eras)Rejected fail-closed as AccountBlock.Address (ErrABUnsupportedAddressClass, M12 fix)!
Why 0x02 (z1q{2,f,g,t}...) Is Superior to Changing the 3rd Character (z1z...)
  1. 100% Zero-Friction CEX & SDK Compatibility: Both official SDKs (znn_sdk_dart Address.isValid) and third-party exchange/explorer ^z1q[a-z0-9]{37}$ regexes accept 0x02 withdrawals on Day 1!
  2. No Misleading UX Dichotomy: Rotated 0x00 Pillars, time-locked Stakes, and PoKoS-rescued wallets retain their z1q{p,q,r,z}... addresses after upgrading to ML-DSA-44 / FN-DSA-512—so wallets indicate quantum safety via an explicit on-chain auth badge rather than address prefix heuristics, while engineers can still distinguish native 0x02 addresses immediately by character #4 ({2, f, g, t}).

2. Canonical 0x02 Derivation, Golden Go 1.27 Vector (N02) & 152-Bit vs. 256-Bit Binding (B05, R4-06)​

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)

Canonical Golden Go 1.27+ ML-DSA-44 (0x01) Test Vectors (N02, R4-01 Verified)​

32-byte Seed (hex) : 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20
Go 1.27 Call : sk, _ := mldsa.NewPrivateKey(mldsa.MLDSA44(), seed[:])
len(pk.Bytes()) : 1312 bytes
SHA3-256(pk.Bytes()) : 941049da6dbfb141f770f075f7968f243cd4533e9719f121be0eb7c5f8ee7645
Derived 20B Address (hex) : 0208953cfda6d999d2a6c636a4a0b1cfb1c7fdea
Canonical Bech32 Address : z1qgyf208a5mven54xccm2fg93e7cu0l022alugr
Low-Level Sig KAT : sk.SignDeterministic([]byte("zenon-v3-kat"), &mldsa.Options{Context: "zenon-ab:v2"})
SHA3-256(lowLevelSig) : 621b16f8e3e2c7c064aec7ab540f1f64b1d1665feef964f07c6cded92d99f33b
v4 Bound Transcript Digest : f79b6f58918590a542c285d49fec08cde4ca1abc4d47ccb77b78b078569e542f // over SHA3-256("zenon-v4-bound-ab-kat")
SHA3-256(boundSig[2420]) : b7444ca31c5c802bd2cdc7f3fd5c76d1e2bce8655bfd44dd96a099e26c8608cf

Honest Security Profile of 152-Bit First Binding & PrecommitKey Upgrade (B05, R4-06 Fix)​

  • Before First Spend (Height == 0, Unregistered): Only the 19-byte (152-bit) digest is committed on-chain.
    • Ideal Unbounded-Depth Quantum Model: ~2^76 single-target Grover queries (2^((152 - u)/2) multi-target across 2^u untouched funded addresses).
    • NIST MAXDEPTH = 2^64 Bounded-Depth Model (Zalka's Theorem [E6], R4-06 Corrected): For oracle circuit depth D_circ = 2^d (d ≈ 12 for ML-DSA keygen + SHA3-256), each processor runs K = 2^(64 - d) = 2^52 Grover iterations covering K^2 = 2^104 states, requiring M = 2^152 / K^2 = 2^48 parallel quantum processors and W = M * K = 2^152 / K = 2^100 total oracle calls (> 2^112 logical quantum gates) (M = 2^24 parallel runs and W = 2^88 calls in the idealized d = 0 limit).
  • After First Spend (Height >= 1) OR PrecommitKey Registration (Height == 0 Cold Vaults): Full 32-byte (256-bit) SHA3-256([algId] || pqPubKey) is locked in authenticated smt-v1 state (2^128 ideal Grover). High-value cold vaults wanting 256-bit binding before ever emitting Height = 1 call AuthRegistry.PrecommitKey (from any feeless sponsor/funder account pre-CRQC) to bind their full pqPubKey into AuthRegistry (#14) at funding time!

3. AuthRegistryContract (#14) v4 ABI, 179-Byte PoP & Dual-Ledger Races (B03, B05, M06, R4-03 Fix)​

3.1 AuthRegistryContract (#14) ABI​

[
{"type":"function","name":"RotateKey","inputs":[
{"name":"algId","type":"uint8"},
{"name":"expectedRotationNonce","type":"uint64"},
{"name":"newPublicKey","type":"bytes"},
{"name":"newKeyPopSignature","type":"bytes"}
]},
{"type":"function","name":"RescueWithPoKoS","inputs":[
{"name":"targetAddress","type":"address"},
{"name":"algId","type":"uint8"},
{"name":"newPublicKey","type":"bytes"},
{"name":"newKeyPopSignature","type":"bytes"}
]},
{"type":"function","name":"PrecommitKey","inputs":[
{"name":"targetAddress","type":"address"},
{"name":"algId","type":"uint8"},
{"name":"newPublicKey","type":"bytes"},
{"name":"newKeyPopSignature","type":"bytes"}
]},
{"type":"function","name":"UpgradeHybridToPureMLDSA44","inputs":[
{"name":"expectedRotationNonce","type":"uint64"},
{"name":"newKeyPopSignature","type":"bytes"}
]}
]
  • PrecommitKey Guard (B05): Requires targetAddress[0] == 0x02, AccountStore(targetAddress).Height == 0, activePubKeyHash == 0, pendingEffectiveHeight == 0, DerivePQAddress(algId, newPublicKey) == targetAddress (preventing unauthorized griefing/bricking of third-party addresses!), and a valid 179-byte newKeyPopSignature (opByte = 0x03).
  • Overflow Guard: RotateKey and UpgradeHybridToPureMLDSA44 require authState.rotationNonce < math.MaxUint64 (ErrAuthNonceOverflow), never wrapping to 0.

3.2 Exact 179-Byte GenesisHash- & Generation-Bound PoP Preimage (M06 Fix)​

To prevent cross-network replay (e.g., devnets sharing ChainIdentifier = 1), cross-role confusion, or competing-generation races (B03), AuthRegistryContract reconstructs the exact 179-byte popPreimage:

popPreimage (exact 179 bytes):
Bytes 0..17 : "zenon-auth-pop:v3" // 17 ASCII bytes
Bytes 17..25 : be_u64(ChainIdentifier) // 8 bytes (1 on Alphanet)
Bytes 25..57 : GenesisMomentumHash[32] // 32 bytes (prevents same-ChainId fork replay!)
Byte 57 : opByte // 1 byte (0x01=Rotate, 0x02=PoKoS, 0x03=Precommit, 0x04=HybridStrip)
Bytes 58..78 : targetAddress[20] // 20 bytes
Bytes 78..98 : senderBlock.Address[20] // 20 bytes (binds sponsor/relayer!)
Bytes 98..106 : be_u64(senderBlock.Height) // 8 bytes (prevents intra-account replay)
Bytes 106..114 : be_u64(expectedRotationNonce) // 8 bytes (MUST equal authState.rotationNonce!)
Bytes 114..146 : prevActivePubKeyHash[32] // 32 bytes ([32]byte{0} on first registration)
Byte 146 : algId // 1 byte in {0x01, 0x02, 0x03, 0x81*}
Bytes 147..179 : SHA3_256(newPublicKey)[32] // 32 bytes
-------------------------------------------------------------------------
Exact Sum: 17 + 8 + 32 + 1 + 20 + 20 + 8 + 8 + 32 + 1 + 32 = 179 bytes!

popDigest = FIPS202_SHA3_256(popPreimage) // 32 bytes

3.3 Dual-Ledger Send -> Receive Generation Semantics & H_inc + 1 Promotion (B03, R4-03 Fix)​

  1. Preserving User-Stripe Isolation + Clean rollbackEmbedded on Competing Sends (B03, R4-03):
    • User UserSend blocks remain 100% isolated to the sender's own AccountStore (ApplySend validates stateless ABI packing only, preserving parallel Stage 3a user stripes!).
    • Suppose an old key emits two RotateKey UserSend blocks S_1 (expectedRotationNonce = 0) and S_2 (expectedRotationNonce = 0) before AuthRegistry executes ContractReceive(S_1).
    • ContractReceive(S_1) executes against ctx.InclusionMomentumStore() at H_confirm = ctx.InclusionHeight() (NOT receiveBlock.MomentumAcknowledged R4-03!), sets pendingEffectiveHeight = H_confirm + 1, and immediately increments authState.rotationNonce from 0 to 1.
    • When ContractReceive(S_2) executes, S_2.expectedRotationNonce (0) != authState.rotationNonce (1)—returning ErrAuthStaleGeneration, which GenerateEmbeddedReceive (vm.go:568-578) cleanly rolls back (Data = be_u64(2)) after advancing the FIFO sequencer cursor without stalling AuthRegistry's mailbox!
  2. Phase 1A (10s v3) vs. Phase 1B (1s v4) In-Flight Window (B03, B09 Honesty):
    • In Phase 1A (LegacyDposV1), ContractReceive(S_1) is produced asynchronously in the next slot (~10–20 s total window); in Phase 1B (Momentum v4 Algorithm 1 Step 3b), ContractReceive(S_1) executes deterministically in the same Momentum H_confirm (1.0 s promotion at H_confirm + 1). Rotation is strictly a pre-CRQC proactive migration mechanism, never a post-compromise undo button.

4. Wallet Key Derivation (Go 1.27+), Seed Classes & Independent Seed Option (B01, M05, R4-09 Fix)​

Master Node: HMAC-SHA512(Key = "zenon-pq-slip0010:v1", Data = bip39Seed64)
Derivation: m / 44' / 73404' / 1' / <algId>' / <accountIndex>'
  • Computational PRF Isolation & Wallet Cohort Coverage (M05 Fix):
    1. HMAC-SHA512 provides computational PRF domain separation between classical SLIP-0010 and PQ subtrees (not information-theoretic secrecy if bip39Seed64 itself is physically stolen!). Wallets (Syrius, znn-cli) MUST offer both deterministic derivation from an existing 12/24-word BIP-39 mnemonic (with or without 25th-word passphrase, including go-zenon Argon2id-encrypted KeyFiles wallet/keystore.go:29) and rotating to a freshly generated independent 256-bit entropy seed (mandatory whenever root mnemonic exposure is suspected).
    2. Hardware wallets or CLI users holding standalone imported keys without BIP-39 rotate directly to a fresh PQ seed via RotateKey (and any standard 32-byte RFC 8032 seed remains eligible for RescueWithPoKoS—see Ed25519-PoKoS Rescue).
algId' SegmentTarget SchemeExact Go 1.27+ / Reference Extraction from 32-Byte leaf.Key[0:32] (B01, R4-09 Verified)
1' (0x80000001)ML-DSA-44mldsa.NewPrivateKey(mldsa.MLDSA44(), leaf.Key[0:32]) (Go 1.27+ stdlib crypto/mldsa)
2' (0x80000002)FN-DSA-512SHA3_256("zenon-fndsa512-keygen:v1" || leaf.Key[0:32]) (32 B seed -> pinned fn-dsa v0.3 keygen R4-09)
3' (0x80000003)SLH-DSA-SHAKE-128sSHAKE256("zenon-slhdsa128s-keygen:v1" || leaf.Key[0:32], 48) -> FIPS 205 (SK.seed, SK.prf, PK.seed)