Ethereum: ECDSA: (v, r, s), what is v?

Understand the Ethereum ECDSA signature format

When signing transactions on the Ethereum network, with particular reference to the Elliptical Curve Digital Signature Algorithm (ECDSA), combined with the recovery check function (RFC6979), you have a special format. In this article, we immerseize the details of the “values ​​used in” V “,R "and" Ethereum ECDSA Signature.

Overview of ECDSA signature format

Before immersing into the characteristics of the value of "V", it is essential to understand how ECDSA works in the context of Ethereum. ECDSA is a digital signature scheme that uses elliptical curve cryptography to justify the credibility and integrity of messages. In Ethereum, ECDSA is used together by the restore control function (RFC6979) to sign transactions.

Definition ofv

When you determine the value of "V", it is essential to understand what this value means. According to the specified code detail,v = 27 + (y % 2)calculatesv. In other words, this formula adds two important ingredients:

  • Result of "Y % 2 : This section determines whether” signed “or non -written transaction has been created.

  • Value of “V”

    : This final calculation gives the full signature value used to sign the RFC6979 transactions.

Interpreting parity in ECDSA signatures

ECDSA signatures use two values, “R” and scent, which are produced on the basis of a private key provided by the user. The “parity” of these values ​​is essential in understanding how they contribute to the general signature value. According to Ethereum documentation:

  • If y % 2 == 0, the result of the calculation of v” will increase by one.

  • This means that if you use a usual ECDSA implementation, such as Pycryptodome and generate “Rand S based on the private key (which must be produced by PKCS#1 v1″ E ” used signature schema) and then to determine the parity of the Values ​​of “V” 2.

Example

To illustrate this, consider an example where we generate a new transaction using Pycryptodome and RFC6979. In our case, we use a private key with a generalized public exponent.

`Python

Import Pyecdsse

Def generate_keypair ():

Ethereum: ECDSA: (v, r, s), what is v?

Generate a new RSA pair

Key = Pyecdsse.rsApivatey.Generate (2048)

Find out private and public exponents

E, D = Pyecdsse.rsspublickey.get_exponent (key)

Return (key, pyecdsse.ecdapublickey (E = E))

Suppose you have a public key to which 27: e:

`Python

Def Generate_public_key (Key):

Find out private and public exponents

D = Pyecdsse.rsApivatey.Generate (2048)

Return (key, pyECDSSE.ECDSAPULICKEY (D = D))

Make a new key pair with a generated E value with 27.

(Key, ECPS) = Generate_keypair ()

Print ("E:", ECPS.E)

Print ("D:", ECPS.D)

We can use them to produce Pycryptodome with the values ​​of “E” and D:

Python

Derives the public exponence

public_exponent = pyecdsse.ecdsiplickey (E = 27, d = d) .get_public_exponent ()

Print ("Public Exponent:", Public_Exponent)

Now we can calculate the value of “V” based on the parity of our values.

Calculation of V

“ Python

Calculate v = 27 + (y % 2) for all transactions.

For TX in transactions:

Signature = Pyecdsse.ecdasignature.generate (ECPS, TX)

Extract state and private persons from signature

Signature_Public_Exponent = Signature.get_public_Exponent ()

Signature_Private_Exponent = Signature.get_Private_Exponent ()

Check that the transaction is signed to -e

If Signature_Public_Exponent <0:

Print (“The transaction is signed.

Ethereum Reset Wallet Bitcoin

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

เราใช้คุกกี้เพื่อพัฒนาประสิทธิภาพ และประสบการณ์ที่ดีในการใช้เว็บไซต์ของคุณ คุณสามารถศึกษารายละเอียดได้ที่ นโยบายความเป็นส่วนตัว และสามารถจัดการความเป็นส่วนตัวเองได้ของคุณได้เองโดยคลิกที่ ตั้งค่า

ตั้งค่าความเป็นส่วนตัว

คุณสามารถเลือกการตั้งค่าคุกกี้โดยเปิด/ปิด คุกกี้ในแต่ละประเภทได้ตามความต้องการ ยกเว้น คุกกี้ที่จำเป็น

ยอมรับทั้งหมด
จัดการความเป็นส่วนตัว
  • เปิดใช้งานตลอด

บันทึกการตั้งค่า