fix(core): wire-format reset — BLAKE3 block hash, PQTX domain prefix, 16-byte AA domains, 32-byte address wire#54
Merged
Conversation
… 16-byte AA domains, 32-byte address wire - BlockHeader::hash() now uses blake3(canonical_encode(header)) instead of keccak256(rlp(header)); canonical_encode() produces a fixed 424-byte deterministic preimage (16B domain + 11×32B fields + 7×8B u64 fields) - Transaction::signing_hash() preimage now starts with PQTX_SIGNING_V1\0 (16B) domain prefix per WP §1503-1509; shell-sdk golden vector updated accordingly - AaBundle signing domains upgraded from 1-byte to 16-byte strings: PQTX_BUNDLE_V1\0\0, PQTX_PAYMASTER_V, PQTX_SESSION_V1\0 - SessionAuth::auth_hash() None target now pads to 32 bytes (was 20) - InnerCall, Transaction.to, AaBundle.paymaster, SessionAuth.target decoders no longer accept 20-byte address fallback; only 32-byte or empty accepted - Remove legacy 1-byte BATCH/PAYMASTER/SESSION_AUTH_HASH_DOMAIN constants - Add header_canonical_encode_len() test (asserts 424-byte output) - cargo fmt cleanup on Phase 1 consensus files Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Stages Phase 2 whitepaper-alignment breaking wire-format changes by switching block hashing to a BLAKE3 canonical encoding, introducing PQTX/AA 16-byte domain prefixes for signing hashes, and enforcing 32-byte addresses on the wire (removing 20-byte decode fallbacks). This affects core hashing/signing primitives and transaction/session/bundle decoding behavior, with small follow-up adjustments in node/consensus code and test vectors.
Changes:
- Switch
BlockHeader::hash()toblake3(canonical_encode(header))with a fixed-width (424B) canonical preimage. - Add PQTX domain prefixing for transaction signing + move AA signing domains to 16-byte tags; update golden vectors accordingly.
- Enforce 32-byte addresses in decode paths for
Transaction,InnerCall,AaBundle, andSessionAuth(reject legacy 20-byte inputs).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/core/src/block.rs | Introduces canonical 424-byte block-header encoding and updates block hash to BLAKE3 over that encoding; adds length test. |
| crates/core/src/transaction.rs | Adds PQTX signing domain prefix, upgrades AA signing domains to 16 bytes, and removes 20-byte address decode fallbacks across multiple wire decoders. |
| crates/core/src/lib.rs | Re-exports new PQTX/AA domain constants from the core crate root and removes legacy u8 domain exports. |
| crates/core/tests/sdk_vectors.rs | Updates SDK golden vector to match the new PQTX signing preimage domain prefix. |
| crates/node/src/node/event_loop.rs | Avoids cloning the finalized hash by copying the ShellHash value directly. |
| crates/node/src/node/p2p_handlers.rs | Formatting-only change around attestation signing message construction. |
| crates/consensus/src/wpoa.rs | Adjusts imports and formats test calls (no functional behavior change intended). |
| crates/consensus/src/view_change.rs | Formatting-only change for own_signing_message() call site. |
| crates/consensus/src/finality.rs | Formats test helper + attestation signing message calls (no functional behavior change intended). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let mut buf = Vec::new(); | ||
| self.encode(&mut buf); | ||
| shell_primitives::keccak256(&buf) | ||
| shell_primitives::blake3_hash(&self.canonical_encode()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of the white-paper alignment plan. Stages breaking wire-format changes ahead of the single testnet restart after Phase 5.
Changes
1. Block hash → BLAKE3 canonical encoding (WP §1489-1499)
BlockHeader::hash()now returnsblake3(canonical_encode(header))instead ofkeccak256(rlp(header))canonical_encode()produces a fixed 424-byte deterministic preimage:SHELL_BLOCK_HDR\0header_canonical_encode_len()test asserting exactly 424 bytes2. PQTX signing envelope domain prefix (WP §1503-1509)
Transaction::signing_hash()preimage now starts withPQTX_SIGNING_V1\0(16 bytes)0xf5a1…0836→0x68ee…4761shell-sdk'shashTransaction()must be updated to prepend the same 16-byte domain3. 16-byte AA signing domains
Upgraded from 1-byte to 16-byte domain strings across all AA signing paths:
batch_signing_hash()0x7EPQTX_BUNDLE_V1\0\0paymaster_signing_hash()0x7FPQTX_PAYMASTER_VSessionAuth::auth_hash()0x81PQTX_SESSION_V1\0BATCH_SIGNING_HASH_DOMAIN,PAYMASTER_SIGNING_HASH_DOMAIN,SESSION_AUTH_HASH_DOMAINu8 constantsshell-corecrate root4. 32-byte address enforcement on wire (remove 20-byte decode fallbacks)
InnerCall::decode()— rejects 20-bytetoaddress; only 32-byte or empty acceptedTransaction::decode()— rejects 20-bytetoaddressAaBundle::decode()— rejects 20-bytepaymasteraddressSessionAuth::decode()— rejects 20-bytetargetaddressSessionAuth::auth_hash()—Nonetarget now pads to[0u8; 32](was[0u8; 20])Test results
Downstream impact
hashTransaction()must prependPQTX_SIGNING_V1\0(16 bytes) beforechain_id