Skip to content

[CT-19] Build batch document verification contract #927

@mftee

Description

@mftee

Problem

When a shipment is completed, multiple documents (Bill of Lading, Proof of Delivery, Customs Declaration) need to be verified against their on-chain hashes simultaneously. The current document contract requires one transaction per document, making post-completion verification slow and expensive.

Proposed Solution

Create a batch verification function inside contracts/package/document-verification/ that verifies multiple submitted hashes against their registered on-chain values in a single transaction.

Note: All work must be done inside the contracts/package/ directory. Do not modify any existing contract files outside this folder.

Acceptance Criteria

  • verify_documents_batch(doc_ids: Vec<BytesN<32>>, submitted_hashes: Vec<BytesN<32>>) function
  • Input vectors must have equal length; mismatched lengths return InputLengthMismatch
  • Returns Vec<VerificationResult> where VerificationResult = { doc_id: BytesN<32>, matches: bool, stored_hash: BytesN<32> }
  • A mismatch on one document does NOT halt verification of the remaining documents (all are processed independently)
  • The response also includes a summary: { total: u32, matched: u32, mismatched: u32 }
  • Unit tests cover: all hashes match, partial match (2 of 3), all mismatch, empty input (returns empty result)

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions