I am currently working on an anonymous P2P file sharing application and I am elaborating some already existing solutions. Some of them allegedly provide point-to-point encryption using RSA public/private keys to exchange a symmetric secret key, which is then used to encrypt a stream of data.

But I wonder how is it possible for two peers to safely exchange their public keys with each other without any third party (without any Certificate authority providing those public keys) and at the same time without being able to become attacked with "Man-in-the-middle" technique? (Actually some of them allow exporting generated public keys and exchange them in a "secure" way like personal meeting, phone, e-mail. But most of these P2P solutions communicate only over the wire. )

By point-to-point I mean connection between two peers, who are directly connected nodes in an P2P overlay, but can be more than one hops away from each other in a physical network.

  • $\begingroup$ Secure key exchange always requires at least one of the parties to be authenticated, or MitM attacks are possible. That said, no centralized authority is necessarily needed, see e.g. Web of trust. $\endgroup$
    – otus
    Commented Aug 16, 2014 at 12:25

1 Answer 1


You will always need to have some way of identifying the other party, be it a pre-distributed key or out-of-band procedures as you are describing. There is no purely digital method that can do this without some kind of shared knowledge.

  • $\begingroup$ Pre-distributed key - you mean for instance to provide public keys with a browser? So when I have this P2P solution, that does not pre-distribute public keys, because there are no domains. Everything is distributed and nodes can join the network dynamically. It wasn't mentioned that parties exchange public keys in some another, secure way - like personal conversation, e-mail, etc. So I'd assume that they exchange those public keys over the wire upon first connection to an another node and that in my opinion is vulnerable to Man-in-the-middle attack, isn't it? $\endgroup$
    – koleS
    Commented Aug 17, 2014 at 9:12
  • $\begingroup$ Yes, it is (vulnerable to MitM attacks), unless some kind of PKI is in place to verify the public keys. See Otus comment on Web of Trust to see how e.g. PGP handles this. $\endgroup$
    – Maarten Bodewes
    Commented Aug 17, 2014 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.