Blockchain – Are Transactions Signed, RLP Encoded, and Hashed Before Transmission to Blockchain

pending-transactionsraw-transactiontransactions

Using the discussion of this link: https://ethereum.org/en/developers/docs/transactions/

It seems obvious that before the transaction is transmitted over the blockchain for miners to mine, the transaction needs to be signed by the sender's private key using elliptical curve multiplication. Then, they are RLP encoded using the raw component of the response from the JASON-RPC call (please see the link).

Does this mean that only the raw component is transmitted through the Ethereum network for miners to mine?

So having said this, the procedure works as follow:

  1. The sender and receiver agree regarding the tx and set the gas price and limit, etc.
const EthereumTx = require('ethereumjs-tx').Transaction 
const privateKey = Buffer.from(   'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109',   'hex', )
const txParams = {   nonce: '0x00',   gasPrice: '0x09184e72a000',   gasLimit: '0x2710',   to: '0x0000000000000000000000000000000000000000',   value: '0x00',   data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057', }
  1. The sender signs the tx using his private key on his local device (using his wallet such as Metamask) — This can be described in the readme.md here.
// The second parameter is not necessary if these values are used
const tx = new EthereumTx(txParams, { chain: 'mainnet', hardfork: 'petersburg' })
tx.sign(privateKey)
  1. The sender serialize his/her tx using the RLP-encoding scheme
const serializedTx = tx.serialize()
  1. The sender computes the keccak-256 hash of this serialized message
  2. The hashed tx is send to the ethereum network to be mined
  3. Once mined other metadata frequently added to the transaction by client software includes the block number (once it is mined and included in the blockchain) and a transaction ID (calculated hash).

Is this how the process work? Is that the right logic? This is not clear in any textbook or anywhere online. If you know a place where this is a reference please let me know of your resource. Many thanks in advance.

Best Answer

The miners need to know everything about the transaction. The signature requires hashing using the private key. That does not mean that the RLP-encoded tx requires hashing all together but only some components of the transaction (tx). The confusion comes that once these components (require hashing) are generated the signed transaction is required to be RLP-encoded again for the miners to mine.

Therefore, the answer would be that no RLP-encoded transaction is not hashed before being transmitted into the blockchain. But before being transmitted the unsigned transaction needs to be signed (which involves hashing) then it is RLP-encoded then transmitted.

Related Topic