Skip to content

Wrong EIP-4844 transaction encoding for signing #2195

@mskrzypkows

Description

@mskrzypkows

When I sign EIP-4844 transaction, a blob sidecar is added, which changes the binary structure of the transaction and leads to the wrong signature.

https://eips.ethereum.org/EIPS/eip-4844#blob-transaction

The signature values y_parity, r, and s are calculated by constructing a secp256k1 signature over the following digest:

keccak256(BLOB_TX_TYPE || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data, access_list, max_fee_per_blob_gas, blob_versioned_hashes])).

In the Transaction4844::asRlpValues we have:

            List<RlpType> result = new ArrayList<>();
            result.add(new RlpList(resultTx));

            // Adding blobs, commitments, and proofs
            result.add(new RlpList(getRlpBlobs()));
            result.add(new RlpList(getRlpKzgCommitments()));
            result.add(new RlpList(getRlpKzgProofs()));

Which adds a list declaration at the beginning of RLP data, that breaks signature.

Steps To Reproduce

Here is PR to the web3singer: https://github.com/Consensys/web3signer/pull/1096/files#diff-e3e39c1cb1261aafa22d5bc9fb0e0e28d222a209801620a9242e77c37dfe259eR64
I encode first for signing and later for returning signed, encoded transaction. The signer is wrong after encoding.

Expected behavior

The signer is equal to the from transaction field after signing and deserialising the encoded EIP-4844 by eth_signTransaction

Actual behavior

The signer is some random value.

Environment

Describe the environment in which the issue occurs

  • Web3j 4.14.1
  • Java or Android version Java 21
  • Operating System Linux

Additional context

tested calling web3signer using code: Consensys/web3signer#1096 with curl:

curl -X POST http://192.168.1.25:9000 \ 
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_signTransaction",
    "params": [{
  "blobVersionedHashes": [
    "013728d4039caafea3fadd26f99fce3b5a89f772d5cc8185eeae68444c1e950b"
  ],
  "data": "47faad1400000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000580000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000e25583099ba105d9ec0a67f5ae86d90e50036425000000000000000000000000e25583099ba105d9ec0a67f5ae86d90e5003642500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000697000000000000000000000000000000000000000000000000000000006864df9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121eb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000185000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "from": "0xE25583099BA105D9ec0A67f5Ae86D90e50036425",
  "gas": "532624",
  "maxFeePerBlobGas": "2",
  "maxFeePerGas": "10041622204",
  "maxPriorityFeePerGas": "10000000000",
  "nonce": "2",
  "to": "0x61064B18219b8aE1d5dCb962cECBfA736B46d83a",
  "chainId": "3151908"
}
]
  }'

for the private key: 39725efee3fb28614de3bacaffe4cc4bd8c436257e2c8bb887c4b5c4be45e76d
so the from field after decoding should be 0xE25583099BA105D9ec0A67f5Ae86D90e50036425

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug in behaviour or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions