I'm trying to implement Tor protocol as a small project at school. I read the paper: https://svn-archive.torproject.org/svn/projects/design-paper/tor-design.pdf and related-docs. But there's a couple thing I'm questioning and can't find the answer yet.
1/ Why in Tor handshake protocol, public keys encryption are needed ? I understand that to extend relay to C through B, A need to encrypt the content with the B session key so only B know about C, preventing anyone snooping on the client gaining knowledge about the complete circuit A-B-C. But why also encrypt it with C public key ? It seems not necessary since the DH half-secret is supposed to be public, so there's nothing to hide, B can read the handshake package without problem. Even when handshaking A-B, I don't find it necessary to encrypt it with B public key for the same reason. Tor also doesn't need identification as TLS (which use public key for such purpose)
2/ Why do multiple layers needed when transporting data ? From what I understand, once the circuit established, each relay hold a circID table to figure out the next relay, so what is being transferred is only the destination package, so only 1 encryption with exit node session key is need to prevent anyone from knowing the destination ? Even if entry guard snooping, it only sees the encrypted destination package and nothing else, the only thing it can do is to send it to the next relay.
3/ The same when getting a response, why multiple encryption is needed ? It seems that 1 encryption with exit node session key is enough here.
Thank you all very much for helping.