Open ralexstokes opened 4 years ago
I'm thinking if it makes sense to provide persisting versions of KeyStore
, PeerStore
, ...etc. It can be passed into initialize_default_swarm
as the parameter peerstore_opt
. For reference, go-ipfs has FSKeystore
whose backend is a file.
oh yeah -- i think we definitely want these as well! i'd expect we are workings towards parity w/ the Go implementation feature-wise -- more a question of what resources get dedicated to this repo and on what timeframe.
when i opened this issue, i definitely had the specific use case in mind for trinity/eth2
Implemented something similar in aleph-im/pyaleph, coming from configuration or file (if the key is there, load it, if it's none, and a listening host, print out the key to prompt user to save it. If not listening, a new host id isn't an issue): https://github.com/aleph-im/pyaleph/blob/22b06c02b82f0759b81142156ad3b978aee485c4/src/aleph/services/p2p/manager.py#L16
We are currently missing the ability to persist node identities b/t runs of a node.
The user should provide a "key pair provider" when creating a host; I'd expect the type to be
Callable[[], libp2p.crypto.keys.KeyPair]
for maximum flexibility.There are different methods of providing key pairs based on the "lifetime" of the key pair:
New key pair for some cryptosystem; for example, the user provides a function with the above signature that returns the result of
libp2p.crypto.rsa.create_new_key_pair
with the key parameters passed in via closure, curry, etc.Loading a persisted key pair where the user provides a path to a serialized key pair which the library then loads into memory; for example, a callable that closes over the path which, when called does the necessary IO to load and return a
KeyPair
object.Having persistence opens some questions:
Serialization/keystore format
How to manage multiple key pairs and select b/t them... I'd think the nice thing is to "auto-save" every key pair the library makes at some default keystore path -- the user then needs a way to specify one key from this keystore.