Skip to content

Commit e9f70c9

Browse files
authored
clef: documentation generator + docs (#19020)
* clef: implement documentation generation + remove unused struct * clef: formatting + spelling * clef: updates to doc
1 parent 3fd6db2 commit e9f70c9

File tree

11 files changed

+398
-33
lines changed

11 files changed

+398
-33
lines changed

cmd/clef/README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,43 @@ Check out
1616

1717
* the [tutorial](tutorial.md) for some concrete examples on how the signer works.
1818
* the [setup docs](docs/setup.md) for some information on how to configure it to work on QubesOS or USBArmory.
19-
19+
* the [data types](datatypes.md) for detailed information on the json types used in the communication between
20+
clef and an external UI
2021

2122
## Command line flags
2223
Clef accepts the following command line options:
2324
```
2425
COMMANDS:
2526
init Initialize the signer, generate secret storage
2627
attest Attest that a js-file is to be used
27-
addpw Store a credential for a keystore file
28+
setpw Store a credential for a keystore file
29+
gendoc Generate documentation about json-rpc format
2830
help Shows a list of commands or help for one command
29-
31+
3032
GLOBAL OPTIONS:
3133
--loglevel value log level to emit to the screen (default: 4)
3234
--keystore value Directory for the keystore (default: "$HOME/.ethereum/keystore")
33-
--configdir value Directory for clef configuration (default: "$HOME/.clef")
34-
--networkid value Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby) (default: 1)
35+
--configdir value Directory for Clef configuration (default: "$HOME/.clef")
36+
--chainid value Chain id to use for signing (1=mainnet, 3=ropsten, 4=rinkeby, 5=Goerli) (default: 1)
3537
--lightkdf Reduce key-derivation RAM & CPU usage at some expense of KDF strength
3638
--nousb Disables monitoring for and managing USB hardware wallets
3739
--rpcaddr value HTTP-RPC server listening interface (default: "localhost")
40+
--rpcvhosts value Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")
41+
--ipcdisable Disable the IPC-RPC server
42+
--ipcpath Filename for IPC socket/pipe within the datadir (explicit paths escape it)
43+
--rpc Enable the HTTP-RPC server
3844
--rpcport value HTTP-RPC server listening port (default: 8550)
39-
--signersecret value A file containing the password used to encrypt signer credentials, e.g. keystore credentials and ruleset hash
45+
--signersecret value A file containing the (encrypted) master seed to encrypt Clef data, e.g. keystore credentials and ruleset hash
4046
--4bytedb value File containing 4byte-identifiers (default: "./4byte.json")
4147
--4bytedb-custom value File used for writing new 4byte-identifiers submitted via API (default: "./4byte-custom.json")
4248
--auditlog value File used to emit audit logs. Set to "" to disable (default: "audit.log")
4349
--rules value Enable rule-engine (default: "rules.json")
44-
--stdio-ui Use STDIN/STDOUT as a channel for an external UI. This means that an STDIN/STDOUT is used for RPC-communication with a e.g. a graphical user interface, and can be used when the signer is started by an external process.
45-
--stdio-ui-test Mechanism to test interface between signer and UI. Requires 'stdio-ui'.
50+
--stdio-ui Use STDIN/STDOUT as a channel for an external UI. This means that an STDIN/STDOUT is used for RPC-communication with a e.g. a graphical user interface, and can be used when Clef is started by an external process.
51+
--stdio-ui-test Mechanism to test interface between Clef and UI. Requires 'stdio-ui'.
52+
--advanced If enabled, issues warnings instead of rejections for suspicious requests. Default off
4653
--help, -h show help
4754
--version, -v print the version
48-
55+
4956
```
5057

5158

cmd/clef/datatypes.md

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
## UI Client interface
2+
3+
These data types are defined in the channel between clef and the UI
4+
### SignDataRequest
5+
6+
SignDataRequest contains information about a pending request to sign some data. The data to be signed can be of various types, defined by content-type. Clef has done most of the work in canonicalizing and making sense of the data, and it's up to the UI to presentthe user with the contents of the `message`
7+
8+
Example:
9+
```json
10+
{
11+
"content_type": "text/plain",
12+
"address": "0xDEADbEeF000000000000000000000000DeaDbeEf",
13+
"raw_data": "GUV0aGVyZXVtIFNpZ25lZCBNZXNzYWdlOgoxMWhlbGxvIHdvcmxk",
14+
"message": [
15+
{
16+
"name": "message",
17+
"value": "\u0019Ethereum Signed Message:\n11hello world",
18+
"type": "text/plain"
19+
}
20+
],
21+
"hash": "0xd9eba16ed0ecae432b71fe008c98cc872bb4cc214d3220a36f365326cf807d68",
22+
"meta": {
23+
"remote": "localhost:9999",
24+
"local": "localhost:8545",
25+
"scheme": "http",
26+
"User-Agent": "Firefox 3.2",
27+
"Origin": "www.malicious.ru"
28+
}
29+
}
30+
```
31+
### SignDataResponse - approve
32+
33+
Response to SignDataRequest
34+
35+
Example:
36+
```json
37+
{
38+
"approved": true,
39+
"Password": "apassword"
40+
}
41+
```
42+
### SignDataResponse - deny
43+
44+
Response to SignDataRequest
45+
46+
Example:
47+
```json
48+
{
49+
"approved": false,
50+
"Password": ""
51+
}
52+
```
53+
### SignTxRequest
54+
55+
SignTxRequest contains information about a pending request to sign a transaction. Aside from the transaction itself, there is also a `call_info`-struct. That struct contains messages of various types, that the user should be informed of.
56+
57+
As in any request, it's important to consider that the `meta` info also contains untrusted data.
58+
59+
The `transaction` (on input into clef) can have either `data` or `input` -- if both are set, they must be identical, otherwise an error is generated. However, Clef will always use `data` when passing this struct on (if Clef does otherwise, please file a ticket)
60+
61+
Example:
62+
```json
63+
{
64+
"transaction": {
65+
"from": "0xDEADbEeF000000000000000000000000DeaDbeEf",
66+
"to": null,
67+
"gas": "0x3e8",
68+
"gasPrice": "0x5",
69+
"value": "0x6",
70+
"nonce": "0x1",
71+
"data": "0x01020304"
72+
},
73+
"call_info": [
74+
{
75+
"type": "Warning",
76+
"message": "Something looks odd, show this message as a warning"
77+
},
78+
{
79+
"type": "Info",
80+
"message": "User should see this aswell"
81+
}
82+
],
83+
"meta": {
84+
"remote": "localhost:9999",
85+
"local": "localhost:8545",
86+
"scheme": "http",
87+
"User-Agent": "Firefox 3.2",
88+
"Origin": "www.malicious.ru"
89+
}
90+
}
91+
```
92+
### SignDataResponse - approve
93+
94+
Response to SignDataRequest. This response needs to contain the `transaction`, because the UI is free to make modifications to the transaction.
95+
96+
Example:
97+
```json
98+
{
99+
"transaction": {
100+
"from": "0xDEADbEeF000000000000000000000000DeaDbeEf",
101+
"to": null,
102+
"gas": "0x3e8",
103+
"gasPrice": "0x5",
104+
"value": "0x6",
105+
"nonce": "0x4",
106+
"data": "0x04030201"
107+
},
108+
"approved": true,
109+
"password": "apassword"
110+
}
111+
```
112+
### SignDataResponse - deny
113+
114+
Response to SignDataRequest. When denying a request, there's no need to provide the transaction in return
115+
116+
Example:
117+
```json
118+
{
119+
"approved": false,
120+
"Password": ""
121+
}
122+
```
123+
### OnApproved - SignTransactionResult
124+
125+
SignTransactionResult is used in the call `clef` -> `OnApprovedTx(result)`
126+
127+
This occurs _after_ successful completion of the entire signing procedure, but right before the signed transaction is passed to the external caller. This method (and data) can be used by the UI to signal to the user that the transaction was signed, but it is primarily useful for ruleset implementations.
128+
129+
A ruleset that implements a rate limitation needs to know what transactions are sent out to the external interface. By hooking into this methods, the ruleset can maintain track of that count.
130+
131+
**OBS:** Note that if an attacker can restore your `clef` data to a previous point in time (e.g through a backup), the attacker can reset such windows, even if he/she is unable to decrypt the content.
132+
133+
The `OnApproved` method cannot be responded to, it's purely informative
134+
135+
Example:
136+
```json
137+
{
138+
"raw": "0xf85d640101948a8eafb1cf62bfbeb1741769dae1a9dd47996192018026a0716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293a04e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed",
139+
"tx": {
140+
"nonce": "0x64",
141+
"gasPrice": "0x1",
142+
"gas": "0x1",
143+
"to": "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192",
144+
"value": "0x1",
145+
"input": "0x",
146+
"v": "0x26",
147+
"r": "0x716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293",
148+
"s": "0x4e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed",
149+
"hash": "0x662f6d772692dd692f1b5e8baa77a9ff95bbd909362df3fc3d301aafebde5441"
150+
}
151+
}
152+
```
153+
### UserInputRequest
154+
155+
Sent when clef needs the user to provide data. If 'password' is true, the input field should be treated accordingly (echo-free)
156+
157+
Example:
158+
```json
159+
{
160+
"prompt": "The question to ask the user",
161+
"title": "The title here",
162+
"isPassword": true
163+
}
164+
```
165+
### UserInputResponse
166+
167+
Response to SignDataRequest
168+
169+
Example:
170+
```json
171+
{
172+
"text": "The textual response from user"
173+
}
174+
```
175+
### ListRequest
176+
177+
Sent when a request has been made to list addresses. The UI is provided with the full `account`s, including local directory names. Note: this information is not passed back to the external caller, who only sees the `address`es.
178+
179+
Example:
180+
```json
181+
{
182+
"accounts": [
183+
{
184+
"address": "0xdeadbeef000000000000000000000000deadbeef",
185+
"url": "keystore:///path/to/keyfile/a"
186+
},
187+
{
188+
"address": "0x1111111122222222222233333333334444444444",
189+
"url": "keystore:///path/to/keyfile/b"
190+
}
191+
],
192+
"meta": {
193+
"remote": "localhost:9999",
194+
"local": "localhost:8545",
195+
"scheme": "http",
196+
"User-Agent": "Firefox 3.2",
197+
"Origin": "www.malicious.ru"
198+
}
199+
}
200+
```
201+
### UserInputResponse
202+
203+
Response to list request. The response contains a list of all addresses to show to the caller. Note: the UI is free to respond with any address the caller, regardless of whether it exists or not
204+
205+
Example:
206+
```json
207+
{
208+
"accounts": [
209+
{
210+
"address": "0x0000000000000000000000000000000000000000",
211+
"url": ".. ignored .."
212+
},
213+
{
214+
"address": "0xffffffffffffffffffffffffffffffffffffffff",
215+
"url": ""
216+
}
217+
]
218+
}
219+
```
67.6 KB
Loading
79.6 KB
Loading
99 KB
Loading
115 KB
Loading

0 commit comments

Comments
 (0)