feat: embed network_id in signed attestations - #697
Merged
thlpkee20-wq merged 2 commits intoJul 29, 2026
Merged
Conversation
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.
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #578
Changes
src/lib.rs
NetworkIdMismatch = 62toRevoraError— returned when an attestation's embedded network_id does not match the current chain.InvalidTransferParticipants = 63— returned on self-transfer.SignedAttestationstruct withnetwork_id: BytesN<32>(domain separator) anddigest: BytesN<32>(pre-signed canonical hash).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.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.verify_attestation_digest(read-only) — pre-flight check that rejects attestations whose network_id or digest does not match. ReturnsErr(NetworkIdMismatch)for both mismatch cases (fail-closed design).build_attestation_digesthelper used by both public fns.src/test_transfer_with_attestation.rs
make_signed_attestationtest helper.verify_attestation_correct_network_id— golden pathverify_attestation_mainnet_id_on_testnet_rejectedverify_attestation_testnet_id_on_mainnet_rejectedverify_attestation_unknown_network_id_rejectedverify_attestation_wrong_digest_rejectedattestation_compute_verify_round_trip(no-aliasing property)docs/transfer-with-attestation.md
SignedAttestationstruct and its two fields.compute_attestation_digestandverify_attestation_digest.NetworkIdMismatchto the error reference table (code 62).