PayJoin (P2EP), is a type of Bitcoin transaction to enhance privacy and guarantee anonymity for the participants.
In PayJoin transactions, the sender to the recipient contributes inputs to break the "common input ownership heuristic," a prevalent assumption when analyzing blockchains to remove users' privacy and anonymity.
This type of heuristic for parsing the Bitcoin blockchain is quite common and the most commonly used. It assumes that the same person signs all the entries inside a transaction. So far, it had been a reasonably close assumption due to the little use of multi-signature addresses. However, developers proposed and created the P2EP protocol to break this assumption and improve Bitcoin's privacy.
PayJoin closely compares many types of Bitcoin scripts; P2EP is not one. Instead, it is a protocol that allows two users to conduct a transaction privately, or at least more privately than it would be without it. Using a point-to-point channel, such as an onion address, a sender and recipient can exchange information about the UTXO they would like to use as input in a transaction.
They can then construct and sign the transaction cooperatively using the Partially Signed Transaction Standard (PSBT) defined in the Bitcoin enhancement proposal called BIP 174. The result is a transaction that will resemble any typical transaction recorded inside the blockchain.
How does PayJoin work?
PayJoin is a collaborative transaction between the party receiving the funds and the party sending the funds, for example, a merchant and his customer. The main objective is to break the heuristic that assumes the inputs are from the same person while making it more difficult to determine that in quality, the transaction is a CoinJoin. Finally, it helps to reduce the commissions paid by the merchant due to the coin pooling.
The Pay to Endpoint account helps to arrange this sort of transfer. A Tor-like onion routing service or a conventional IP address is used to reach the receiver via the Internet. The transaction sender is issued a payment invoice through a link that uses the Bitcoin URI described in BIP 21. The sender connects to the recipient's server through the routing service or IP address and communicates which protocol to use from now on.
All of this coordination between the parties typically takes a few seconds. If the connection is lost, the transaction terminates a few moments later.
2. Building of a normal transaction
In the first request to the recipient's server, the sender provides a signed transaction with only the sender's input, just like any other Bitcoin transaction.
Here, the inputs are only from the sender. The outputs are the recipient's address, while the exchange address is that of the sender. Both the store and we can transmit to the Bitcoin network the transaction at any time. The only problem is that the transaction loses its privacy.
3. Creation of the Coinjoin transaction
The recipient's server responds to the initial proposal with a transaction that adds new inputs to the original one. It also increases the output of the transaction intended for him.
The sender sends the transaction to the Bitcoin network for processing.
Payjoin enabled wallets
Some wallets allow this type of transaction, although not all have the full functionality. Some only support sending, while others have all the programming logic to send and receive this type of transaction.
Advantages of PayJoin
First and foremost, the most significant benefit of this type of transaction is breaking the ownership heuristic, which implies that the entry does not belong to the same person or entity but several of them, destroying one of the fundamental assumptions surveillance-oriented companies often have.
Unlike other CoinJoin implementations, the outputs do not have the same value here, which causes the transaction to not look like a CoinJoin transaction either. On the other hand, the outputs do not reflect the actual value of the transaction. In the example we saw above, the actual monetary exchange was only 0.2 bitcoins, but the outcomes are 0.7 and 0.8 bitcoins, obfuscating the amount paid.
Finally, the recipient is also consolidating his coins, which saves him fees in the future. Without PayJoin, the recipient would have two UTXOs, one for 0.2 BTC and one for 0.5 BTC, so he will have to pay more fees to spend them. But since he has now used PayJoin, he only has one UTXO worth 0.7 BTC, which reduces the fees in the future when he has to use it.