You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/clef/rules.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,14 @@ It enables usecases like the following:
9
9
10
10
The two main features that are required for this to work well are;
11
11
12
-
1. Rule Implementation: how to create, manage and interpret rules in a flexible but secure manner
13
-
2. Credential managements and credentials; how to provide auto-unlock without exposing keys unnecessarily.
12
+
1. Rule Implementation: how to create, manage, and interpret rules in a flexible but secure manner
13
+
2. Credential management and credentials; how to provide auto-unlock without exposing keys unnecessarily.
14
14
15
15
The section below deals with both of them
16
16
17
17
## Rule Implementation
18
18
19
-
A ruleset file is implemented as a `js` file. Under the hood, the ruleset-engine is a `SignerUI`, implementing the same methods as the `json-rpc` methods
19
+
A ruleset file is implemented as a `js` file. Under the hood, the rulesetengine is a `SignerUI`, implementing the same methods as the `json-rpc` methods
20
20
defined in the UI protocol. Example:
21
21
22
22
```js
@@ -27,7 +27,7 @@ function asBig(str) {
27
27
returnnewBigNumber(str)
28
28
}
29
29
30
-
// Approve transactions to a certain contract if value is below a certain limit
30
+
// Approve transactions to a certain contract if the value is below a certain limit
31
31
functionApproveTx(req) {
32
32
var limit =big.Newint("0xb1a2bc2ec50000")
33
33
var value =asBig(req.transaction.value);
@@ -70,7 +70,7 @@ The Otto vm has a few [caveats](https://github.com/robertkrimen/otto):
70
70
Additionally, a few more have been added
71
71
72
72
* The rule execution cannot load external javascript files.
73
-
* The only preloaded library is [`bignumber.js`](https://github.com/MikeMcl/bignumber.js) version `2.0.3`. This one is fairly old, and is not aligned with the documentation at the github repository.
73
+
* The only preloaded library is [`bignumber.js`](https://github.com/MikeMcl/bignumber.js) version `2.0.3`. This one is fairly old, and is not aligned with the documentation at the GitHub repository.
74
74
* Each invocation is made in a fresh virtual machine. This means that you cannot store data in global variables between invocations. This is a deliberate choice -- if you want to store data, use the disk-backed `storage`, since rules should not rely on ephemeral data.
75
75
* Javascript API parameters are _always_ an object. This is also a design choice, to ensure that parameters are accessed by _key_ and not by order. This is to prevent mistakes due to missing parameters or parameter changes.
76
76
* The JS engine has access to `storage` and `console`.
@@ -88,8 +88,8 @@ Some security precautions can be made, such as:
88
88
89
89
##### Security of implementation
90
90
91
-
The drawbacks of this very flexible solution is that the `signer` needs to contain a javascript engine. This is pretty simple to implement, since it's already
92
-
implemented for `geth`. There are no known security vulnerabilities in, nor have we had any security-problems with it so far.
91
+
The drawback of this very flexible solution is that the `signer` needs to contain a javascript engine. This is pretty simple to implement since it's already
92
+
implemented for `geth`. There are no known security vulnerabilities in it, nor have we had any securityproblems with it so far.
93
93
94
94
The javascript engine would be an added attack surface; but if the validation of `rulesets` is made good (with hash-based attestation), the actual javascript cannot be considered
95
95
an attack surface -- if an attacker can control the ruleset, a much simpler attack would be to implement an "always-approve" rule instead of exploiting the js vm. The only benefit
@@ -105,7 +105,7 @@ It's unclear whether any other DSL could be more secure; since there's always th
105
105
106
106
## Credential management
107
107
108
-
The ability to auto-approve transaction means that the signer needs to have necessary credentials to decrypt keyfiles. These passwords are hereafter called `ksp` (keystore pass).
108
+
The ability to auto-approve transactions means that the signer needs to have the necessary credentials to decrypt keyfiles. These passwords are hereafter called `ksp` (keystore pass).
109
109
110
110
### Example implementation
111
111
@@ -127,8 +127,8 @@ The `vault.dat` would be an encrypted container storing the following informatio
127
127
128
128
### Security considerations
129
129
130
-
This would leave it up to the user to ensure that the `path/to/masterseed` is handled in a secure way. It's difficult to get around this, although one could
131
-
imagine leveraging OS-level keychains where supported. The setup is however in general similar to how ssh-keys are stored in `.ssh/`.
130
+
This would leave it up to the user to ensure that the `path/to/masterseed` is handled securely. It's difficult to get around this, although one could
131
+
imagine leveraging OS-level keychains where supported. The setup is however, in general, similar to how ssh-keys are stored in `.ssh/`.
132
132
133
133
134
134
# Implementation status
@@ -149,7 +149,7 @@ function big(str) {
149
149
// Time window: 1 week
150
150
varwindow=1000*3600*24*7;
151
151
152
-
// Limit: 1 ether
152
+
// Limit: 1 ether
153
153
var limit =newBigNumber("1e18");
154
154
155
155
functionisLimitOk(transaction) {
@@ -163,7 +163,7 @@ function isLimitOk(transaction) {
163
163
if (stored !="") {
164
164
txs =JSON.parse(stored)
165
165
}
166
-
// First, remove all that have passed out of the time-window
166
+
// First, remove all that has passed out of the timewindow
167
167
var newtxs =txs.filter(function(tx){returntx.tstamp> windowstart});
168
168
console.log(txs, newtxs.length);
169
169
@@ -174,7 +174,7 @@ function isLimitOk(transaction) {
0 commit comments