optimism-java / shisui

Ethereum Portal Network Client written in Go
https://www.ethportal.net/clients/shisui
GNU Lesser General Public License v3.0
5 stars 6 forks source link

save the private key of the node #168

Open fearlessfe opened 6 days ago

fearlessfe commented 6 days ago

Rationale

Why should this feature exist?

Every time you run shisui client, it will generate a private key for the client even if you restart the client. That means every time you start a client, it will be a new node.

Implementation

Do you have ideas regarding the implementation of this feature?

Try to read the key in data dir, If the key path is not exist, create a new key, or read key from file

r4f4ss commented 2 days ago

@GrapeBaBa please assign me

r4f4ss commented 2 days ago

The public key of the node is used to form its ID. The private key, according to PortalNetworks is used to prevent impersonation:

Nodes generate a private key for the purpose of node discovery. This is used to sign the ENR to prevent impersonation. Peers can encrypt messages for each other using the ENR.

then it should be ideally password protected.

My purpose is to use the file "nodekey" in data.dir directory to store the private key not encrypted, and create a new flag --nodekey.file with value <file name>:<password>.

The usage is the follow:

  1. If flag --nodekey.file is omitted 1.1 - when starting, Shisui looks for a key in the file "nodekey", if there is not it creat a new private key 1.2 - when quitting, if the file "nodekey" do not exist Shisui create the file and saves the private key
  2. If flag --nodekey.file <file>:<password> is present 2.1 - when starting, Shisui looks for a key in the password protected file \<file>, if there is not it creat a new private key 2.2 - when quitting, if the file \<file> do not exist Shisui create the file and saves the private key with password protection

This is my idea, any feedback is welcome!

EDIT: note that --private.key should be removed in this proposal

fearlessfe commented 1 day ago

I think we can just store the key in the datadir, such as geth and trin(another portalnetwork client impl by rust) do