Introduction
Bitcoin is often referred to as digital money, but this is a dubious comparison. If Alice pays Bob ten dollars in cash, Bob will have no idea where the money came from. If he gives it to Carol later, she won't know that Alice once owned the money.
Bitcoin is distinguished by its open nature. Any coin's history (more specifically, Unspent Transaction Output or UTXO) can be easily viewed by anyone. This concept is similar to recording the amount of the deal and the names of the parties for each transaction.
However, pseudonymizing a public address ensures that the user's identity is not easily revealed. But Bitcoin is not completely private. Blockchain analysis is becoming increasingly sophisticated and capable of linking addresses with personal data more and more effectively. Along with other tracking methods, certain organizations may de-anonymize crypto users. To avoid this, over time, technologies for breaking ties between transactions appeared.
What is coin mixing?
In a broad sense, coin mixing can mean any activity related to confusing the history of funds and replacing their data. However, in the field of cryptocurrencies, coin mixing usually means a service provided by a third party. Typically, service providers take users' coins (and a small fee) and return coins that are not tied to the ones sent. These services are also known as tumblers or mixers.
The security and anonymity of such centralized services are, of course, questionable. Users have no guarantees that they will get their funds back and that they will not be corrupted in any way. In addition, when using the mixer, it is worth paying attention to the fact that intellectual property and Bitcoin addresses can be registered by a third party. As a result, users relinquish control over their funds in the hope of getting unlinked funds back.
A more interesting approach exists in the form of CoinJoin transactions, which provide a greater degree of secrecy. That is, after CoinJoin, no evidence can reliably link the user to his previous transactions. Many CoinJoin solutions are decentralized alternatives to mixers. Although the scheme may have a coordinator, users do not need to sacrifice custody of their funds.
What is CoinJoin?
CoinJoin transactions were originally proposed by Bitcoin developer Gregory Maxwell in 2013. He gave a brief description of how such transactions are structured and how increased privacy can be achieved without changing the protocol.
The essence of CoinJoin is to combine the funds of several users into one transaction. Before we explain how (and why), 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, they take their UTXOs as input, specify the output, and sign the input. It is important to emphasize that each entry is signed independently and users can set several exits (withdrawals to different addresses).

If we look at this transaction consisting of four inputs (0.2 BTC each) and two outputs (0.7 BTC and 0.09 BTC), we can make several different assumptions. First, we observe how the payment takes place - the sender sends money to someone and gets a part back. Since four inputs are used, the larger output is probably intended for the receiver. Note that the outputs are missing 0.01 BTC - this is the miner's reward.
It is also possible that the sender wants to create a large UTXO from smaller ones, so they combine the smaller inputs to get the desired result of 0.7 BTC.
Another assumption we can make is that each entry is self-signed. This transaction can have up to four different parties signing the entries. And this is the principle that makes CoinJoin effective.
How does CoinJoin work?
The idea is that there will be several parties participating in the transaction, depositing funds and specifying the desired output. As logins become merged, it becomes impossible to tell exactly which login belongs to which user. Consider the scheme below:

Here we have four participants who want to break the link between transactions. They join together (or through a special coordinator) to announce the inputs and outputs they would like to enable.
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 can be changed without becoming invalid. Therefore, there is no risk that the coordinator will run away with the funds.
Such a transaction serves as something like a black box for mixing coins. Remember that we are effectively destroying UTXOs to create new ones. 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 has provided one of the outputs and is possibly the new owner of the final output.
But even that is not guaranteed. Who would say, looking at the above transaction, that there are four participants? Maybe it's one person sending his money to four addresses? Maybe two people make two separate purchases and return 0.2 BTC each to their address? Or two people make two separate purchases and return 0.2 BTC each to their respective addresses? We cannot be sure.
Privacy by Objection
The very fact that a CoinJoin implementation exists is enough to call into question the methods used to analyze transactions. In most cases, you can understand that CoinJoin has been used, but you cannot find out who the funds have been transferred to. With the rise in popularity of CoinJoin, the assumption that input belongs to a single user has become untenable, leading to a dramatic massive increase in the privacy of the ecosystem.
We said that the transaction from the previous example had an anonymity set of four inputs that could be the recipient of any of the four participants involved. The greater the anonymity set, the less likely that transactions can be traced back to their original owner. New implementations of CoinJoin allow users to securely combine their input with dozens of others, providing a high level of deniability. A transaction for 100 people was successfully completed recently.
Final thoughts
Coin mixing tools are an important addition to the arsenal of any user who takes privacy seriously. Unlike proposed privacy updates (such as private transactions), our options are compatible with the current protocol.
For those who trust the reliability and methodology of third parties, a simple solution would be to use blending services. For those who prefer transparent and non-custodial services, CoinJoin is suitable as an alternative. This can be done manually for tech-savvy users, or with software tools that abstract away more complex mechanisms. There are already several such tools that are only growing in popularity as users seek more privacy.
