Skip to content

Conversation

@King31T
Copy link
Contributor

@King31T King31T commented Jan 7, 2026

No description provided.

* **计算 `v`**`v` 值是恢复标志符,由于 `r` 值有取模运算以及椭圆曲线的对称性,如果只有 `r` 值,一个 `r` 最多可以恢复出四个 `K``v` 值的取值范围是 `0、1、2、3` 四个整数,历史上为了和以太坊保持一致,最后的 `v` 值会在 `0、1、2、3` 的基础上再加 `27`,即最后 `v` 值的取值范围是 `27、28、29、30`。有了确定的 `v`,就可以恢复出唯一的 `K``v` 为 1 个字节。

4. 将签名结果 `r``s``v` 拼接后添加到交易中,拼接顺序为 `v || r || s`
4. `r``s``v` 值拼接后得到完整的签名值添加到交易中,拼接顺序为 `r || s || v`。需要注意的是拼接时不对`v`值作加`27`处理,使用标准的`0、1、2、3`
Copy link
Contributor

Choose a reason for hiding this comment

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

新加部分是不是可以去掉?因为TRON 签名的 v 可以为0、1 或 27、28 两种。是否可以改一下第3步中的 计算v值 那里?

Choose a reason for hiding this comment

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

签名如果以r s v结构出现的话 也就是sig.v值是标准值加27 如果签名以拼接形式出现也就是在交易里看到的那种 是以标准值作为拼接元素。一般代码里看到的v都是加了27的,标准值的时候一般叫recID。不过这个建议很好,拼接的描述用recID更好,而不是v值不作加27处理的描述,然后v值的计算那儿先写就算recId,再对recid作加27处理得到v值。

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