Skip to content

feat(crypto): domain-separate wallet signatures and add cross-chain replay tests - #282

Open
ocakciomursel-pixel wants to merge 4 commits into
wraith-protocol:developfrom
ocakciomursel-pixel:feat/domain-separated-wallet-signatures-273
Open

ocakciomursel-pixel wants to merge 4 commits into
wraith-protocol:developfrom
ocakciomursel-pixel:feat/domain-separated-wallet-signatures-273

Conversation

@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor

Summary

Inventories all SDK-generated wallet and off-chain authorization signatures, introduces canonical cross-chain domain separation (chain, chainId, network, contract, operation, nonce, expiry) across EVM, Stellar, Solana, and CKB, publishes deterministic positive + negative replay vectors in @wraith-protocol/test-vectors, and preserves v1 compatibility with a documented migration path.

Changes

  • Canonical domain framing & replay guards (src/auth/domain.ts, exported from @wraith-protocol/sdk):
    • Defines SignatureDomain, ReplayRejectionReason, encodeDomainAuthorizationBytes (WRAITH-DOMAIN-SIG-V1 4-byte length-prefixed framing preventing variable-length concatenation collisions), buildDomainStealthSigningMessage, and checkDomainGuards.
  • Chain signing & verification helpers (src/chains/{evm/names,stellar/auth,solana/auth,ckb/auth}.ts):
    • EVM: Adds EIP-712 structured computeEvmDomainSeparator, computeEvmNameAuthorizationDigest, signDomainNameAuthorization, and verifyDomainNameAuthorization (binding chainId, verifyingContract, salt = keccak256(network), operationHash, nonce, and expiry). Marks unscoped v1 signNameRegistration, signNameRegistrationOnBehalf, signNameUpdate, and signNameRelease @deprecated while preserving byte-identical 1.x behavior.
    • Stellar & Solana: Adds ed25519 SHA-256 compute{Stellar,Solana}AuthorizationDigest, sign{Stellar,Solana}DomainAuthorization, and verify{Stellar,Solana}DomainAuthorization (supporting both 32-byte seeds and stealth scalars).
    • CKB: Adds recoverable secp256k1 + ckb-default-hash blake2b computeCkbAuthorizationDigest, signCkbDomainAuthorization, and verifyCkbDomainAuthorization.
  • Published vectors, replay conformance & docs (packages/test-vectors/vectors/wallet-signatures.json, test/conformance/signature-replay.test.ts, docs/security/signature-domains.md, MIGRATING.md):
    • Publishes SHA-256 checksummed valid and negative replay vectors covering cross-chain same-curve (EVM <-> CKB on secp256k1, Stellar <-> Solana on ed25519), cross-network, cross-contract, altered-operation (name.register replayed as name.update on identical name/meta-address), expired, nonce-reuse, and forged-domain claim substitutions.
    • Updates ./chains/stellar bundle budgets (33 KB -> 34.5 KB ESM, 41 KB -> 42.5 KB CJS) in package.json and BUNDLE_SIZE.md for the new Stellar domain-authorization helpers (with zero cross-chain imports).

Semver Impact

  • Minor: Additive domain-separation exports across root and chain modules; v1 EVM signing helpers remain backward-compatible with @deprecated annotations and migration steps in MIGRATING.md.

Verification

  • pnpm build & pnpm api:check
  • pnpm format:check, pnpm test:types, pnpm size, pnpm pack:check, pnpm audit:ci
  • pnpm --filter @wraith-protocol/test-vectors differential
  • pnpm test (including test/conformance/signature-replay.test.ts)

Closes #273

@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor Author

Hi maintainers — thanks for assigning #273! This PR is open, conflict-free, and all CI checks are green. Ready for review ahead of the Nov 25 Wave 11 deadline; happy to address any feedback quickly.

@ocakciomursel-pixel
ocakciomursel-pixel force-pushed the feat/domain-separated-wallet-signatures-273 branch from 4fc663f to f80e47f Compare November 24, 2026 03:12
@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@ocakciomursel-pixel 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

@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor Author

Thanks for merging #279, #280, and #281! Rebased this PR onto latest develop (693c29a), resolved the conflicts in etc/*.api.md, BUNDLE_SIZE.md, and packages/test-vectors (checksums regenerated), and verified pnpm build, pnpm api:check, pnpm size, pnpm test:types, pnpm test (1,628 tests), and pnpm format:check all pass locally. Ready for review and merge ahead of the Wave 11 deadline!

@ocakciomursel-pixel
ocakciomursel-pixel force-pushed the feat/domain-separated-wallet-signatures-273 branch from f80e47f to 4c4c6ac Compare November 24, 2026 03:42

@truthixify truthixify 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.

The canonical encoding still truncates oversized domain values. u256be serializes only the low 256 bits, so nonce 0 and nonce 2^256 produce identical authorization bytes; u64be similarly truncates expiry and the generic EVM chain ID. Reject nonce values above 2^256-1 and expiry/chain ID values above 2^64-1 before encoding, and add overflow/collision regressions.

@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor Author

@truthixify Good catch — addressed in 6bffeca (and synced with latest develop 178475a / #283 in 9f90606):

  • Pre-encoding range checks (src/auth/domain.ts): validateSignatureDomain now enforces 0 <= nonce <= 2^256 - 1, 1 <= expiry <= 2^64 - 1, and 1 <= chainId <= 2^64 - 1 (for EVM) with InvalidSignatureError before any encoding or guard evaluation, and u32be / u64be / u256be also enforce their exact bit-width bounds as defense in depth.
  • Overflow & truncation-collision regressions (test/conformance/signature-replay.test.ts): Added boundary tests for 2^256 - 1 and 2^64 - 1, pre-encoding rejection tests for oversized nonce (2^256, 2^256 + 1), expiry (2^64, expiry + 2^64), and generic EVM chainId (2^64, chainId + 2^64), and end-to-end verifier regressions confirming wraparound values cannot collide with low values or bypass usedNonces, expiry, or chain ID checks across Stellar, Solana, CKB, and EVM.
  • Docs & companion API report: Updated docs/security/signature-domains.md, etc/sdk.api.md, and listed vectors/wallet-signatures.json in etc/test-vectors.api.md.

All 27/27 CI checks are green on 9f90606. Ready for re-review and merge ahead of today's Wave 11 deadline.

@truthixify truthixify 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.

Head 9f90606 passed malware screening and issue #273 ownership matches @ocakciomursel-pixel. The prior integer-width blocker is resolved and the required checks are green. This head became conflicting after #287 advanced develop, so it needs a clean rebase and fresh CI; the rebased SHA will require a new remote security scan before merge.

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.

[Wave 11] Domain-separate wallet signatures and add cross-chain replay tests

2 participants