# Clef
Clef can be used to sign transactions and data and is meant as a(n eventual) replacement for Geth's account management. This allows DApps to not depend on Geth's account management. When a DApp wants to sign data (or a transaction), it can send the content to Clef, which will then provide the user with context and asks for permission to sign the content. If the users grants the signing request, Clef will send the signature back to the DApp.
This setup allows a DApp to connect to a remote Ethereum node and send transactions that are locally signed. This can help in situations when a DApp is connected to an untrusted remote Ethereum node, because a local one is not available, not synchronised with the chain, or is a node that has no built-in (or limited) account management.
Clef can run as a daemon on the same machine, off a usb-stick like [USB armory](https://inversepath.com/usbarmory), or even a separate VM in a [QubesOS](https://www.qubes-os.org/) type setup.
Check out the
* [CLI tutorial](tutorial.md) for some concrete examples on how Clef works.
* [Setup docs](docs/setup.md) for infos on how to configure Clef on QubesOS or USB Armory.
* [Data types](datatypes.md) for details on the communication messages between Clef and an external UI.
## Command line flags
Clef accepts the following command line options:
```
COMMANDS:
init Initialize the signer, generate secret storage
attest Attest that a js-file is to be used
setpw Store a credential for a keystore file
delpw Remove a credential for a keystore file
gendoc Generate documentation about json-rpc format
help Shows a list of commands or help for one command
GLOBAL OPTIONS:
--loglevel value log level to emit to the screen (default: 4)
--keystore value Directory for the keystore (default: "$HOME/.ethereum/keystore")
--configdir value Directory for Clef configuration (default: "$HOME/.clef")
--chainid value Chain id to use for signing (1=mainnet, 3=Ropsten, 4=Rinkeby, 5=Goerli) (default: 1)
--lightkdf Reduce key-derivation RAM & CPU usage at some expense of KDF strength
--nousb Disables monitoring for and managing USB hardware wallets
--pcscdpath value Path to the smartcard daemon (pcscd) socket file (default: "/run/pcscd/pcscd.comm")
--rpcaddr value HTTP-RPC server listening interface (default: "localhost")
--rpcvhosts value Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")
--ipcdisable Disable the IPC-RPC server
--ipcpath Filename for IPC socket/pipe within the datadir (explicit paths escape it)
--rpc Enable the HTTP-RPC server
--rpcport value HTTP-RPC server listening port (default: 8550)
--signersecret value A file containing the (encrypted) master seed to encrypt Clef data, e.g. keystore credentials and ruleset hash
--4bytedb-custom value File used for writing new 4byte-identifiers submitted via API (default: "./4byte-custom.json")
--auditlog value File used to emit audit logs. Set to "" to disable (default: "audit.log")
--rules value Path to the rule file to auto-authorize requests with
--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.
--stdio-ui-test Mechanism to test interface between Clef and UI. Requires 'stdio-ui'.
--advanced If enabled, issues warnings instead of rejections for suspicious requests. Default off
--help, -h show help
--version, -v print the version
```
Example:
```
$ clef -keystore /my/keystore -chainid 4
```
## Security model
The security model of Clef is as follows:
* One critical component (the Clef binary / daemon) is responsible for handling cryptographic operations: signing, private keys, encryption/decryption of keystore files.
* Clef has a well-defined 'external' API.
* The 'external' API is considered UNTRUSTED.
* Clef also communicates with whatever process that invoked the binary, via stdin/stdout.
* This channel is considered 'trusted'. Over this channel, approvals and passwords are communicated.
The general flow for signing a transaction using e.g. Geth is as follows:
![image](sign_flow.png)
In this case, `geth` would be started with `--signer http://localhost:8550` and would relay requests to `eth.sendTransaction`.
## TODOs
Some snags and todos
* [ ] Clef should take a startup param "--no-change", for UIs that do not contain the capability to perform changes to things, only approve/deny. Such a UI should be able to start the signer in a more secure mode by telling it that it only wants approve/deny capabilities.
* [x] It would be nice if Clef could collect new 4byte-id:s/method selectors, and have a secondary database for those (`4byte_custom.json`). Users could then (optionally) submit their collections for inclusion upstream.
* [ ] It should be possible to configure Clef to check if an account is indeed known to it, before passing on to the UI. The reason it currently does not, is that it would make it possible to enumerate accounts if it immediately returned "unknown account" (side channel attack).
* [x] It should be possible to configure Clef to auto-allow listing (certain) accounts, instead of asking every time.
* [x] Done Upon startup, Clef should spit out some info to the caller (particularly important when executed in `stdio-ui`-mode), invoking methods with the following info:
* [x] Version info about the signer
* [x] Address of API (HTTP/IPC)
* [ ] List of known accounts
* [ ] Have a default timeout on signing operations, so that if the user has not answered within e.g. 60 seconds, the request is rejected.
* [ ] `account_signRawTransaction`
* [ ] `account_bulkSignTransactions([] transactions)` should
* only exist if enabled via config/flag
* only allow non-data-sending transactions
* all txs must use the same `from`-account
* let the user confirm, showing
* the total amount
* the number of unique recipients
* Geth todos
- The signer should pass the `Origin` header as call-info to the UI. As of right now, the way that info about the request is put together is a bit of a hack into the HTTP server. This could probably be greatly improved.
- Relay: Geth should be started in `geth --signer localhost:8550`.
- Currently, the Geth APIs use `common.Address` in the arguments to transaction submission (e.g `to` field). This type is 20 `bytes`, and is incapable of carrying checksum information. The signer uses `common.MixedcaseAddress`, which retains the original input.
- The Geth API should switch to use the same type, and relay `to`-account verbatim to the external API.
* [x] Storage
* [x] An encrypted key-value storage should be implemented.
* See [rules.md](rules.md) for more info about this.
* Another potential thing to introduce is pairing.
* To prevent spurious requests which users just accept, implement a way to "pair" the caller with the signer (external API).
* Thus Geth/cpp would cryptographically handshake and afterwards the caller would be allowed to make signing requests.
* This feature would make the addition of rules less dangerous.
* Wallets / accounts. Add API methods for wallets.
## Communication
### External API
Clef listens to HTTP requests on `rpcaddr`:`rpcport` (or to IPC on `ipcpath`), with the same JSON-RPC standard as Geth. The messages are expected to be [JSON-RPC 2.0 standard](https://www.jsonrpc.org/specification).
Some of these call can require user interaction. Clients must be aware that responses may be delayed significantly or may never be received if a users decides to ignore the confirm
没有合适的资源?快使用搜索试试~ 我知道了~
基于以太坊geth客户端的keccak256算法并开放出JSON-RPC接口实现功能全部资料+详细文档.zip
共1293个文件
go:905个
h:54个
json:54个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 47 浏览量
2024-11-25
21:49:57
上传
评论
收藏 61.62MB ZIP 举报
温馨提示
【资源说明】 基于以太坊geth客户端的keccak256算法并开放出JSON-RPC接口实现功能全部资料+详细文档 【备注】 1、该项目是个人高分项目源码,已获导师指导认可通过,答辩评审分达到95分 2、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 3、本项目适合计算机相关专业(人工智能、通信工程、自动化、电子信息、物联网等)的在校学生、老师或者企业员工下载使用,也可作为毕业设计、课程设计、作业、项目初期立项演示等,当然也适合小白学习进阶。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
基于以太坊geth客户端的keccak256算法并开放出JSON-RPC接口实现功能全部资料+详细文档.zip (1293个子文件)
009c5adfa4fd685caef58e1ce932fa7fb209730a 61B
0176eaf52ed014ec5c91cf4afa070dd3fd469077-1 7B
1 487B
2 487B
2850f6ccf2d7f5f846dfb73119b60e09e712783f 637B
UTC--2020-03-29T15-10-23.357757200Z--8c344131b197d986e6a075bbc332a338ab05763a 491B
36fb987a774011dc675e1b5246ac5c1d44d84d92 1KB
37ec7b55c7ba014cced204c5f9989d2d0eb9ff6d 633B
582fa92154b784daa1faa293b695fa388fe34bf1 39B
UTC--2020-06-20T07-34-18.645393000Z--f9288b1feb9769684e8e67f562a3047d535a88b1 491B
UTC--2020-03-29T15-10-15.889258400Z--07aa767f1ef2b35daf85317eeb659c8544eca8fc 491B
UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8 487B
aaa 487B
ab57cb2b2b5ce614efe13a47bc73814580f2cce8 1KB
configure.ac 15KB
Dockerfile.alltools 416B
Makefile.am 5KB
CURRENT.bak 16B
CURRENT.bak 16B
node2.bat 401B
node1.bat 389B
start_bootnode.bat 52B
init.bat 37B
r.bin 12B
tests.c 190KB
tests_exhaustive.c 19KB
secp256k1.c 19KB
bench_internal.c 13KB
org_bitcoin_NativeSecp256k1.c 12KB
lax_der_privatekey_parsing.c 5KB
bench_verify.c 4KB
lax_der_parsing.c 4KB
bench_schnorr_verify.c 2KB
gen_context.c 2KB
bench_recover.c 2KB
bench_ecdh.c 2KB
bench_sign.c 2KB
org_bitcoin_Secp256k1Context.c 404B
cb61d5a9c4896fb9658090b597ef0e7be6f7b67e 539B
headers.0000.cdat 0B
receipts.0000.cdat 0B
bodies.0000.cdat 0B
headers.0000.cdat 0B
receipts.0000.cdat 0B
bodies.0000.cdat 0B
deb.changelog 118B
bodies.cidx 6B
receipts.cidx 6B
headers.cidx 6B
bodies.cidx 6B
receipts.cidx 6B
headers.cidx 6B
qubes.Clefsign 432B
CONTRIBUTORS 173B
deb.control 704B
COPYING 1KB
deb.copyright 647B
CURRENT 16B
CURRENT 16B
CURRENT 16B
CURRENT 16B
CURRENT 16B
CURRENT 16B
data 87B
nsis.simplefc.dll 176KB
Dockerfile 432B
.dockerignore 57B
deb.docs 8B
e4303e23ca34fbbc43164a232b2caa7a3af2bf8d 1KB
empty 0B
geth.exe 57.25MB
main.exe 57.25MB
main.exe 57.22MB
f658340af009dd4a35abe645a00a7b732bc30921 20B
fd9bd350f08ee3c0c19b85a8e16114a11a60aa4e 489B
FLOCK 0B
FLOCK 0B
foo 487B
garbage 300B
.gitignore 700B
.gitignore 336B
.gitignore 256B
.gitignore 256B
.gitignore 0B
4byte.go 5.69MB
genesis_alloc.go 818KB
module_dashboard.go 499KB
bindata.go 298KB
bind_test.go 177KB
blake2b_test.go 108KB
blockchain_test.go 88KB
contracts_test.go 88KB
blockchain.go 88KB
algorithm_test.go 80KB
tx_pool_test.go 69KB
downloader.go 68KB
api.go 64KB
downloader_test.go 62KB
algorithm.go 61KB
flags.go 59KB
共 1293 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
Yuki-^_^
- 粉丝: 3100
- 资源: 1817
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功