OpenZeppelin / OpenZeppelin/openzeppelin-contracts

Provide helper to split a short signature's `vs`

Open
#4,587 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Solidity
Stars
27.2k
Forks
12.4k
Avg merge
2d 19h
Merged PRs (30d)
33

Description

We have a function tryRecover(hash, r, vs) to support short signatures, but sometimes you want to receive a short signature and split it into a long signature without doing the recover operation.

For example a function that uses permit could look like this:

function doThingWithPermit(..., uint256 value, uint256 deadline, bytes32 r, bytes32 vs) {
      (uint8 v, bytes32 s) = ECDSA.splitShort(vs);

      try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}

      doThing(..., value);
}

token.permit expects v, r, s, but doThingWithPermit can be much more calldata efficient if it receives vs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the existing ECDSA.tryRecover(hash, r, vs) implementation and its ECDSA entry point. Add the requested splitShort(vs) helper so callers can obtain v and s for token.permit, then add or update tests to verify the returned components and confirm the permit use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.