Skip to content

feat: add nonce and expiry to transfer attestations - #701

Merged
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
devv-leo:feat/attestation-nonce-expiry
Jul 29, 2026
Merged

feat: add nonce and expiry to transfer attestations#701
thlpkee20-wq merged 2 commits into
RevoraOrg:masterfrom
devv-leo:feat/attestation-nonce-expiry

Conversation

@devv-leo

Copy link
Copy Markdown
Contributor

Closes #561

Summary

Add nonce and expiry to transfer_with_attestation to prevent attestation replay. Nonces are per-signer (keyed by from address) and monotonically consumed.

Changes

Contract (src/lib.rs)

  • Add AttestationNonceUsed(Address, u64) variant to DataKey2
  • Extend transfer_with_attestation with attest_hash, network_id, nonce, expires_at
  • Add network ID validation (NetworkIdMismatch if mismatch)
  • Add nonce/expiry validation (SignatureExpired, SignatureReplay)
  • Add dual-party auth (from.require_auth, to.require_auth)
  • Add offering freeze, blacklist, whitelist, jurisdiction enforcement
  • Nonce consumed only after all guards pass (prevents DoS)
  • Event payload now includes nonce and expires_at
  • atomic_swap passes expires_at=0 to skip nonce check

Tests

  • All existing calls updated with nonce/expiry params
  • New tests: expired_attestation_rejected, replayed_attestation_nonce_rejected, nonce_is_per_signer, attestation_used_at_exact_expiry
  • Self-transfer test updated to match no-op behavior

Security

  • Nonce validated early, consumed only after state mutation succeeds
  • Per-signer scoping: nonces tracked per (from, nonce) pair
  • Expired attestations rejected with SignatureExpired (error 27)
  • Replayed nonces rejected with SignatureReplay (error 28)
  • atomic_swap uses expires_at=0 sentinel to bypass attestation requirements

devv-leo and others added 2 commits July 29, 2026 19:25
Add nonce and expiry to transfer_with_attestation to prevent attestation replay.

- Extend transfer_with_attestation with attest_hash, network_id,
  nonce, and expires_at parameters
- Add AttestationNonceUsed(Address, u64) variant to DataKey2
- Add network ID validation, nonce/expiry validation, and nonce
  consumption tracking (consumed only after all guards pass)
- Add dual-party auth (from.require_auth, to.require_auth)
- Add offering freeze, blacklist, whitelist, jurisdiction guards
- Update atomic_swap to pass dummy attestation values (expires_at=0)
- Add new tests for: expired attestation, nonce replay,
  per-signer nonce scoping, exact expiry boundary
- Update event payload to include nonce and expires_at

Closes RevoraOrg#561
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@devv-leo 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 f8e4eba into RevoraOrg:master Jul 29, 2026
1 of 3 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.

Add transfer_with_attestation nonce and expiry to prevent attestation replay

2 participants