Ethereum: What is relation between scriptSig and scriptPubKey?

Understanding ScriptSig and scriptPubKey in Ethereum

Ethereum: What is relation between scriptSig and scriptPubKey?

In Ethereum, «scriptSig» and «scriptPubKey» are important components of a transaction feed, but they have different purposes. Let’s separate them to understand their relationship.

scriptSig: Signatures

A «scriptSig» is a signature associated with a transaction feed that is commonly used to sign transactions. It contains information about the identity of the sender and the details of the transaction. A «scriptSig» contains:

  • Signatures: The sender’s public keys are signed with their private keys to verify the transaction.
  • Timestamp: A timestamp indicating when the signature was created.
  • Data: Additional information that may be included in the transaction, such as the transaction hash or other metadata.

Here is an example of «scriptSig»:

sig =

0x... (sender's public key)

0x... (timestamp)

0x... (data)

scriptPubKey: public keys

«scriptPubKey» is a public key associated with the event feed. It represents the identity of the sender and is used to receive events.

«scriptPubKey» contains:

  • Public key: The sender’s public keys are contained in the scriptPubKey.
  • Chaincode hash

    : The hash of the chaincode (Ethereum’s blockchain code) is attached to this public key, linking it to the identity of the sender.

  • Signature: In some cases, a signature is also included in the «scriptPubKey», but this is less common.

Here is an example of «scriptPubKey»:

pubKey = 0x... (sender's public key)

chaincodeHash = 0x... (sender's chaincode hash)

Relationship between ScriptSig and scriptPubKey

Ethereum transactions use both scriptSig and scriptPubKey commands together. When a transaction is created, the sender signs it with his private key using the public key in scriptSig. This signature is then included in the «scriptPubKey» code.

The recipient of the transaction can verify this signature with his own private key associated with his public key in scriptSig, and if the information in scriptSig matches the expected information, he can be sure that the sender’s identity has been signed correctly.

In short:

  • scriptSig: Signatures that include the sender’s public key(s), a timestamp, and additional information.
  • scriptPubKey: Public keys associated with the sender’s identity, including their chaincode hash (which is associated with their identity) and signature (if any).

Understanding these two components is crucial when working with Ethereum transactions using different programming languages ​​and tools.

Ethereum Working Celo

Dejar un comentario

Tu dirección de correo electrónico no será publicada.