I know how Tor works (mostly) but I want to know how data returns through Tor to the user. Example: I send a message from me (Bob) to my friend (Rob) and it goes to, let's say, 3 relays. Now, when I get the data back from Bob which relays does it use? The same ones? And if I sent that to a website it will send the data back to exit node. How does the exit node know who to send the traffic to? I will be using a Tor>VPN. How does the exit node route the traffic from the VPN back to me? And also since I encrypt the data when I send it and then the data gets decrypted layer by layer by the relays, who encrypts the data when it is going from a website to me? Sorry if it's long but there is no information about this anywhere. Thanks in advance.
Every step is done in reverse when the data is sent back to you from the exit relay, using the same relays. The relay knows which connection some data it receives belongs to, so it can link the data from Rob or the webserver to the original request. It then, instead of decrypting the data you sent it, encrypts it so only you can read it. Then it forwards the data to the middle relay, which will also encrypt it instead of decrypting it. Same thing at your guard relay. Then your Tor client decrypts the received data three times, and you have Rob's answer. This doesn't change whether you use a VPN or not, all the connections that your Tor client makes are bi-directional so you can send and receive data on them.
- When data is sent through a series of Onion Routers, a
Virtual Circuitis made. The data travels back through the same virtual circuit.
- The exit node knows the response is for what forward message and then does the required action based on which virtual circuit sent that message.
- Alice has a
session keyeach for Bob and Rob. So they encrypt the data on its way back to Alice using their respective keys, making Alice the only one to decrypt all the layers and access the data.