PoW+PoS hybrid consensus, post-quantum crypto (ML-DSA-87 + ML-KEM-1024), and a real CLI wallet#6
Open
devnull37 wants to merge 10 commits into
Open
PoW+PoS hybrid consensus, post-quantum crypto (ML-DSA-87 + ML-KEM-1024), and a real CLI wallet#6devnull37 wants to merge 10 commits into
devnull37 wants to merge 10 commits into
Conversation
…ests to test. ill build later
Introduce detailed agent specifications for blockchain integration testing and Rust unit test writing in the .claude/agents directory. Add CLAUDE.md with project and development guidance, and update Cargo.toml files and node/pallets for new consensus and testing features, including miner module and consensus pallet enhancements.
…eights Block authoring is real Proof-of-Work via sc-consensus-pow (double-Blake2-256 over pre_hash||nonce, U256 difficulty, on-chain retargeting); Aura/GRANDPA removed from node and runtime. pallet-ghost-consensus is the PoS economic layer (staking, stake-weighted selection, 40/60 miner/staker reward split, evidence-gated slash-and-burn, validation-timeout recovery). Post-quantum: on-chain ML-DSA-87 (Dilithium-5, FIPS 204) signature verification in the no_std Wasm runtime; node-side ML-KEM-1024 (FIPS 203) + ChaCha20-Poly1305 payload encryption module. Hardening this round: - Replay guard on verify_pq_signature (rejects duplicate attestations) - No-staker block finality is now immediate (was validation-timeout-only) - mine CLI demo uses the node's real PoW work function (single source of truth); CLI --difficulty now matches the chain's conventional convention - Real operation-grounded weights (weights.rs SubstrateWeight<Runtime>: DbWeight reads/writes + ~300us ML-DSA verify charge) wired into the runtime, replacing the () placeholder - [profile.dev] debug=false to avoid MSVC LNK1318 (PDB size limit) on the bin Verified: 37 pallet tests + 20 node tests pass; node boots and mines blocks #1->#20 via sc-consensus-pow with all of the above compiled in. Honest scope: node-to-node transport remains classical libp2p Noise/X25519 (stable2407 has no PQ-Noise); no external audit; probabilistic PoW finality. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The `ghost` subcommands now connect to a running node's JSON-RPC endpoint instead of printing guidance: - balance / validators: decode System.Account and GhostConsensus.ValidatorStakes from live state (state_getStorage / state_getKeysPaged). - stake / unstake / transfer: build, sr25519-sign, and submit real extrinsics using the runtime's own RuntimeCall / UncheckedExtrinsic / TxExtension types (SignedPayload::from_raw with RPC-fetched genesis hash + the embedded spec/tx version, immortal era, metadata-hash extension disabled), via author_submitExtrinsic. New node deps: jsonrpsee http-client, tokio, pallet-balances, pallet-ghost-consensus. Each command takes --rpc-url (default http://127.0.0.1:9944) and --account (default //Alice). Verified against a live --dev node: balance reflects the genesis endowment; validators lists the genesis stakers; stake (2->5 UNIT), unstake (5->4 UNIT) and transfer (Bob +5 UNIT) all execute on-chain with correct nonce sequencing (0,1,2). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- pq-keygen: generate an ML-DSA-87 (FIPS 204) keypair to <out>.pub (2592 bytes) and <out>.sec (4896 bytes). Keygen runs on a 16 MiB-stack thread (the matrix expansion overflows the main thread's stack otherwise). - register-key: read an ML-DSA-87 public key file and submit ghostConsensus.register_ml_dsa_key, activating on-chain PQ attestation checks for the signer. - `validators` now also reports each validator's ML-DSA key status. New node dep: fips204 (native keygen only; the no_std Wasm runtime builds fips204 separately, without default-rng). Generated key files are gitignored. Verified against a live --dev node: pq-keygen produced a 2592/4896-byte keypair; register-key from Alice was accepted and executed; `validators` then reported "ML-DSA-87 key registered (2592 bytes)" for Alice and "no PQ key" for Bob. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Expose the existing node-side ML-KEM-1024 (FIPS 203) + ChaCha20-Poly1305 module as CLI commands (file-based, no running node needed): - pq-kem-keygen: write a keypair to <out>.ek (1568 bytes) and <out>.dk (3168 bytes). - pq-encrypt: ML-KEM-encapsulate to a recipient .ek and seal the file with ChaCha20-Poly1305. - pq-decrypt: decapsulate with a .dk and open the AEAD bundle. Heavy crypto runs on a 16 MiB-stack thread. Generated .ek/.dk files are gitignored. Verified: keygen produced 1568/3168-byte keys; a 39-byte plaintext encrypted to a 1639-byte bundle and decrypted back to the exact original; decryption with a different keypair's key was correctly rejected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
Turns the chain into a working hybrid Proof-of-Work + Proof-of-Stake network with real post-quantum cryptography, hardens the consensus pallet, wires real weights, and adds a genuine CLI wallet + PQ tooling.
Block authoring is real PoW via
sc-consensus-pow(double-Blake2-256 overpre_hash || nonce,U256difficulty, on-chain retargeting); Aura/GRANDPA were removed from the node and runtime.pallet-ghost-consensusis the PoS economic layer (staking, stake-weighted validator selection, 40/60 miner/staker reward split, evidence-gated slash-and-burn, validation-timeout recovery).What's included
no_stdWasm runtime; validators register keys, andvalidate_blockenforces an ML-DSA signature from the selected validator when a key is registered.verify_pq_signature; immediate finality when the staker set is empty (was timeout-only); theminedemo now uses the node's real PoW work function (single source of truth).SubstrateWeight(DbWeightreads/writes + a conservative ~300µs ML-DSA-verify charge) wired into the runtime, replacing the()placeholder.ghost <cmd>, over JSON-RPC):balance,validators— live state queries (validatorsalso shows ML-DSA key status).stake,unstake,transfer— build, sr25519-sign, and submit real extrinsics.pq-keygen,register-key— ML-DSA-87 keygen + on-chain registration.pq-kem-keygen,pq-encrypt,pq-decrypt— ML-KEM-1024 file encryption (offline).Verification
--devrun: mined Refactor and Fix Ghost Chain Consensus #1→#20;stake(2→5 UNIT),unstake(5→4 UNIT), andtransfer(Bob +5 UNIT) executed with correct nonce sequencing;register-keythen showedML-DSA-87 key registered (2592 bytes)invalidators; ML-KEMpq-encrypt→pq-decryptround-tripped exactly and a wrong-key decrypt was correctly rejected.Honest scope / caveats
stable2407has no PQ-Noise variant. PQ lives at the signature + application-encryption layers, not the wire transport.frame-benchmarkingnumbers are still recommended before mainnet.[profile.dev] debug = falseis set to avoid the MSVCLNK1318PDB-size limit on the node binary.Build & test
🤖 Generated with Claude Code