Skip to content

Implement Merkle Tree Proof Verification for Results #36

@Just-Bamford

Description

@Just-Bamford

��# Issue 18: Implement Merkle Tree Proof Verification for Results

Problem

Result hash stored but not verified against merkle tree. No way to prove individual votes contributed to result.

Solution

  • Add verify_result_proof(ballot_id_hash, vote_merkle_proof, result_hash) function
  • Accept MerkleProof struct with vote hash, merkle path, and leaf index
  • Verify merkle path against stored result hash
  • Enables external vote verification without trusting contract entirely

Implementation Tasks

  • Define MerkleProof struct: vote_hash, path, index
  • Implement merkle path verification logic
  • Implement verify_result_proof() function
  • Unit tests: valid proofs verify correctly
  • Unit tests: invalid proofs fail
  • Integration test: full merkle verification workflow

Note for Contributors

This is an advanced cryptographic feature for external vote verification. Merkle proofs allow third parties to prove that a specific vote contributed to a published result without needing to trust the contract or backend. Implement standard merkle tree verification: given a leaf (vote), a path of hashes, and an index, reconstruct the root and compare with stored result hash. Support different tree depths and path lengths. Verify that proof inputs match the stored result hash exactly. This feature requires that results are published with merkle tree commitments (coordination with core backend). Consider using a standard merkle tree library if available in Soroban SDK. Test edge cases: empty trees, single-node trees, invalid paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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