While double spending is unlikely to occur, it is not impossible.
There are actually three types of attack that in theory could cause double spending.
**
**
**
**
This attack is named after Hal Finney. Hal Finney was one of the early Bitcoin contributors and the first person ever to receive Bitcoin from Satoshi Nakamoto himself. Finney explained that a double spending attack could happen in three steps.
**
**First, the attacker performs a transaction in which he sends his coin to an address under his control. Once his action is performed, it begins mining a valid block in which the given transaction is included.
Second, the attacker includes the transaction in the block, but does not transmit it to the network. Instead, he purchases with the same number of coins that he used in the first transaction. Thus, he seeks to meet the payment of some good at service with the same amount of money.
Third, after making a transaction to the merchant, and the merchant accepting it without confirmation, the attacker transmits the mined block to the network. This action causes the network to accept the block as valid while invalidating the transaction made to the merchant.
Although it seems simple enough, this is the rarest of the rarest scenario. That is because it requires two things:
The attacker needs to be the miner of the block where his own transactions are being validated. For this, the hashing power of the attacker needs to be massive. The lower the hashing power, the lower the chances are that he will be the miner.
The merchant needs to accept a transaction with zero confirmations from the network. The second transaction that the attacker conducted with the merchant was unconfirmed. And it is unlikely that such a transaction will be accepted, and the merchant will provide his goods or services until it is confirmed.
One metaphor to explain this is to imagine a thief stealing a $100 bill and then trying to spend it at two different stores before the stores have a chance to check if the bill is counterfeit.
**
**
Race attacks are simply a race between two transactions that have been broadcast at near identical times.
Firstly, a merchant is paid with the crypto existing in the wallet. But immediately, the second transaction is initiated where the attacker transfers the same crypto to his other wallet.
The trick here is to replace the first transaction with the second transaction before the first transaction is processed on the blockchain.
But how is the second transaction preferred over the first transaction?
By adding more fees to the second transaction, usually the higher the fees, the faster the transaction is processed. And the second transaction has more fees miners have an incentive to process it first. And then the first transaction, when processed, is invalidated since there was no crypto in the wallet.
This attack also only works if the merchant accepts unconfirmed transactions, that is, it sells his goods or services before the transaction is validated by the blockchain.
One metaphor to explain this is to imagine a sprinter running a race and crossing the finish line with multiple identities, the first one to cross the finish line wins the race and the other identities are disqualified. Similarly, in a race attack, the attacker will broadcast multiple transactions, but the network will only accept the first one that it receives, while the others will be rejected.
Another metaphor could be a game of poker, where the attacker is playing with multiple hands at the same time, trying to get the best hand as fast as possible, and the network will only accept the one that gets to it first.
**
**
This attack is possibly the most difficult, but still the most straightforward attack of all. It simply involves using the power of blockchain against itself.
**
**A 51% attack on the Bitcoin network can be thought of as a hostile takeover of a company.
Just as a group of investors with 51% ownership of a company can control its direction and decisions, a group of miners with 51% of the mining power on the Bitcoin network can control which transactions are confirmed and which are not.
This allows them to double-spend their own coins, block other users' transactions, and prevent new blocks from being added to the blockchain.
It's like a group of shareholders who can control the company's direction, and can make the company's finances disappear by changing the company's books and no one can stop them from doing so.
But don't worry, that isn't easy, especially with the established blockchains like Bitcoin.
The Bitcoin network is huge and is spread across the world. A 51% attack on such a network is improbable to occur.
**
**
**
**
Now, as a general rule of safeguarding against becoming a victim of double spending attack, if you are accepting payments in the crypto, it is always important to make sure that your transaction is confirmed by the blockchain before you sell goods or services to someone.
**
**
On a final note, if Satoshi Nakamoto hadn't used blockchain technology and consensus mechanism to address the double spending problem, cryptocurrencies would never have gained a foothold. The double spending risk is now minuscule and near impossible in established blockchains like Bitcoin.
---
Embora seja improvável que o Double Spending (gasto duplo, em tradução livre) ocorra, não é impossível.
Na verdade, existem três tipos de ataque que, em teoria, podem causar Double Spending.
Este ataque tem o nome de Hal Finney. Ele foi um dos primeiros contribuidores do Bitcoin e a primeira pessoa a receber bitcoins do próprio Satoshi Nakamoto. Finney explicou que um ataque de gasto duplo poderia acontecer em três etapas.
Primeiro, o usuário realiza uma transação na qual envia sua moeda para um endereço sob seu controle. Depois que sua ação é executada, ele começa a minerar um bloco válido, no qual a transação especificada está incluída.
Em segundo lugar, o usuário inclui a transação no bloco, mas não a transmite para a rede. Em vez disso, ele usa o mesmo número de moedas que usou na primeira transação para efetuar uma compra com a mesma quantia em dinheiro da primeira transação.
Terceiro, depois de fazer uma transação para o comerciante e este aceitá-la sem confirmação, o usuário transmite o bloco minerado para a rede. Essa ação faz com que a rede aceite o bloco como válido enquanto invalida a transação feita ao comerciante.
Embora pareça bastante simples, este cenário é extremamente raro. Isso porque requer duas coisas:
O usuário precisa ser o minerador do bloco onde suas próprias transações estão sendo validadas. Para isso, ele precisa de um poder de hash muito grande. Quanto menor o poder de hash, menores são as chances de ele ser o minerador.
O comerciante precisa aceitar a transação com zero confirmações da rede. A segunda transação, que o usuário realizou com o comerciante não foi confirmada, e é improvável que tal transação seja aceita, sem esta confirmação.
Uma metáfora para explicar isso é imaginar um ladrão roubando uma nota de $ 100 e tentando gastá-la em duas lojas diferentes antes que as lojas tenham a chance de verificar se a nota é falsa.
O Race Attack é simplesmente uma corrida entre duas transações que foram transmitidas em horários quase idênticos.
Em primeiro lugar, um comerciante é pago com a criptomoeda existente na carteira. Mas, imediatamente, a segunda transação é iniciada onde o meliante transfere a mesma criptomoeda para sua outra carteira.
O truque aqui é substituir a primeira transação pela segunda, antes que a primeira seja processada na blockchain.
Mas como a segunda transação é priorizada em relação à primeira?
Adicionando mais taxas à segunda transação.
Geralmente, quanto mais altas as taxas, mais rápido a transação é processada. Quando a segunda transação possui taxas mais altas, os mineradores têm um incentivo extra para processá-la primeiro. Sendo assim, a primeira transação, assim que processada, será invalidada, pois já não haverá criptomoeda na carteira.
Mais uma vez, esse ataque também só funciona se o recebedor aceitar transações não confirmadas. Ou seja, vender seus bens ou serviços antes que a transação seja validada pela blockchain.
Uma metáfora para explicar isso é imaginar um velocista fazendo uma corrida e cruzando a linha de chegada com múltiplas identidades. O primeiro a cruzar a linha de chegada vence a corrida e as demais identidades são desclassificadas.
Da mesma forma, em um ataque de corrida, o invasor transmitirá várias transações, mas a rede aceitará apenas a primeira que receber, enquanto as outras serão rejeitadas.
Outra metáfora poderia ser um jogo de pôquer, onde um jogador está com várias mãos ao mesmo tempo, tentando obter a melhor mão o mais rápido possível, e a mesa irá aceitar a mão que o jogador apresentar primeiro.
Este ataque é possivelmente o mais difícil, porém o ataque mais direto de todos. Envolve simplesmente usar o poder do blockchain contra si mesmo.
Um ataque de 51% na rede Bitcoin é como uma aquisição hostil de uma empresa.
Assim como um grupo de investidores com 51% de propriedade de uma empresa pode controlar seus rumos e decisões, um grupo de mineradores com 51% do poder de mineração na rede Bitcoin pode controlar quais transações são confirmadas e quais não são.
Isso permite que eles gastem duas vezes suas próprias moedas, bloqueiem as transações de outros usuários e evitem que novos blocos sejam adicionados à blockchain.
É como um grupo de acionistas que pode controlar a direção da empresa e pode fazer com que as finanças da empresa desapareçam, alterando os livros e ninguém pode impedi-los de fazer isso.
Mas não se preocupe, isso não é nada fácil, especialmente em blockchains estabelecidas como o Bitcoin. A rede Bitcoin é enorme e está espalhada por todo o mundo. É improvável que ocorra um ataque de 51% a essa rede.
Agora, como regra geral de proteção contra estes ataques de gasto duplo, se você estiver aceitando pagamentos em criptomoedas, é sempre importante garantir que sua transação seja confirmada pela blockchain antes de vender bens ou serviços a alguém.
Portanto, se Satoshi Nakamoto não tivesse usado a tecnologia blockchain e o mecanismo de consenso para resolver o problema de gastos duplos, as criptomoedas nunca teriam se estabelecido. O risco de gastos duplos são mínimos e quase impossível em blockchains estabelecidas como o Bitcoin.