Skip to content

feat(remittance): add signed split allocation quotes#1064

Open
jamilahmadzai wants to merge 1 commit into
Remitwise-Org:mainfrom
jamilahmadzai:codex/remitwise-1011-signed-allocations
Open

feat(remittance): add signed split allocation quotes#1064
jamilahmadzai wants to merge 1 commit into
Remitwise-Org:mainfrom
jamilahmadzai:codex/remitwise-1011-signed-allocations

Conversation

@jamilahmadzai

Copy link
Copy Markdown

Summary

Closes #1011.

Adds an authenticated allocation-quote path for remittance_split:

  • Adds get_split_allocations_hash(caller, total_amount, deadline) so callers can compute the exact quote hash off-chain.
  • Adds get_split_allocations_signed(caller, total_amount, deadline, request_hash) to validate amount, deadline, hash binding, and caller authorization before returning allocations.
  • Binds the quote hash to the shared signing domain, alloc functional tag, network id, current contract address, caller address, total amount, and deadline.
  • Delegates the final allocation calculation to the existing get_split_allocations path so signed and unsigned quote semantics stay in lockstep.

Security notes

  • The signed quote path performs no token transfers and writes no contract state.
  • The auth payload includes the caller, network, contract instance, amount, and deadline.
  • The request hash uses stable XDR address bytes for the caller and contract address to avoid object-id instability across repeated computations.
  • Deadline handling mirrors the public hashed distribution semantics: deadline <= now expires, deadline > now + MAX_DEADLINE_WINDOW_SECS is invalid, and the exact max-window boundary is accepted.

Tests

  • cargo test -p remittance_split test_get_split_allocations_signed -- --nocapture
  • cargo clippy -p remittance_split --all-targets completed with existing warnings.
  • git diff --check

Known baseline: the full cargo test -p remittance_split -- --nocapture suite is currently red on existing tests unrelated to this change. The failures include older tests still initializing splits with 50/30/15/5-style values while initialize_split now validates basis points summing to 10_000, plus an existing event-topic assertion. The focused tests added for this issue pass.

Bounty: GrantFox OSS campaign for issue #1011.

@jamilahmadzai

Copy link
Copy Markdown
Author

Checked the failing CI jobs after opening this PR. The failures are outside the touched scope:

  • Build and Test stops while compiling reporting/src/lib.rs / reporting/src/utils.rs (ContractError import/derive issues, to_i128_checked trait import, and existing ?/return-type errors).
  • Lint (unwrap/expect ban) fails on the same reporting compile errors before reporting any issue in remittance_split.
  • Validate and Build fails on the same unrelated reporting crate errors.
  • Gas Benchmarks, Security Checks, and Storage Key Naming Convention Validation pass.

This PR only changes remittance_split/src/lib.rs and remittance_split/src/test.rs. The focused validation for the new signed allocation quote path still passes locally:

cargo test -p remittance_split test_get_split_allocations_signed -- --nocapture
git diff --check

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.

Add a get_split_allocations_signed authorized variant binding allocation reads to a request hash

1 participant