Feat/sdp audit bridge - #79
Merged
Merged
Conversation
Resolve explicit transaction hashes or a source-account time window through bounded Horizon payment queries. Normalize classic and SAC transfers into deterministic, exact, PII-free aggregate evidence.
Anchor locally hashed aggregates through Nirium with optional domain-separated Ed25519 attestations. Add a CID-only verifier that recomputes content integrity and reconstructs every cited payment through Horizon.
Exercise malformed Horizon and IPFS responses, pagination bounds, SAC and muxed semantics, cross-transaction evidence, exact arithmetic, record tampering, and domain-separated attestations.
Describe integration and verification workflows, trust boundaries, Providencia Onchain attribution, and reproducible evidence from a three-payment SDP Testnet disbursement.
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.
Closes #71
Summary
This PR adds a reusable, testnet-only SDP audit bridge under
examples/sdp-audit-bridge/. It accepts either explicit transaction hashes or a distribution account plus UTC time window, reads the corresponding payment records directly from Stellar Horizon, produces a deterministic PII-free aggregate, and anchors that record through Nirium'sanchorAuditRecord().It also adds a separate CID-only verification path. The verifier retrieves the anchored document from IPFS, recomputes its canonical SHA-256 digest and optional Ed25519 attestation statement, then independently retrieves and reconciles every cited transaction against Horizon. It does not accept the anchored aggregate as proof of its own claims.
Design decision
Three in-scope implementation strategies were evaluated independently:
asset_balance_changes, muxed-account representations, or malformed gateway responses. The additional abstraction would not replace the security-critical checks required here.The selected design remains an adapter rather than an SDP fork or dashboard. It never queries recipient PII, accesses custody keys, or submits Stellar transactions.
Implementation
{ sourceAccount, from, to }.invoke_host_functionpayment records.content_sha256locally and signs only the domain-separated statementnirium-audit-v1:<content_sha256>when an agent key is configured.Findings and hardening
Review of the first implementation identified several important correctness gaps. SDP payments can use a distribution account as the operation source while a channel account submits the envelope, so envelope-source filtering was replaced with payment-source filtering. Horizon's payment endpoints were used to cover both classic payments and SAC balance changes consistently. Issued assets now compare code and issuer, and monetary aggregation uses stroops rather than floating-point arithmetic.
The adversarial review then found three additional boundary cases: a classic muxed destination and an SAC
G-address:idrepresentation could be counted as different recipients; a malicious response could return a payment record belonging to a different requested transaction; and contradictoryto,to_muxed, andto_muxed_idfields could be accepted. Canonical muxed-account reconstruction, strict per-record transaction-hash matching, and muxed-field coherence checks now reject those cases. The focused suite contains 41 passing tests covering normal flows, malformed external data, pagination limits, SAC ambiguity, signature substitution, aggregate tampering, and these adversarial cases.Testnet acceptance evidence
The bridge was exercised end-to-end against three real XLM payments created by a self-hosted SDP v7.0.0 instance built from official backend commit
d36cfaa(disbursement8ffa4b5e-d19e-4524-96c6-3707db2b2696). Both explicit-hash and source-window selection produced three recipients and6.6000000 XLM.QmPBR9r3ax7u9smk6H7w7AjSciNh2AZKHwUB5sTyxwCSQD7c7e6ad1ed8d13e6fafb4e9757046bb58889df661fd126b12b226edb95629f24539aad89debbd03081b515ad4c85c3ac41797f62e3d437ea33763be0e987b464The README records all three transaction hashes and the reproducible verification command. It credits Providencia Onchain / VIIO for the deployment-specific on-chain traceability pattern and limits this contribution's claim to a generic reusable adapter.
Validation
Assistance disclosure
The repository's contribution guidance requires disclosure of AI assistance. OpenAI Codex was used only as an engineering assistant for implementation review, documentation research, test execution, and adversarial analysis. The contributor retained authorship, technical judgment, and responsibility for the submitted work. The guidance's literal Claude-specific co-author trailer was not used because it would inaccurately attribute co-authorship to a different system; no AI system is represented as an author or co-author of these commits.