Introduction
Bitcoin is often marketed as digital money, but this is a controversial claim. If Alice pays Bob ten dollars in cash, Bob does not know where the money came from. If he then wants to give them to Carol, she will not be able to know that Alice once had them.
Bitcoin is distinguished by its public nature. The history of a given coin (more precisely, the unspent transaction output or UTXO) can be legally viewed by anyone. This concept is similar to recording the transaction amount and the names of the parties for each transaction.
However, public address aliases make it difficult to identify users. However, Bitcoin is not completely private. Blockchain analysis is becoming increasingly sophisticated and is able to link addresses to identities more and more efficiently. When combined with other tracking methods, certain organizations can de-anonymize cryptocurrency users. To avoid this, technologies for breaking ties between transactions emerged over time.
What is a Bitcoin mixer?
In a broad sense, coin mixing can mean any activity related to the obfuscation of funds and their replacement with others. In the context of cryptocurrencies, it usually refers to services provided by a third party. Typically, such services accept user funds (with a small commission) and return such coins that have no connection with the sent ones. These services are known as tumblers or mixers.
The security and anonymity of such centralized services is, of course, questionable. Users have no guarantee that they will receive their funds back or that they will not be corrupted in any way. In addition, when using the mixer, you should pay attention to the fact that IP and Bitcoin addresses can be logged by a third party. As a result, users give up control of their funds in the hope of getting back unrelated funds.
A more interesting approach exists in the form of CoinJoin transactions, which provide a greater degree of decoupling. This means that after CoinJoin, no evidence can be guaranteed to prove the user's connection with his previous transactions. Many CoinJoin solutions are decentralized alternatives to mixers. Although there may be a coordinator in the scheme, users do not have to sacrifice custody of their funds.
What is CoinJoin?
The idea of CoinJoin transactions was proposed by Bitcoin developer Gregory Maxwell in 2013. In his thread, he gave a brief description of the structure of such transactions and how an increase in the level of confidentiality can be achieved without changing the protocol.
The essence of CoinJoin is to combine the funds of several users into one transaction. Before explaining how (and why) this protocol works, let's look at the structure of a basic transaction.
Bitcoin transactions consist of inputs and outputs. When a user wants to make a transaction, he takes the UTXO as input, sets the output, and signs the input. It is important to emphasize that each input is self-signed, and users can set multiple outputs (pins to different addresses).

If we consider a given transaction with four inputs (0.2 BTC each) and two outputs (0.7 BTC and 0.09 BTC), we can make a few assumptions. Firstly, we see that the sender transfers funds to someone and returns some to himself. Since four inputs are used, the larger output is probably intended for the receiver. Please note that the outputs are missing 0.01 BTC - this is the reward to the miner.
It is also possible that the sender wants to create a larger UTXO from a smaller one in order to combine smaller inputs to obtain the desired 0.7 BTC.
Another assumption we can make is that each input is self-signed. A given transaction can have up to four parties signing the inputs. This is the principle that makes CoinJoin effective.
How does CoinJoin work?
The idea is that multiple parties will participate in the transaction, depositing funds and specifying the desired output. Because inputs become merged, it becomes impossible to tell exactly which input belongs to which user. Consider the diagram below:

There are four parties here who want to break the link between transactions. They communicate with each other (or through a special coordinator) to declare the inputs and outputs that they would like to include.
The coordinator receives all the information, includes the data in the transaction, and each participant signs it before sending it to the network. Once users confirm it, the transaction cannot be changed without becoming invalid. This way, there is no risk that the coordinator will steal the funds.
The transaction serves as a sort of black box for coin mixing. Remember that we destroy UTXO to create a new one. The only connection we have between the old and new UTXO is the transaction itself, but we cannot distinguish between its participants. At best, we can say that the participant invested funds and, perhaps, received funds as a result.
But even this is not guaranteed. Who can say, looking at the above deal, that there are four parties? Maybe it's one person sending their funds to four addresses? Or two people make two separate purchases and return 0.2 BTC to their respective addresses? Or do four people send to new members or back to themselves? We can't be sure.
Privacy through denial
The very existence of CoinJoin is enough to cast doubt on transaction analysis methods. In most cases, you can tell that CoinJoin was used, but you can't tell who the funds were transferred to. With increasing popularity, the assumption that input data belongs to a single user has become unfounded, leading to a massive surge in privacy across the ecosystem.
We said that the transaction in the previous example had an anonymity set of four inputs, the recipient of which could be any of the four participants involved. The greater the anonymity set, the less likely it is that transactions can be linked to the original owner. The newest implementations of CoinJoin allow users to securely combine their inputs with dozens of others, providing a high degree of deniability. Recently a transaction with 100 participants was successfully completed.
Conclusion
Coin mixing tools are an important addition to the arsenal of any user who takes their privacy seriously. Unlike the proposed privacy updates (such as confidential transactions), these are compatible with the protocol as it exists today.
For those who trust the reliability and methodology of third parties, a simple solution is mixing services. For those who prefer transparent and non-custodial services, CoinJoin is a suitable alternative. According to this principle, transactions can be carried out independently, if users are technically savvy, or with the help of software tools that are an abstraction of more complex mechanisms. Several such tools already exist and continue to grow in popularity as users seek greater privacy.

