Skip to content

Implement invoice payment proof commitment (hash-then-reveal) #436

Description

@Kingsman-99

Description

External verifiers (auditors, regulators) need to validate that a payment occurred without being given access to the full payment history. This issue adds a payment proof mechanism where each payment writes a Merkle-style commitment hash to storage, and a verify_payment_proof function checks inclusion without exposing other payments.

Technical Context

Maintain a payment_root_key(invoice_id) -> BytesN<32> rolling hash in lib.rs. On each pay_invoice, compute new_root = sha256(old_root || payer || amount || ledger) using env.crypto().sha256(). Expose get_payment_root(env, invoice_id) -> BytesN<32> and verify_payment_proof(env, invoice_id, proof_elements: Vec<BytesN<32>>, payer: Address, amount: i128, ledger: u64) -> bool.

Acceptance Criteria

  • Payment root is updated after every successful pay_invoice call
  • get_payment_root returns the current rolling hash
  • verify_payment_proof returns true only for valid inclusion proofs
  • Initial root before any payment is sha256(invoice_id) (deterministic seed)
  • Tests: single payment root correct, two payments chain correctly, invalid proof returns false
  • All CI checks (cargo test, cargo clippy, cargo fmt) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsintegration

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions