Repository navigation
feat(frontend): Client-Side SPV Header Verification and Cuckoo Filter WASM Integration (#301) - #338
Closed
huangji6693-max wants to merge 1 commit into
Conversation
… WASM Integration (LynxXProtocol#301) - Implement zero-allocation Cuckoo filter (ZeroAllocCuckooFilter) and SHA-256 Merkle inclusion branch verifier (verify_sha256_merkle_branch) in contracts/validation/src/cuckoo.rs - Export zero-allocation Uint16Array Cuckoo filter WASM primitives (cuckoo_filter_reset, cuckoo_filter_len, cuckoo_filter_contains, cuckoo_filter_insert, cuckoo_filter_delete) in pactum_validation - Add VERIFY_SPV_HEADER_CHAIN and VERIFY_CUCKOO_INCLUSION message handlers to validation.worker.ts with 4-level Stellar BucketList SHA-256 Merkle root verification - Integrate SpvStateManager into frontend/src/lib/localIndexer/rpcClient.ts to enforce cryptographic SPV state verification and Cuckoo filter pre-checks before rendering balances or commitments, blocking spoofed RPC payloads with WARNING: security alerts - Add comprehensive Rust (13/13) and Vitest (14/14) test suites covering honest chains, spoofed balances, tampered commitments, and phantom RPC entries Closes LynxXProtocol#301
4 tasks
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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
Implements client-side Simplified Payment Verification (SPV) header chain validation and a zero-allocation Cuckoo Filter WASM pre-filter for the browser local indexer (#301).
Closes #301
/claim #301
Architecture & Key Changes
Zero-Allocation Cuckoo Filter & Merkle Branch Verifier in Rust (
contracts/validation/src/cuckoo.rs&contracts/validation/src/lib.rs):ZeroAllocCuckooFilterusing a fixed[[u16; 4]; 1024]4-way associative bucket table (~8 KiB) with FNV-1a 64-bit primary bucket indexing, non-zero 16-bit fingerprints ([1, 65535]), XOR alternate bucket involution (i2 = (i1 ^ (hash(fp) & 0x3FF)) & 0x3FF), and bounded deterministic Cuckoo eviction kicks (MAX_CUCKOO_KICKS = 64).verify_sha256_merkle_branchfor deterministic SHA-256 Merkle inclusion branch verification without heap allocations.WASM Bridge (
frontend/src/wasm/pactum-validation/pactum_validation.js&pactum_validation.d.ts):Uint16ArrayCuckoo filter primitives (cuckoo_filter_reset,cuckoo_filter_len,cuckoo_filter_contains,cuckoo_filter_insert,cuckoo_filter_delete) matching the RustZeroAllocCuckooFiltersemantics.WebWorker SPV Header Chain & BucketList Inclusion Verifier (
frontend/src/workers/validation.worker.ts):verifySpvHeaderChainvalidating strictly sequential Stellar ledger headers, previous-header hash links, canonical header SHA-256 hashes, and 4-level Stellar BucketList SHA-256 Merkle roots (curr_0..3/snap_0..3).evaluateCuckooInclusionProofcombining O(1) Cuckoo Filter pre-checks with full SHA-256 Merkle inclusion branch verification against the verified BucketList root.VERIFY_SPV_HEADER_CHAINandVERIFY_CUCKOO_INCLUSION.Local Indexer RPC Guard (
frontend/src/lib/localIndexer/rpcClient.ts):SpvStateManagerto verify incoming RPC ledger states and commitments before rendering balances or commitments in the UI.WARNING: ...security alerts.Verification
contracts/validation):cargo test -p pactum-validation— 13 / 13 passedcargo clippy -p pactum-validation --lib -- -D warnings— 0 warningsspvVerification.test.ts+localIndexer):npx vitest run src/lib/localIndexer/spvVerification.test.ts src/lib/localIndexer/poller.test.ts src/lib/localIndexer/events.test.ts src/lib/localIndexer/db.test.ts— 29 / 29 passednpm run lint(oxlint) &npx tsc -b --noEmit— 0 warnings, 0 errorsnode scripts/ci/check-numeric-ids.mjs— PASSED