Skip to content

Commit 1cf1377

Browse files
authored
Clarify how ECDSA signatures are parsed (#5990)
1 parent 78eb160 commit 1cf1377

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

contracts/utils/cryptography/ECDSA.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,12 @@ library ECDSA {
207207

208208
/**
209209
* @dev Parse a signature into its `v`, `r` and `s` components. Supports 65-byte and 64-byte (ERC-2098)
210-
* formats. Returns (0,0,0) for invalid signatures. Consider skipping {tryRecover} or {recover} if so.
210+
* formats. Returns (0,0,0) for invalid signatures.
211+
*
212+
* For 64-byte signatures, `v` is automatically normalized to 27 or 28.
213+
* For 65-byte signatures, `v` is returned as-is and MUST already be 27 or 28 for use with ecrecover.
214+
*
215+
* Consider validating the result before use, or use {tryRecover}/{recover} which perform full validation.
211216
*/
212217
function parse(bytes memory signature) internal pure returns (uint8 v, bytes32 r, bytes32 s) {
213218
assembly ("memory-safe") {

0 commit comments

Comments
 (0)