feat: implement Tamper-Proof Merkle Hash-Chain Audit Vault - #448
Merged
Conversation
|
@T-kesh is attempting to deploy a commit to the jotelfootball-tech's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
I'm aware that node and contract ci are failing and I am currently working on them. I'll get it all clear before the end of today. |
T-kesh
marked this pull request as draft
August 30, 2026 09:35
T-kesh
marked this pull request as ready for review
August 30, 2026 09:35
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jotel-dev
approved these changes
Aug 30, 2026
2 tasks
Contributor
Author
Thank you for the swift review, I once again apologise for the late pr. Thank you for the opportunity and i look forward to work with you next wave. |
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.
feat: Implement Tamper-Proof Merkle Hash-Chain Audit Vault
First off, apologies for the slight delay in getting this PR up! Implementing a cryptographically secure audit system required meticulous care, extensive testing, and rigorous edge-case checks (especially around database race conditions) to guarantee absolute immutability. Thank you for your patience!
Overview
This PR introduces the Tamper-Proof Merkle Hash-Chain Audit Vault to satisfy our strict financial compliance requirements. It ensures that all critical event logs are cryptographically immutable and anchors their verifiable proofs onto the Stellar network.
Key Features & Architectural Changes
1. Database-Level Tamper Resistance
audit_hash_chain&audit_rootstables: Created robust Postgres schemas to store event hashes and batched Merkle roots.HashChainEnginewhich usesSELECT ... FOR UPDATErow locks to guarantee zero sequence number gaps. Each new record's hash natively commits to the previous record's hash ($curr_hash = SHA256(payload + prev_hash)$).2. Stellar On-Chain Anchoring
zk-credentialsmart contract to accept and durably store 32-byte Merkle Roots against a block index using theanchor_audit_rootadmin function.AuditAnchorWorkerto run asynchronously. It processes completed batches of 1,000 logs, calculates the aggregated Merkle Root, and securely anchors it on-chain, storing the resulting transaction hash for immediate lookup.3. Inclusion Proof Generation & Verification
GET /api/v1/audit/proof/:eventIdendpoint utilizing a customProofGenerator. It mathematically reconstructs the Merkle branch and returns a full, cryptographically sound inclusion proof.AuditorPortalandAuditProofViewerfrontend components. Compliance officers can now input any Sequence ID and instantly view its verifiable on-chain inclusion proof.4. Integrity Validation Tooling
scripts/verify-audit-chain.tsfor deep, offline validation of the entire database hash chain to instantly flag unauthorized database tampering.hash-chain.test.ts,audit-vault.test.ts) and end-to-end integration tests (audit_tamper_detection.test.ts).Notes for Reviewers
node:crypto(SHA-256) for maximum throughput.This pr closes #405