Before you send all of this, your IP and so on are "stripped" from x, and when 4 sends x to the server, it adds its IP and so on. It sees node 2's address and sends it there.
![hide my ip address website hide my ip address website](https://wethegeek.com/wp-content/themes/wethegeek/assets/products/svpn/SVPN_SS_3.jpg)
You sent this to node 1, which can decrypt only a. 2, 3, and 4 are the address' of the next node. Tor now calculates this: a(2, b(3, c(4, d(x))). You generate x, the packet you want to send. Node 1 gets key a, node 2 gets key b, etc. Let us say the packet will go through 4 nodes. Tor basically uses a cryptography process not too terribly unlike SSL as regards the mathematical procedure described above to share a separate key with each "node" your packet will travel through.
![hide my ip address website hide my ip address website](https://now.symassets.com/content/dam/norton/global/images/non-product/misc/tlc/01-ip-addresses-an-overview.png)
Thus, the client is able to send "his number" (the key used for the remainder of the session) without an eavesdropper knowing it. To be concise as to how it actually works, the server generates one number such that it is a factor of two other numbers, and then the client uses that number to operate on his number such that it would be extremely difficult to find his number without knowing the factors generated by the server.
![hide my ip address website hide my ip address website](https://www.pcmobitech.com/wp-content/uploads/2014/12/free-hide-ip-19.png)
HTTPS is a mathematical process relying on concepts that make it so that a client and a server can work out a key without ever "talking" to each other beforehand - even if an attacker is listening. OK, I have nothing to add that will actually answer your question per se, but I would like to add WHY in a bit more detail.