Checking the signature at P2WPKH event: Step-by-step guide

Cryptocurrencies such as Bitcoin have gained tremendous popularity over the years, and one of the most significant safety features that affect their reliability is the process of verifying the signature business. In this article, we are considering how to check the signatures at P2WPKH (Private Transaction) at Bitcoin.

Ordinary P2PKH signatures for certification

For the standard P2PKH events, the signature verification process includes the following steps:

  • NewtraSaction : The event is created and includes the sender’s address, the address of the recipient, the amount and other relevant information.

  • Install Txout Values ​​well : Transaction sources have been resolved (ie their balances are updated) to ensure that there is sufficient funds for the event.

  • Place all TXin -scripts on the blank : All event revenue is placed in an empty script, indicating that the funds or funds are not transferred from the sender’s wallet to the recipient address.

  • Set previous locking information : The event includes the “previous lock” field, which includes the previous locking command series (eg the sender’s public key) and all related information.

Signature Digest Creating **

To check the signature at the P2WPKH event, we need to create a signature protection. Thus:

  • Create a new Transaction object : Creating a new ‘NewtraSationobject containing all the details you need.

2

  • Set all TXin scripts to blank : All event revenue is placed in an empty script.

  • Place previous locking information : The previous locking information is set to the event.

Signature Digest Generation

Signature Digest is created using encryption (eg Sha-256). The resulting hexadecimal string is used to check the signature at the following events.

Here is an example of how to create a signature digest:

Python

Bring the hashlib

Tx_outs = {“quantity”: 10.0, “scriptpubkey”: “Q1 …”}

tx_in_scripts = {}

Previous_Locking = {“public_key”: “Sender_public_key”}

New_Transaction = NewtTraSation (tx_outs = tx_outs,

tx_in_scripts = tx_in_scripts,

Previous_Locking = Previous_Locking)

Bitcoin: How does one verify signature in a P2WPKH transaction?

Create Signature with Digest SHA-256

Signature_digest = hashlib.sha256 (new_transaction.signature) .hexdigest ()

`

Checking the signature at P2WPKH event

To check the signature at the P2WPKH event, you must follow these steps:

  • Get signed information : The recipient of the event must receive a signed information containing the event ID and other relevant information.

2

  • Set txouts well

    : The outputs are settled according to the specified rules.

  • Set all TXin scripts to blank : All event revenue is placed in an empty script.

  • Set previous locking information : Previous locking information is placed at the event.

Please verify your signature at P2WPKH event

This is how to check the signature at P2WPKH:

`Python

Bring the hashlib

Signed_data = …

Tx_outs = {“quantity”: 10.0, “scriptpubkey”: signed_data}

tx_in_scripts = {}

Previous_Locking = {}

New_Transaction = NewtTraSation (tx_outs = tx_outs,

tx_in_scripts = tx_in_scripts,

Previous_Locking = Previous_Locking)

Create Signature with Digest SHA-256

Signature_digest = hashlib.sha256 (new_transaction.signature).

Ethereum Scriptsig

(Visited 1 times, 1 visits today)