Skip to content

Commit

Permalink
✏️ comments on type byte size
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
  • Loading branch information
pcaversaccio committed Jul 31, 2022
1 parent a3c7f8e commit 7a103a9
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/utils/ECDSA.vy
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ def _recover_sig(hash: bytes32, signature: Bytes[65]) -> address:
"""
@dev Recover the signer address from a message digest `hash`
and the signature `signature`.
@param hash The message digest that was signed.
@param signature The secp256k1 signature of `hash`.
@param hash The 32-bytes message digest that was signed.
@param signature The secp256k1 64/65-bytes signature of `hash`.
"""
# 65-bytes case: r,s,v standard signature
if (len(signature) == 65):
r: uint256 = extract32(signature, 0, output_type=uint256)
s: uint256 = extract32(signature, 32, output_type=uint256)
v: uint256 = convert(slice(signature, 64, 1), uint256)
return self._try_recover_vrs(hash, v, r, s)
# 64-bytes case: r,vs signature; see: https://eips.ethereum.org/EIPS/eip-2098
elif (len(signature) == 64):
r: uint256 = extract32(signature, 0, output_type=uint256)
vs: uint256 = extract32(signature, 32, output_type=uint256)
Expand All @@ -40,10 +42,10 @@ def _recover_vrs(hash: bytes32, v: uint256, r: uint256, s: uint256) -> address:
"""
@dev Recover the signer address from a message digest `hash`
and the secp256k1 signature parameters `v`, `r`, and `s`.
@param hash The message digest that was signed.
@param v secp256k1 signature parameter `v`.
@param r secp256k1 signature parameter `r`.
@param s secp256k1 signature parameter `s`.
@param hash The 32-bytes message digest that was signed.
@param v The secp256k1 1-byte signature parameter `v`.
@param r The secp256k1 32-bytes signature parameter `r`.
@param s The secp256k1 32-bytes signature parameter `s`.
"""
return self._try_recover_vrs(hash, v, r, s)

Expand All @@ -56,9 +58,9 @@ def _try_recover_r_vs(hash: bytes32, r: uint256, vs: uint256) -> address:
and the secp256k1 short signature fields `r` and `vs`.
@notice See https://eips.ethereum.org/EIPS/eip-2098 for the
compact signature representation.
@param hash The message digest that was signed.
@param r The secp256k1 signature parameter `r`.
@param vs The secp256k1 short signature field of `v` and `s`.
@param hash The 32-bytes message digest that was signed.
@param r The secp256k1 32-bytes signature parameter `r`.
@param vs The secp256k1 32-bytes short signature field of `v` and `s`.
"""
s: uint256 = vs & convert(SIGNATURE_INCREMENT, uint256)
v: uint256 = shift(vs, -255) + 27
Expand All @@ -76,10 +78,10 @@ def _try_recover_vrs(hash: bytes32, v: uint256, r: uint256, s: uint256) -> addre
the different client implementations can be found here:
https://github.com/ethereum/yellowpaper/pull/860. Thus,
the signature check on the value of `v` is neglected.
@param hash The message digest that was signed.
@param v The secp256k1 signature parameter `v`.
@param r The secp256k1 signature parameter `r`.
@param s The secp256k1 signature parameter `s`.
@param hash The 32-bytes message digest that was signed.
@param v The secp256k1 1-byte signature parameter `v`.
@param r The secp256k1 32-bytes signature parameter `r`.
@param s The secp256k1 32-bytes signature parameter `s`.
"""
if (s > convert(MALLEABILITY_THRESHOLD, uint256)):
raise "ECDSA: invalid signature \'s\' value"
Expand Down

0 comments on commit 7a103a9

Please sign in to comment.