From cbadbb43d7e81ce8d58fab177d01b89bdc23da82 Mon Sep 17 00:00:00 2001 From: Akash Bansal Date: Fri, 5 Jul 2024 23:41:33 +0530 Subject: [PATCH 1/3] Fix grammar errors in documentation --- docs/modules/ROOT/pages/utilities.adoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/modules/ROOT/pages/utilities.adoc b/docs/modules/ROOT/pages/utilities.adoc index 31d4d5e33ed..74fc17aaeb7 100644 --- a/docs/modules/ROOT/pages/utilities.adoc +++ b/docs/modules/ROOT/pages/utilities.adoc @@ -8,11 +8,11 @@ Here are some of the more popular ones. === Checking Signatures On-Chain -At a high level, signatures are a set of cryptographic algorithms that allow for a _signer_ to prove himself owner of a _private key_ used to authorize an piece of information (generally a transaction or `UserOperation`). Natively, the EVM supports the Elliptic Curve Digital Signature Algorithm (https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm[ECDSA]) using the secp256k1 curve, however other signature algorithms such as P256 and RSA are supported. +At a high level, signatures are a set of cryptographic algorithms that allow for a _signer_ to prove they are the owner of a _private key_ used to authorize a piece of information (generally a transaction or `UserOperation`). Natively, the EVM supports the Elliptic Curve Digital Signature Algorithm (https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm[ECDSA]) using the secp256k1 curve, however, other signature algorithms such as P256 and RSA are supported. ==== Ethereum Signatures (secp256k1) -xref:api:utils.adoc#ECDSA[`ECDSA`] provides functions for recovering and managing Ethereum account ECDSA signatures. These are often generated via https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#sign[`web3.eth.sign`], and are a 65 byte array (of type `bytes` in Solidity) arranged the following way: `[[v (1)], [r (32)], [s (32)]]`. +xref:api:utils.adoc#ECDSA[`ECDSA`] provides functions for recovering and managing Ethereum account ECDSA signatures. These are often generated through https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#sign[`web3.eth.sign`], and are a 65 byte array (of type `bytes` in Solidity) arranged the following way: `[[v (1)], [r (32)], [s (32)]]`. The data signer can be recovered with xref:api:utils.adoc#ECDSA-recover-bytes32-bytes-[`ECDSA.recover`], and its address compared to verify the signature. Most wallets will hash the data to sign and add the prefix `\x19Ethereum Signed Message:\n`, so when attempting to recover the signer of an Ethereum signed message hash, you'll want to use xref:api:utils.adoc#MessageHashUtils-toEthSignedMessageHash-bytes32-[`toEthSignedMessageHash`]. @@ -34,7 +34,7 @@ WARNING: Getting signature verification right is not trivial: make sure you full P256, also known as secp256r1, is one of the most used signature schemes. P256 signatures are standardized by the National Institute of Standards and Technology (NIST) and it's widely available in consumer hardware and software. -These signatures are different to regular Ethereum Signatures (secp256k1) in that they use a different elliptic curve to perform operations but have similar security guarantees. +These signatures are different to regular Ethereum Signatures (secp256k1) in that they use different elliptic curve to perform operations but have similar security guarantees. [source,solidity] ---- @@ -245,9 +245,9 @@ function _hashFn(bytes32 a, bytes32 b) internal view returns(bytes32) { === Packing -The storage in the EVM is shaped in chunks of 32 bytes, each of this chunks is known as _slot_, and can hold multiple values together as long as these values don't exceed its size. These properties of the storage allows for a technique known as _packing_, that consists of placing values together on a single storage slot to reduce the costs associated to reading and writing to multiple slots instead of just one. +The storage in the EVM is shaped in chunks of 32 bytes, each of these chunks is known as _slot_, and can hold multiple values together as long as these values don't exceed their size. These properties of the storage allow for a technique known as _packing_, that consists of placing values together on a single storage slot to reduce the costs associated to reading and writing to multiple slots instead of just one. -Commonly, developers pack values using structs that place values together so they fit better in storage. However, this approach requires to load such struct from either calldata or memory. Although sometimes necessary, it may be useful to pack values in a single slot and treat it as a packed value without involving calldata or memory. +Commonly, developers pack values using structs that place values together so they fit better in storage. However, this approach requires loading such a struct from either calldata or memory. Although sometimes necessary, it may be useful to pack values in a single slot and treat it as a packed value without involving calldata or memory. The xref:api:utils.adoc#Packing[`Packing`] library is a set of utilities for packing values that fit in 32 bytes. The library includes 3 main functionalities: From dae4312d61319fcecd2b57155a388846648af1a9 Mon Sep 17 00:00:00 2001 From: Akash Bansal Date: Mon, 15 Jul 2024 17:35:38 +0530 Subject: [PATCH 2/3] Update ECDSA documentation to reference ethers and viem libraries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit updates the ECDSA documentation to reference the more current `ethers` and `viem` libraries for generating Ethereum account ECDSA signatures. Changes made: - Updated reference from `web3.eth.sign` to `signMessage` function in the ethers library and viem documentation. These changes provide more relevant and up-to-date information for developers using the ECDSA functions. I have ensured that the updated links point to the correct sections of the ethers and viem documentation. Co-authored-by: Ernesto GarcĂ­a --- docs/modules/ROOT/pages/utilities.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/utilities.adoc b/docs/modules/ROOT/pages/utilities.adoc index 74fc17aaeb7..c01ec30026a 100644 --- a/docs/modules/ROOT/pages/utilities.adoc +++ b/docs/modules/ROOT/pages/utilities.adoc @@ -12,7 +12,7 @@ At a high level, signatures are a set of cryptographic algorithms that allow for ==== Ethereum Signatures (secp256k1) -xref:api:utils.adoc#ECDSA[`ECDSA`] provides functions for recovering and managing Ethereum account ECDSA signatures. These are often generated through https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#sign[`web3.eth.sign`], and are a 65 byte array (of type `bytes` in Solidity) arranged the following way: `[[v (1)], [r (32)], [s (32)]]`. +xref:api:utils.adoc#ECDSA[`ECDSA`] provides functions for recovering and managing Ethereum account ECDSA signatures. These are often generated through the https://docs.ethers.org/v6/api/providers/#Signer-signMessage[`signMessage`] function in the ethers library (https://viem.sh/docs/accounts/custom#signmessage[available for viem users] as well), and are a 65 byte array (of type `bytes` in Solidity) arranged the following way: `[[v (1)], [r (32)], [s (32)]]`. The data signer can be recovered with xref:api:utils.adoc#ECDSA-recover-bytes32-bytes-[`ECDSA.recover`], and its address compared to verify the signature. Most wallets will hash the data to sign and add the prefix `\x19Ethereum Signed Message:\n`, so when attempting to recover the signer of an Ethereum signed message hash, you'll want to use xref:api:utils.adoc#MessageHashUtils-toEthSignedMessageHash-bytes32-[`toEthSignedMessageHash`]. From 1e335ed56662d1db705f19f694e1d71afaa0dfe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20Garc=C3=ADa?= Date: Tue, 16 Jul 2024 12:37:37 +0200 Subject: [PATCH 3/3] Update docs/modules/ROOT/pages/utilities.adoc --- docs/modules/ROOT/pages/utilities.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/utilities.adoc b/docs/modules/ROOT/pages/utilities.adoc index c01ec30026a..944b785672d 100644 --- a/docs/modules/ROOT/pages/utilities.adoc +++ b/docs/modules/ROOT/pages/utilities.adoc @@ -12,7 +12,7 @@ At a high level, signatures are a set of cryptographic algorithms that allow for ==== Ethereum Signatures (secp256k1) -xref:api:utils.adoc#ECDSA[`ECDSA`] provides functions for recovering and managing Ethereum account ECDSA signatures. These are often generated through the https://docs.ethers.org/v6/api/providers/#Signer-signMessage[`signMessage`] function in the ethers library (https://viem.sh/docs/accounts/custom#signmessage[available for viem users] as well), and are a 65 byte array (of type `bytes` in Solidity) arranged the following way: `[[v (1)], [r (32)], [s (32)]]`. +xref:api:utils.adoc#ECDSA[`ECDSA`] provides functions for recovering and managing Ethereum account ECDSA signatures. These are often generated through the https://docs.ethers.org/v6/api/providers/#Signer-signMessage[`signMessage`] function in the ethers library (https://viem.sh/docs/actions/wallet/signMessage#usage[available for viem users] as well), and are a 65 byte array (of type `bytes` in Solidity) arranged the following way: `[[v (1)], [r (32)], [s (32)]]`. The data signer can be recovered with xref:api:utils.adoc#ECDSA-recover-bytes32-bytes-[`ECDSA.recover`], and its address compared to verify the signature. Most wallets will hash the data to sign and add the prefix `\x19Ethereum Signed Message:\n`, so when attempting to recover the signer of an Ethereum signed message hash, you'll want to use xref:api:utils.adoc#MessageHashUtils-toEthSignedMessageHash-bytes32-[`toEthSignedMessageHash`].