[crypto]

THREAD

*****
BTC/BSV: 2 Blockchain Bloat Mitigation Methods
*****

This week, BTC and BSV devs both merged new features designed to keep their blockchains small. Here I compare both upgrades & reflect a bit on the different development practices in both projects.
For BSV, @Shadders333 recently announced the development of something called “free consolidation transactions” (which I will call Fctxs for brevity); this feature is production ready with BitcoinSV Node 1.0.5 https://twitter.com/shadders333/status/1306259151287443456
For BTC, @pwuille recently announced the development of something called “Schnorr signatures” (which I will call Ssigs for brevity); this feature has been merged into the main repository and I am guessing will be released with Bitcoin Core 0.21 https://twitter.com/pwuille/status/1304504395384512512
Bitcoin Core, the reference implementation for BTC, is Open Source, and has an open development model. This means that possible improvements to Bitcoin Core are discussed openlyin the form of BIPs (Bitcoin Improvement Proposals). Available here: https://github.com/bitcoin/bips 
BitcoinSV Node, the reference implementation for BSV, is also Open Source, but has a closed development model. So they don’t have a BIP for Fctxs. You can’t follow and discuss upcoming developments on BSV in Github. https://github.com/bitcoin-sv-specs/bips
Steve Shadders gave a definition and purpose for Fctxs in a blogpost.

https://bitcoinsv.io/2020/09/16/beyond-micropayments-the-rise-of-nano-services/
What are Fctxs?

Nodes keep a copy of the UTXO set. The more unspent UTXOs, the larger it is, and storage costs money. If a user has lots of tiny UTXOs, then consolidating them together can save nodes money. It is therefore in nodes’ interest to let users do this for free.
What are Ssigs?

Bitcoin txs work by combining a private key with a message transferring a UTXO to a different public key, using the ECDSA algorithm. A Schnorr signature is a different algorithm that allows you to put more information into a tx while using less data.
How do Fctxs mitigate blockchain bloat?

By allowing users to consolidate their UTXOs at no cost, they encourage a smaller blockchain with less overall UTXOs.
How do Ssigs mitigate blockchain bloat?

By allowing complex txs with multiple signatories to be written with more efficient mathematics, then as complex activity increases, it will lead to less data on the blockchain.
The maths behind Fctxs is very simple. This image is Shadders’ equation: the number of outputs (nOutputs) minus number of inputs (nInputs) of a consolidating tx gives you the number of txs difference (uxto_delta). (NB he has misspelled UTXO in this equation.)
As long as uxto_delta is high enough, then it is in miners’ economic interest to allow the consolidation transaction to occur for free, because it saves them money in storage.
The maths behind Ssigs is complicated. This image is Wuille, Nick & Ruffing’s equation describing their implementation of the algorithm. Where m = message P = public key G = the base of the curve
Ssigs use the same secp256k1 curve that ECDSA does. If you’re interesting, coords for point G are (0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798, 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8)

https://en.bitcoin.it/wiki/Secp256k1 
The body of IsConsolidationTxn can be found in /src/policy/policy.cpp. Aside from spam detection and making sure all the txs are valid, etc. the magic comes down to two lines:

if ( http://tx.vin .size() < factor * tx.vout.size())
return false; https://github.com/bitcoin-sv/bitcoin-sv/blob/master/src/policy/policy.cpp
But just to be safe, the function sort of checks for the same thing again before its final return:

if(sumScriptPubKeySizeOfTxInputs < factor * sumScriptPubKeySizeOfTxOutputs)
return false;
I do not understand the mathematics of the Schnorr algorithm, but I can show you the code. Here’s most of the code that does the work with the mathematical curves
Fctxs is basically a very simple algorithm, an “if… then…” statement that compares whether one number is smaller than another. Ssigs practically apply an algorithm designed by cryptographer Klaus Schnorr to the innards of Bitcoin & are a work of genius.
Furthermore, Schnorr signatures help advance BTC’s security & privacy features.
In contrast, fctxs on BSV just create an opportunity to game the system. Even Shadders sot of hinted at this in his blog post.

There is economic incentive to spend all your BSV to thousands of addresses you create for yourself, then use fctxs to make free payments.
One of these blockchains is undergoing incredible development with advanced cryptography. The other one… isn’t.

If you’ve got this far, thanks for reading, I hope it was as fun to read as it was to write.

I recognise this is a complicated & massively geeky hobby.
You can follow @pd_myers.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: