As provided in the Chaumian Coinjoin protocol:
At the first stage, all participants in the mix provide the coordinator with the addresses from which they will pay.
For example, 3 people gave 3 addresses. Everyone connected from their own IP address
Thus the coordinator sees:
btc address A was received from IP address 1.1.1.1
btc address B was received from IP address 2.2.2.2
btc address C was received from IP address 3.3.3.3
btc address D was received from IP address 4.4.4.4
Next, each participant using a new connection (new ip) transmits to the coordinator the addresses to which they will receive the payment
address E was received from IP address 5.5.5.5
address F was received from IP address 6.6.6.6
address G was received from IP address 7.7.7.7
address H was received from IP address 8.8.8.8
The meaning of the mathematics used is that everything is organized in such a way that the coordinator can be sure that the addresses received at the second stage (E, F, G, H) belong to one of the exchange participants who registered at the first stage. This is enough to form one transaction in which Bitcoin is transferred from addresses (A, B, C, D) to addresses (E, F, G, H).
However, in the implementation of the whirlpool protocol by Samourai it looks like this:
Thus the coordinator sees:
Address A was received from IP address 1.1.1.1
Address B was received from IP address 2.2.2.2
address C was received from IP address 3.3.3.3
address D was received from IP address 4.4.4.4
Next, each participant using a new connection transmits to the coordinator the addresses to which they will receive the payment
address E was received from IP address 1.1.1.1
address F was received from IP address 3.3.3.3
address G was received from IP address 4.4.4.4
address H was received from IP address 2.2.2.2
And you don’t need any mathematics to write down which input and output belong to whom.