Skip to content

fix: bind address and amount in Merkle leaf for claim_with_proof - #442

Merged
kilodesodiq-arch merged 5 commits into
ChainForgee:mainfrom
portableDD:fix/merkle-leaf-bind-address-and-amount
Aug 20, 2026
Merged

fix: bind address and amount in Merkle leaf for claim_with_proof#442
kilodesodiq-arch merged 5 commits into
ChainForgee:mainfrom
portableDD:fix/merkle-leaf-bind-address-and-amount

Conversation

@portableDD

Copy link
Copy Markdown
Contributor

Summary

The Merkle allowlist proved membership only — a single root authorised every package sharing that root regardless of amount. The leaf was sha256(claimant_address_string) so any allowlisted address could claim any amount.

Add a v2 leaf format: sha256(address_string || amount_be_bytes) that binds both recipient and package amount. Packages set merkle_leaf_version="v2" in metadata to opt in; v1 (address-only) is the default for backward compatibility. The merkle-allowlist tool is updated to generate sha256-based v2 leaves.

Closes #436

Testing

  • Existing tests pass with v1 (address-only) default
  • v2 leaf binds address + amount correctly
  • merkle-allowlist tool uses sha256 with amount encoding

Checklist

  • Tests added or updated for new/changed behavior
  • Existing tests pass
  • No secrets, keys, or seed phrases committed
  • Follows the coding conventions in the relevant service README
  • PR is focused on a single concern

The Merkle allowlist proved membership only — a single root
authorised every package sharing that root regardless of amount.
The leaf was sha256(claimant_address_string) so any allowlisted
address could claim any amount.

Add a v2 leaf format: sha256(address_string || amount_be_bytes)
that binds both recipient and package amount.  Packages set
merkle_leaf_version='v2' in metadata to opt in; v1 (address-only)
is the default for backward compatibility.  The merkle-allowlist
tool is updated to generate sha256-based v2 leaves.

Closes ChainForgee#436
The soroban_sdk::String type does not implement PartialEq<str>,
causing a compilation error when comparing the leaf_version with a
string literal. Use soroban_sdk::String comparison instead.

@kilodesodiq-arch kilodesodiq-arch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kilodesodiq-arch kilodesodiq-arch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@portableDD please resolve conflicts.

- Integrate main's zero-dependency merkle-allowlist architecture
- Keep v2 leaf format (address + amount binding) from PR ChainForgee#442
- Update sample_allowlist.json with amount fields for v2 support
@kilodesodiq-arch
kilodesodiq-arch merged commit a08b074 into ChainForgee:main Aug 20, 2026
5 checks passed
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.

claim_with_proof Merkle leaves bind only the claimant address: a single root cannot authorize per-recipient amounts

2 participants