crossbario / crossbar

Crossbar.io - WAMP application router
https://crossbar.io/
Other
2.05k stars 274 forks source link

Expand node keys with secp256k1 #1988

Closed oberstet closed 2 years ago

oberstet commented 2 years ago

we have code to generate new node keys:

https://github.com/crossbario/crossbar/blob/master/crossbar/common/key.py

which is used generating node keys using CLI:

CROSSBAR_NODE_ID=core3 CROSSBAR_NODE_CLUSTER_IP=core3 crossbar edge keys \
    --cbdir=${STACKDIR}/nodes/core3/.crossbar

which produces (no worries, this is throw-away key material):

(cpy39_1) (base) oberstet@intel-nuci7:~/scm/typedefint/crossbar-cluster/stack$ cat /home/oberstet/scm/typedefint/crossbar-cluster/stack/.recordevolution/nodes/core3/.crossbar/key.pub
Crossbar.io node public key

creator: oberstet@intel-nuci7
created-at: 2022-04-08T11:55:30.539Z
machine-id: 816b4b901e774fc1ad59cbf2719806b7
node-authid: core3
node-cluster-ip: core3
public-key-ed25519: 6a5f441abab159ffed64e02e5e7619db3590f7be9d94d5e44dd2e44a86d50579
(cpy39_1) (base) oberstet@intel-nuci7:~/scm/typedefint/crossbar-cluster/stack$ cat /home/oberstet/scm/typedefint/crossbar-cluster/stack/.recordevolution/nodes/core3/.crossbar/key.priv 
Crossbar.io node private key - KEEP THIS SAFE!

creator: oberstet@intel-nuci7
created-at: 2022-04-08T11:55:30.539Z
machine-id: 816b4b901e774fc1ad59cbf2719806b7
node-authid: core3
node-cluster-ip: core3
public-key-ed25519: 6a5f441abab159ffed64e02e5e7619db3590f7be9d94d5e44dd2e44a86d50579
private-key-ed25519: a32704ef1bce21e8c8c2856e3e6ea1d7695c44c8f43e8c759f3818fd1ac9e966

in addition to above

each node should have

Ethereum uses ECDSA based signatures with curve secp256k1 and hash keccak256

code already exists in crossbar here:

https://github.com/crossbario/crossbar/blob/ca8d383f01231e2b3f986e791f215f12f2deee5d/crossbar/edge/worker/xbr/_marketmaker.py#L125

however, we should move that code into the general node key setup

_eth_privkey_raw = os.urandom(32)
_eth_privkey = eth_keys.keys.PrivateKey(_eth_privkey_raw)
_eth_acct = Account.privateKeyToAccount(_eth_privkey_raw)
_eth_adr_raw = self._eth_privkey.public_key.to_canonical_address()
_eth_adr = web3.Web3.toChecksumAddress(_eth_adr_raw)
oberstet commented 2 years ago

normal node keys are store in CBDIR in files:

for the node's eth keys we might use file names:

oberstet commented 2 years ago

coming via https://github.com/crossbario/crossbar/pull/1991

oberstet commented 2 years ago

fixed via 22.4.1. here is an example:

(cpy39_1) (base) oberstet@intel-nuci7:~/scm/crossbario/crossbar-examples/authentication$ cat wampcra/static/.crossbar/key.pub 
Crossbar.io node public key

creator: oberstet@intel-nuci7
created-at: 2022-04-15T05:41:00.456Z
machine-id: 816b4b901e774fc1ad59cbf2719806b7
node-authid: intel-nuci7
node-cluster-ip: 127.0.0.1
public-key-ed25519: c71289fe71920793da6c95086cc71dafd96aeaa171831154f5a5301a6fc20387
(cpy39_1) (base) oberstet@intel-nuci7:~/scm/crossbario/crossbar-examples/authentication$ cat wampcra/static/.crossbar/key.priv 
Crossbar.io node private key - KEEP THIS SAFE!

creator: oberstet@intel-nuci7
created-at: 2022-04-15T05:41:00.456Z
machine-id: 816b4b901e774fc1ad59cbf2719806b7
node-authid: intel-nuci7
node-cluster-ip: 127.0.0.1
public-key-ed25519: c71289fe71920793da6c95086cc71dafd96aeaa171831154f5a5301a6fc20387
private-key-ed25519: edbce3af8c8952928d64c6c9658f66e594ec1b13d170071416aee2174ffa0f5c