Ethereum: Recovering ECDSA public key from the signature


Ethereum: Recovering ECDSA public key from the signature

Recovery of ECDSA Public Key from Signature: Step by Step Guide

Ethereum, as a decentralized platform built above Bitcoin blockchain, uses an algorithm of the digital signature of the elliptical curve (ECDSA) for safe communication and processing of transactions. In this article, we will explore how to reclaim the public key associated with a particular signature of ECDS.

Understanding ECDSA base

Before you immerse yourself in the solution, we quickly examine some basic concepts:

* Public key : A couple of keys used to authenticate and disobey: public key (for example, x) and a private key (for example ‘y).

* Signature : a digital print that checks the message is not stunned during the transfer.

* Hash Function: a one -way function used to create a series of features with fixed dimensions (known as hash) from arbitrary entrance.

Recovery of ECDSA Public Key from Signature

In order to regain the public key, we need to get a proper private key. This is generally performed using the following steps:

  • Get a raw signature : Get a raw signature that is a non -informed signature message.

  • Decritography Signature

    Ethereum: Recovering ECDSA public key from the signature

    : Use the function of deciphering (for example,Ecdsa_signo ecdsa_recover) to decipher the signature, which reveals a private key.

  • Say the public key : Once a private key is obtained, use it to pull out the appropriate public key.

PASSO-STEP SOLUTION

Here's a detailed example of how to regain the public key of the ECDS from a particular signature:

Python

Matters hashlib

Import structure

Def Decrypt_signature (signature):

“” “” “

Raw signature and returns a private key for decorists.

ARGS:

Signature (byte): raw signature.

Return:

Byte: private key deciphered.

“” “” “

Take out the length of the signature

Signature_len = int.from_bytes (signature [: 32], byteorder = ‘Big’)

Decortors Signature using ECDSA Deciphering Function

Public_key, _ = Stuct.unpack (‘! BBH’, Signature [32: 1024])

Return Public_key

Def Get_private_KEY (Public_key):

“” “” “

Gets a private key from a particular public key.

ARGS:

Public_key (byte): public key.

Return:

Byt: appropriate private key.

“” “” “

Stand out ECDSA parameters

N, x, _ = Stuct.unpack (‘! BBH’, Public_key [: 32])

Calculate a private key using RSA function

Private_key = Power (x, (n – 1) % 2, n)

Return private_key

Example of use:

Signature = b ‘\ x01 \ x02 \ x03 \ x04 \ x05’

Replace with a real signature

Public_key = decrypt_signature (signature)

Private_KEY = Get_private_KEY (Public_key)

Press (Private_key)

output: appropriate private key

`

Note : In this example, we use the comparable function ofecdsa_sign` (which is not implemented here). You should replace it with effective implementation that provides similar functionality. In addition, it is necessary to ensure that you have shelves for books and tools to encrypt the necessary in the system.

Following these steps, you can regain the public key of the ECDS from a particular signature to Ethereum Blockchain or any other ECDSA -based platform.

BINANCE BEP2

Leave a Reply

Your email address will not be published. Required fields are marked *