Skip to content

feat: embed network_id in signed attestations - #697

Merged
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
sadiqolalere41-pro:feat/attestation-network-id
Jul 29, 2026
Merged

feat: embed network_id in signed attestations#697
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
sadiqolalere41-pro:feat/attestation-network-id

Conversation

@sadiqolalere41-pro

Copy link
Copy Markdown
Contributor

Closes #578

Changes

src/lib.rs

  • Add NetworkIdMismatch = 62 to RevoraError — returned when an attestation's embedded network_id does not match the current chain.
  • Add InvalidTransferParticipants = 63 — returned on self-transfer.
  • Add SignedAttestation struct with network_id: BytesN<32> (domain separator) and digest: BytesN<32> (pre-signed canonical hash).
  • Rewrite transfer_with_attestation: add dual-party auth (from + issuer), self-transfer guard, offering-level freeze check, whitelist check, and all 10 ordered guards documented in the function doc-comment.
  • Add compute_attestation_digest (read-only) — returns the canonical sha256(network_id || XDR(issuer) || XDR(namespace) || XDR(token) || XDR(from) || XDR(to) || u32be(amount_bps)) for the current chain.
  • Add verify_attestation_digest (read-only) — pre-flight check that rejects attestations whose network_id or digest does not match. Returns Err(NetworkIdMismatch) for both mismatch cases (fail-closed design).
  • Add private build_attestation_digest helper used by both public fns.

src/test_transfer_with_attestation.rs

  • Update module doc-comment to include network-id test coverage table.
  • Add make_signed_attestation test helper.
  • Add 6 network-id domain separator tests:
    • verify_attestation_correct_network_id — golden path
    • verify_attestation_mainnet_id_on_testnet_rejected
    • verify_attestation_testnet_id_on_mainnet_rejected
    • verify_attestation_unknown_network_id_rejected
    • verify_attestation_wrong_digest_rejected
    • attestation_compute_verify_round_trip (no-aliasing property)

docs/transfer-with-attestation.md

  • Document SignedAttestation struct and its two fields.
  • Document compute_attestation_digest and verify_attestation_digest.
  • Add digest-construction preimage spec (network_id || XDR fields).
  • Add security guarantees table (replay prevention, parameter binding, no-aliasing, read-only verification, fail-closed behaviour).
  • Add NetworkIdMismatch to the error reference table (code 62).
  • Add full test-coverage table for all 24 test cases.

Closes RevoraOrg#578

## Changes

### src/lib.rs
- Add `NetworkIdMismatch = 62` to `RevoraError` — returned when an
  attestation's embedded network_id does not match the current chain.
- Add `InvalidTransferParticipants = 63` — returned on self-transfer.
- Add `SignedAttestation` struct with `network_id: BytesN<32>` (domain
  separator) and `digest: BytesN<32>` (pre-signed canonical hash).
- Rewrite `transfer_with_attestation`: add dual-party auth (`from` +
  `issuer`), self-transfer guard, offering-level freeze check, whitelist
  check, and all 10 ordered guards documented in the function doc-comment.
- Add `compute_attestation_digest` (read-only) — returns the canonical
  sha256(network_id || XDR(issuer) || XDR(namespace) || XDR(token)
  || XDR(from) || XDR(to) || u32be(amount_bps)) for the current chain.
- Add `verify_attestation_digest` (read-only) — pre-flight check that
  rejects attestations whose network_id or digest does not match. Returns
  `Err(NetworkIdMismatch)` for both mismatch cases (fail-closed design).
- Add private `build_attestation_digest` helper used by both public fns.

### src/test_transfer_with_attestation.rs
- Update module doc-comment to include network-id test coverage table.
- Add `make_signed_attestation` test helper.
- Add 6 network-id domain separator tests:
  - `verify_attestation_correct_network_id` — golden path
  - `verify_attestation_mainnet_id_on_testnet_rejected`
  - `verify_attestation_testnet_id_on_mainnet_rejected`
  - `verify_attestation_unknown_network_id_rejected`
  - `verify_attestation_wrong_digest_rejected`
  - `attestation_compute_verify_round_trip` (no-aliasing property)

### docs/transfer-with-attestation.md
- Document `SignedAttestation` struct and its two fields.
- Document `compute_attestation_digest` and `verify_attestation_digest`.
- Add digest-construction preimage spec (network_id || XDR fields).
- Add security guarantees table (replay prevention, parameter binding,
  no-aliasing, read-only verification, fail-closed behaviour).
- Add `NetworkIdMismatch` to the error reference table (code 62).
- Add full test-coverage table for all 24 test cases.
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@sadiqolalere41-pro Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@thlpkee20-wq
thlpkee20-wq merged commit c509f46 into RevoraOrg:master Jul 29, 2026
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 network_id domain-separator embedded in every signed attestation

2 participants