feat(eip712): EIP-712 typed-data signing module (WALLET-1255)#41
Merged
Comp0te merged 11 commits intoJun 11, 2026
Merged
Conversation
- Added EIP-712 entities, errors, and repository interfaces to support typed data handling, signing, and verification - Integrated `@casper-ecosystem/casper-eip-712` dependency for EIP-712 compatibility - Included unit tests for EIP-712 error handling
- Added `validatePrimaryType`, `resolveDomainTypes`, `validateTypedDataFieldTypes`, and `validateNoUnknownMessageFields` functions for EIP-712 typed data validation - Included unit tests to cover validation logic and edge cases
- Implemented `computeTypedDataDigest` to generate EIP-712 digests and optional hash artifacts - Included comprehensive unit tests for digest stability, artifact generation, and strict field validation
- Implemented `buildTypedDataDisplayModel` to generate structured display models for EIP-712 typed data - Added `keyToLabel` function to map keys to user-friendly labels - Included comprehensive unit tests for domain and message row formatting, type handling, and address detection
- Implemented `signTypedData`, `signTypedDataDigestWithKey`, and `signTypedDataWithRawKey` for EIP-712 signing - Added unit tests to verify signature correctness, digest computation, and hash artifact handling - Ensured compatibility with `ed25519` and `secp256k1` signing algorithms
…ities with tests - Implemented `recoverTypedDataSignerAddress` and `verifyTypedDataSignature` for Ethereum-style signature recovery and validation - Re-exported EIP-712 domain helpers (`CASPER_DOMAIN_TYPES`, `buildDomain`, `PermitTypes`, etc.) - Added unit tests to validate signature recovery, verification, and helper re-exports
- Added `EIP712Repository` class for typed data handling, digest computation, signing, and verification. - Implemented methods for building display models, signing typed data, and recovering/verifying signatures. - Included comprehensive unit tests to validate repository behavior and error handling.
Comp0te
approved these changes
Jun 7, 2026
Comp0te
reviewed
Jun 7, 2026
Comp0te
reviewed
Jun 7, 2026
Comp0te
left a comment
Collaborator
There was a problem hiding this comment.
setup.integration.test.ts missing new repository
- Adjusted `EIP712Error` instantiation to use `signDigest` as the error context. - Updated integration test to include the new `eip712Repository` in repository wiring validation.
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.
Summary
Extracts the reusable, framework-agnostic EIP-712 typed-data signing logic into
casper-wallet-coreso both consumers — the browser extension and the React-Native mobile app — share one implementation instead of duplicating it. Adds aneip712repository (wired intosetupRepositories()) providing: typed-data validation, EIP-712 digest + hash artifacts, a UI-agnostic display model, a Casper-correct signing helper, and recover/verify.Hashing/recover/verify are delegated to
@casper-ecosystem/casper-eip-712; signing uses casper-js-sdk keys. No UI — each wallet renders its own.casper-click-websdkstays unchanged; this is purely additive.Closes WALLET-1255.
What's added
src/domain/eip712/— interfaces,EIP712Error(implementsIDomainError, also carries the publicerrorCode),SignTypedDataErrorCodes,IEIP712Repository. Mirrorstx-signature-request.src/utils/eip712/— pure logic:validation,digest,displayModel,sign,recover(+ barrel).src/data/repositories/eip712/—EIP712Repository, a thin synchronous facade delegating to the utils.domain/index,utils/index,data/repositories/index,setup.ts(addseip712Repository), andpackage.json(@casper-ecosystem/casper-eip-712@1.2.1; transitive deps only@noble/curves+@noble/hashes, RN-safe).Public API:
setupRepositories().eip712Repository,isEIP712Error,SignTypedDataErrorCodes, plus all types/utilities via the root barrel.Key invariants & decisions
PrivateKey.sign()prehashes with SHA-256 internally, so passing the raw EIP-712 digest reproduces the reference02 + secp256k1.sign(sha256(digest))wire format byte-for-byte (asserted in tests against an independent@noblereference). No new signing dependency.01, signs the digest directly) and covered by a native round-trip test; still unproven by a production consumer (secp256k1 is the proven path).type === 'address'or keycontract_package_hash; message rows whentype === 'address'orbytes32.02-prefixed signatures (which are oversha256(digest)) and do not apply to ed25519 — documented on the wrappers and the repository.Test plan
yarn code:check— clean (tsc strict + eslint + prettier).yarn test— 416 passed (42 suites), including:validation— 4-step domain-type priority, array/bytes1..bytes31rejection (fast-check property),rejectUnknownFields.digest— stable digest + all 6 hash artifacts against real package vectors.displayModel— domain/message address asymmetry,keyToLabel.sign— secp256k1 byte-identical gate, ed25519 round-trip, end-to-end (with/without artifacts).recover— recovers the true signer address, verify round-trip, lib re-exports.setup.integration.test.ts— factory still wires correctly witheip712Repository.🤖 Generated with Claude Code