I was watching this video explaining how tor works: https://youtu.be/QRYzre4bf7I
It explains it with the example of 3 intermediate nodes between client and server. It says that each of the nodes can only decrypt one layer and therefore only the last node can see the message. Each node has only one key to decrypt the corresponding layer. My question is: how is that possible?
How can node 2 know key2 unless it's given to it by node 1? But if node 1 sends key then it means that node one can also decrypt the second layer.