feat: claim evidence URL + SHA-256 commitment (file_claim, events, st… - #267
Merged
jhayniffy merged 2 commits intoMar 29, 2026
Merged
Conversation
…ack)
- Contract: ClaimEvidenceEntry { url, hash }, Claim.evidence, ClaimFiled.evidence_hashes
- Reject all-zero hash at filing (ExcessiveEvidenceBytes; enum at Soroban max)
- Backend: file_claim ScVal encoding, IPFS contentSha256Hex, verification helper
- Frontend: wizard passes evidence; vote schema uses evidence
- Docs: contracts/niffyinsure/docs/claim_evidence_hash.md
Made-with: Cursor
|
@Jambox11 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Adds a content commitment for claim evidence: each attachment is
{ url, hash }with a 32-byte SHA-256 digest. The contract stores the commitment and rejects an all-zero digest at filing; it does not fetch URLs or verify hashes on-chain. Off-chain services (IPFS proxy, NestJS) can fetch bytes and compare digests.Contract (
niffyinsure)ClaimEvidenceEntry(url: String,hash: BytesN<32>);Claim.image_urlsreplaced byClaim.evidence.file_claim(..., evidence)validates URL limits and non-zerohashper entry.ClaimFiledemitsevidence_hashes: Vec<BytesN<32>>(same order asevidence); removed FNVimage_hashu64.validate::Errornote: Sorobancontracterroris at max variant count, so all-zero hash maps to existingExcessiveEvidenceByteswith an updated human message inmap_quote_error.contracts/niffyinsure/docs/claim_evidence_hash.md.get_claim, sharedtests/commonhelpers; snapshots updated.cargo test -p niffyinsurepasses.closes Contract — Claim evidence hash commitment: SHA-256 digest alongside URL #186
Backend
build-transactionacceptsevidence: [{ url, contentSha256Hex }]; Soroban encoding infile-claim-evidence.ts.contentSha256Hex(hash of bytes actually uploaded after EXIF strip); idempotency cache stores it for new uploads.contentMatchesSha256Commitment()for verification against fetched content.scripts/refresh-vectors.tsupdated.ClaimFiledEvent.evidence_hashesreplacesimage_hash.handleClaimFiledduplication;ClaimFiledhandler currently logs only (payload/topics don’t carry enough for a full DB upsert withoutget_claimbackfill).Frontend
evidencewithcontentSha256Hexfrom upload; vote schema usesevidenceinstead ofimage_urls.How to test
cd contracts/niffyinsure && cargo test -p niffyinsurecd backend && npx jest src/soroban/golden-vectors.test.ts src/events/events.test.tsFollow-ups (optional)
ClaimFiled+get_claim(or extend on-chain event) so DB rows stay in sync.nest buildstill has unrelated existing TS issues in this repo; contract + selected Jest suites above are the focused checks for this PR.