I have been developing an application to spend some time, and I decided to make a Chat application that works under the Tor network and is P2P (something like TorChat, which is long dead as far as I know), but I have been struggling with the communication (peer identity validation, to be exact).
Here's an overview of the communication:
We have two entities, which are: Alice (sender), Bob (receiver)
- Alice sends a message to authenticate with Bob upon first interaction
- Alice will send its own Tor id (alice.onion), with a Nonce.
- Bob receives the request.
- If Bob refuses further communication with Alice, then drop the Handshake.
- Bob must now check if Alice is who it says it is, so it opens a secondary TCP channel with Alice and sends Nonce
- Alice receives Bob's request
- It verifies the Nonce it generated on the initial request to make sure someone isn't trying to eavesdrop the communication
- Finalizes the handshake.
- Handshake is complete
- Both parties will have a communication token which will be used in future communications.
Optionally: After the handshake, a public key is sent from both parties, with another layer of encryption.
My question is: is this handshake method secure from the tor network perspective? I can't know, as far as I'm aware, what is the hostname of the sender, which makes it complicated as this is the ID used for communications.
Another problem that I see with my approach is that it can be used as a way to make DDoS amplification attacks, which I also cannot see a great way of handling with that if there's two-way communication.
If it's only one socket communication between both peers (which would resolve the Amplification concern), then how can I make sure what's the sender ID?