Skip to content

Commit fb94a8d

Browse files
authored
Merge pull request #14 from xueyuanying/feature/docs
Add ledger signing update file
2 parents a0b93f5 + c654d37 commit fb94a8d

3 files changed

Lines changed: 233 additions & 0 deletions

File tree

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
2+
# Upcoming implementation: compatibility adaptation for the v field in the signature returned after Ledger signing
3+
4+
For Ledger signing (including all transaction signatures, message signatures, and EIP-712 signatures), a new technical measure will be rolled out in the coming months. The trailing `01` in the `signature` field will be replaced with `1c`, and `00` will be replaced with `1b`.
5+
6+
This change ensures that the last two bytes of Ledger account signatures are consistent with those of regular account signatures.
7+
8+
### Transaction Signing
9+
10+
The following is a successfully signed Ledger transaction body:
11+
```json
12+
{
13+
"txID": "......",
14+
.....other property,
15+
"signature": [
16+
"......01"
17+
]
18+
}
19+
```
20+
It will become:
21+
```json
22+
{
23+
"txID": "......",
24+
.....other property,
25+
"signature": [
26+
"......1c"
27+
]
28+
}
29+
```
30+
When broadcasting, the DApp will use the modified transaction body.
31+
32+
### Message Signing
33+
34+
The DApp sends a message signing request:
35+
```javascript
36+
tron.tronWeb.trx.sign('.....unsign_string');
37+
```
38+
or
39+
```javascript
40+
tron.tronWeb.trx.signMessageV2('.....unsign_string');
41+
```
42+
43+
Actual signature hash returned by Ledger:
44+
```
45+
......50f400
46+
```
47+
48+
Modified hash:
49+
```
50+
......50f41b
51+
```
52+
53+
### EIP-712 Signing
54+
55+
The DApp sends an EIP-712 signing request:
56+
```javascript
57+
const types = {
58+
Person: [
59+
{
60+
name: 'name',
61+
type: 'string',
62+
},
63+
{
64+
name: 'wallet',
65+
type: 'address',
66+
},
67+
],
68+
Mail: [
69+
{
70+
name: 'from',
71+
type: 'Person',
72+
},
73+
{
74+
name: 'to',
75+
type: 'Person',
76+
},
77+
{
78+
name: 'contents',
79+
type: 'string',
80+
},
81+
],
82+
};
83+
84+
const primaryType = 'Mail';
85+
86+
const domain = {
87+
name: 'Ether Mail',
88+
version: '1',
89+
chainId: '0x2b6653dc',
90+
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
91+
};
92+
93+
const message = {
94+
from: {
95+
name: 'Cow',
96+
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
97+
},
98+
to: {
99+
name: 'Bob',
100+
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
101+
},
102+
contents: 'Hello, Bob!',
103+
};
104+
105+
await tron.tronWeb.trx._signTypedData(domain, types, message);
106+
```
107+
108+
Actual signature hash returned by Ledger:
109+
```
110+
.....7ee700
111+
```
112+
113+
Modified hash:
114+
```
115+
......7ee71b
116+
```
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
2+
# 即将实施:对ledger签名后signature的v字段进行兼容改造
3+
针对ledger签名(包括所有交易签名、消息签名、712签名),在将来的几个月内,会更新一项新的技术措施,会将签名后的 `signature` 字段中末尾的`01`替换成`1c``00`替换成`1b`
4+
5+
这个改动,是为了保证ledger账户签名和普通账户签名的末尾两位一致。
6+
7+
### 普通交易签名
8+
9+
以下是签名成功的 ledger 交易体:
10+
```json
11+
{
12+
"txID": "......",
13+
.....other property,
14+
"signature": [
15+
"......01"
16+
]
17+
}
18+
```
19+
会变成:
20+
```json
21+
{
22+
"txID": "......",
23+
.....other property,
24+
"signature": [
25+
"......1c"
26+
]
27+
}
28+
```
29+
如果需要广播,DApp会使用修改后的交易体进行广播
30+
31+
### 消息签名
32+
33+
DApp发送消息签名
34+
```javascript
35+
tron.tronWeb.trx.sign('.....unsign_string');
36+
```
37+
或者
38+
```javascript
39+
tron.tronWeb.trx.signMessageV2('.....unsign_string');
40+
```
41+
42+
ledger返回的实际签名hash:
43+
```
44+
......50f400
45+
```
46+
47+
经过修改后的hash:
48+
```
49+
......50f41b
50+
```
51+
52+
### 712签名
53+
54+
DApp发送712签名
55+
```javascript
56+
const types = {
57+
Person: [
58+
{
59+
name: 'name',
60+
type: 'string',
61+
},
62+
{
63+
name: 'wallet',
64+
type: 'address',
65+
},
66+
],
67+
Mail: [
68+
{
69+
name: 'from',
70+
type: 'Person',
71+
},
72+
{
73+
name: 'to',
74+
type: 'Person',
75+
},
76+
{
77+
name: 'contents',
78+
type: 'string',
79+
},
80+
],
81+
};
82+
83+
const primaryType = 'Mail';
84+
85+
const domain = {
86+
name: 'Ether Mail',
87+
version: '1',
88+
chainId: '0x2b6653dc',
89+
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
90+
};
91+
92+
const message = {
93+
from: {
94+
name: 'Cow',
95+
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
96+
},
97+
to: {
98+
name: 'Bob',
99+
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
100+
},
101+
contents: 'Hello, Bob!',
102+
};
103+
104+
await tron.tronWeb.trx._signTypedData(domain, types, message);
105+
```
106+
107+
ledger返回的实际签名hash:
108+
```
109+
.....7ee700
110+
```
111+
112+
经过修改后的hash:
113+
```
114+
......7ee71b
115+
```

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ plugins:
6565
- TronLink Wallet Extension:
6666
- Request TronLink Extension: plugin-wallet/active-requests.en.md
6767
- Receive messages from TronLink: plugin-wallet/passive-messages.en.md
68+
- Compatibility for the v field after Ledger signing: plugin-wallet/ledger-signing-update.en.md
6869
- AI Support:
6970
- MCP Server TronLink : ai-support/mcp-server-tronlink.en.md
7071
- TronLink MCP Core: ai-support/tronlink-mcp-core.en.md
@@ -89,6 +90,7 @@ plugins:
8990
- 插件钱包:
9091
- 主动请求TronLink插件功能: plugin-wallet/active-requests.zh.md
9192
- 被动接收TronLink插件的消息: plugin-wallet/passive-messages.zh.md
93+
- 对ledger签名后的v字段兼容: plugin-wallet/ledger-signing-update.zh.md
9294
- AI 支持:
9395
- MCP Server TronLink : ai-support/mcp-server-tronlink.zh.md
9496
- TronLink MCP Core: ai-support/tronlink-mcp-core.zh.md

0 commit comments

Comments
 (0)