Question about the peer_id concept

Hello there,

I’m new to libp2p, I have been following libp2p tutorial: Build a peer-to-peer app in Rust - LogRocket Blog

What I have in mind is implementing a chat app using libp2p + floodsub. But I’m not very clear if it is safe to share the same public/private key set and also the same peer_id among clients belonging to the same person?

For example, say I have two machines, one laptop, and one desktop. On both, I want to run this chat app. I’d like their content to be in sync.

scenario 1: if I send a message via client 1, will both clients receive the replied message back addressed to the shared peer_id?

scenario 2: if I send a message via client 1, will client 2 see the message? Because I’d like to update client 2 so that its internal state can be in sync with client 1.

scenario 3: if another peer sends a message to the same peer_id shared by client 1 and 2, will both of them receive the same message?


I did some experiments,

my conclusion is that clients can’t share the same peer_id.