Skip to content

Conversation

@King31T
Copy link
Contributor

@King31T King31T commented Jan 7, 2026

…add an additional note.

* **Calculate the `r` value**: Randomly generate a temporary private key `k`, calculate the temporary public key `K = k × G` (`G`: curve base point), `r = K_x mod n`, that is, the abscissa of `K` modulo `n`, where `n` is the curve order (`n` and `G` satisfy `n × G = O`, and `O` is the zero point of the elliptic curve group on the finite field). `r` is 32 bytes.
* **Calculate the `s` value**: First calculate the modular inverse of the temporary private key `k` with respect to n, `k⁻¹`, that is, `k⁻¹` satisfies `k⁻¹ × k = 1 mod n`, then calculate the `s` value through the transaction's `hash`, the user's private key `d`, and the `r` value, `s = (k⁻¹ × (hash + d × r)) mod n`. `s` is 32 bytes.
* **Calculate the `v` value**: The `v` value is the recovery identifier. Since the `r` value undergoes a modulo operation and the symmetry of the elliptic curve, if there is only the `r` value, one `r` can recover up to four `K`s. The value range of `v` is four integers: `0, 1, 2, 3`. Historically, to be consistent with Ethereum, the final `v` value will be 27 added to `0, 1, 2, 3`, that is, the final value range of `v` is `27, 28, 29, 30`. With a determined `v`, the unique `K` can be recovered. `v` is 1 byte.
* **Calculate the `v` value**: Calculate the `recoveryId` first. Since the `r` value undergoes a modulo operation and the symmetry of the elliptic curve, if there is only the `r` value, one `r` can recover up to four `K`s. The value range of `recoveryId` is `0, 1, 2, 3`. The calculation of `v` value depends on `recoveryId`, historically, to be consistent with Ethereum, the `v` value will be `27` added to `recoveryId`, that is, the value range of `v` is `27, 28, 29, 30`. With a determined `v`, the unique `K` can be recovered. `v` is 1 byte.
Copy link
Contributor

@GordonLtron GordonLtron Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some grammar suggestions;

Calculate the v value: Calculate the recoveryId first. Since the r value undergoes a modulo operation and the symmetry of the elliptic curve,

->>>>

Calculate the v value: Calculate the recoveryId first. Due to the modulo operation on the 'r' value and the symmetry of the elliptic curve,


, historically, to be consistent with Ethereum,

->>>>

. Historically, to remain consistent with Ethereum,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx. These grammatical errors, including the ones mentioned below, have been corrected.

* **Calculate the `v` value**: Calculate the `recoveryId` first. Since the `r` value undergoes a modulo operation and the symmetry of the elliptic curve, if there is only the `r` value, one `r` can recover up to four `K`s. The value range of `recoveryId` is `0, 1, 2, 3`. The calculation of `v` value depends on `recoveryId`, historically, to be consistent with Ethereum, the `v` value will be `27` added to `recoveryId`, that is, the value range of `v` is `27, 28, 29, 30`. With a determined `v`, the unique `K` can be recovered. `v` is 1 byte.

4. Append the concatenated signature results `r`, `s`, `v` to the transaction, in the order `v || r || s`.
4. Concatenate the values of `r`, `s`, and `recoveryId` or `r`, `s`, and `v` to obtain the complete signature. The concatenation order shall be `r || s || recoveryId` / `r || s || v`. At present, both the transaction signing in the official client `wallet-cli` and the block signing in `java-tron` (during block production by SRs) adopt the scheme of concatenating the `recoveryId`, i.e., `signature = r || s || recoveryId`.
Copy link
Contributor

@GordonLtron GordonLtron Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4.Concatenate the values of r, s, and recoveryId or r, s, and v
->>>>
4.Concatenate the values of r, s, and recoveryId (or r, s, and v)

shall be r || s || recoveryId / r || s || v.
->>>>
is either r || s || recoveryId or r || s || v.

adopt the scheme of concatenating the recoveryId, i.e., signature = r || s || recoveryId.
->>>>
adopt the recoveryId scheme, i.e., signature = r || s || recoveryId.

Copy link
Contributor

@vivian1912 vivian1912 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants