Libp2p host with same ID

Is there a way start a libp2p host always with same host ID ?

2 Likes

Definitely, how depends on your implementation. In go-libp2p instead of doing host.New(ctx) you can pass in options such as host.New(ctx, libp2p.Identity(myPrivateKey)). You’ll have to generate, store and reload the private key though. go-libp2p-core/crypto has the tools for working with cryptographic keys.

3 Likes

true. we just save the private key and used it in another host if we want to use the same hostID.