Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cheatcodes): implement EIP-2098 in vm.sign #8538

Merged

Conversation

leovct
Copy link
Contributor

@leovct leovct commented Jul 26, 2024

Motivation

Closes #6606

This PR implements EIP-2098 in a new cheatcode called vm.signEIP2098, introducing a compact signature representation that reduces the signature size from 65 to 64 bytes. The function returns a tuple (r, vs) where vs encodes both the signature's s value and the recovery id v in a single bytes32, allowing for more efficient signature handling and storage.

Solution

x

@leovct leovct marked this pull request as ready for review July 27, 2024 23:23
crates/cheatcodes/src/utils.rs Outdated Show resolved Hide resolved
crates/cheatcodes/src/utils.rs Outdated Show resolved Hide resolved
testdata/default/cheats/Wallet.t.sol Outdated Show resolved Hide resolved
crates/cheatcodes/src/utils.rs Outdated Show resolved Hide resolved
crates/cheatcodes/src/utils.rs Outdated Show resolved Hide resolved
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@DaniPopes DaniPopes merged commit adc2132 into foundry-rs:master Jul 29, 2024
20 checks passed
@leovct leovct deleted the feat/implement-eip-2098-in-vm-sign-cheatcode branch July 29, 2024 12:45
benwjhack pushed a commit to CompassLabs/foundry-test that referenced this pull request Sep 11, 2024
* feat: implement EIP-2098 in vm.sign

* fix: clippy

* test: fix

* fix: forge-fmt

* chore: implement new cheatcode vm.signEIP2098

* fix: typos

* fix: another typo

* fix

* test: update sign tests

* fix: typo

* chore: rename `vm.signEIP2098()` into `vm.signCompact()`

* chore: update `encode_compact_signature` impl

* chore: update `signCompact` tests

* chore: factorize

* chore: rename fns

* chore: nit

* fix: issue

* chore: nits
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.

feat(cheatcodes): implement EIP-2098 in vm.sign
2 participants