Skip to content

feat: Selective disclosure proofs using Merkle trees of credential fields (#67) - #73

Open
jotel-dev wants to merge 1 commit into
laugh-tales:mainfrom
jotel-dev:issue-67-selective-disclosure-proofs-merkle-trees
Open

feat: Selective disclosure proofs using Merkle trees of credential fields (#67)#73
jotel-dev wants to merge 1 commit into
laugh-tales:mainfrom
jotel-dev:issue-67-selective-disclosure-proofs-merkle-trees

Conversation

@jotel-dev

Copy link
Copy Markdown

Description

Closes #67.

This PR adds selective disclosure capabilities to StellarID using Merkle tree proofs. Subjects can selectively disclose specific attributes (e.g., proving age: 30) to third-party verifiers without revealing other fields contained within the credential.

Changes Made

  • Data Model: Added SelectiveCredential struct containing merkle_root: BytesN<32> and field_count.
  • Storage Keys: Added DataKey::SelectiveCredential(u64) and DataKey::SelectiveCredentialCount.
  • Merkle Cryptography:
    • Leaf Hash: SHA-256(field_name_xdr || ":" || field_value_xdr).
    • Binary Tree Construction: Pairs leaves and duplicates odd leaf layers to compute merkle_root.
    • Proof Verification: Recomputes Merkle path from proof elements and checks against stored root.
  • Public Interface:
    • hash_leaf(env, field_name, field_value) -> BytesN<32>
    • compute_merkle_root(env, leaves) -> BytesN<32>
    • verify_merkle_proof(env, leaf, proof, root, index) -> bool
    • issue_selective_credential, get_selective_credential, verify_credential_field, has_valid_field.
  • Documentation: Added Merkle tree selective disclosure documentation to docs/ARCHITECTURE.md.

Test Plan & Verification

  • test_selective_disclosure_merkle_tree: Builds a 4-leaf Merkle tree credential, generates sibling proofs, and verifies individual field disclosure on-chain.
  • All unit tests passing via cargo test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement selective disclosure proofs using Merkle tree of credential fields

1 participant