<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Posts on Murch ado about nothing</title>
    <link>http://murch.one/posts/</link>
    <description>Recent content in Posts on Murch ado about nothing</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 06 May 2022 00:00:00 +0000</lastBuildDate>
    <atom:link href="http://murch.one/posts/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>What is the Waste Metric?</title>
      <link>http://murch.one/posts/waste-metric/</link>
      <pubDate>Fri, 06 May 2022 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/waste-metric/</guid>
      <description>&lt;h2 id=&#34;coin-selection&#34;&gt;Coin Selection&lt;/h2&gt;
&lt;p&gt;Funds are tracked in discrete portions, so called &lt;em&gt;Unspent Transaction Outputs&lt;/em&gt; (see &lt;a href=&#34;https://bitcoin.stackexchange.com/q/49853/5406&#34;&gt;UTXO  model&lt;/a&gt;). Generally, a wallet&amp;rsquo;s funds are split across multiple to numerous such UTXOs. When a user sends a transaction, their wallet software needs to pick some of their UTXOs to fund the transaction. The process of picking the input set of a transaction is referred to as &lt;em&gt;Coin Selection&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The primary goal of Coin Selection is to raise sufficient funds to pay for the recipient outputs and fees of the transaction, but there are secondary goals as well:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;low immediate fees&lt;/strong&gt;: As transactions must bid for the blockspace they occupy, we want      transactions to be reasonably sized to limit their cost.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;low overall fees&lt;/strong&gt;: All UTXOs must be spent eventually to allow us to reassign their value  to new outputs. Sometimes it may be opportune to use additional inputs for a transaction    crafted while there is little blockspace demand to consolidate funds into fewer UTXOs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;financial privacy&lt;/strong&gt;: As the blockchain is public and will exist forevermore, the details of our transactions are visible to all. This means that we may reveal financial information to our business partners when we pay them, and companies surveilling Bitcoin usage in general may be able to glean additional data from our usage patterns. We want to limit the information we leak about the wallet&amp;rsquo;s history, its UTXO pool, and total funding.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As a means to achieve our secondary goals, it is useful to consider the &lt;strong&gt;composition of the wallet&amp;rsquo;s UTXO pool&lt;/strong&gt;. We want funds to be split in useful ways. For example, UTXOs of homogeneous values are less useful than UTXOs of diverse values. We want to have a sufficient count of UTXOs to not reveal all of our funds to business partners and surveillants in each transaction, but few enough that our wallet isn&amp;rsquo;t fragmented into little pieces, where we combine a lot of transaction history and incur high fees with every transaction.&lt;/p&gt;
&lt;p&gt;Take for example two wallets that each have 1 ₿ trying to send 0.6 ₿. One has the UTXOs [0.5, 0.5], the other has [0.1, 0.2, 0.3, 0.4]. The first wallet would need to use both its UTXOs and send itself a change output of 0.4 ₿. All of its funds would be in flight, it would have no confirmed UTXOs left to send an independent transaction, and the recipient would learn that the sender has an additional 0.4 ₿. The second wallet might use the 0.2 ₿ and 0.4 ₿, which would leave two other UTXOs untouched in the wallet, and not require creation of a change output.&lt;/p&gt;
&lt;p&gt;Generally, the combination space spanned by a diverse wallet is more densely populated than a homogeneous wallet. Split 4×0.25 ₿ a wallet with 1 ₿ can only combine the amounts {0.25, 0.5, 0.75, 1}, while a wallet with [0.1, 0.2, 0.3, 0.4] could combine all of {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1}.&lt;/p&gt;
&lt;h2 id=&#34;feerate-sensitive-coin-selection&#34;&gt;Feerate sensitive coin selection&lt;/h2&gt;
&lt;p&gt;Wanting to pay low fees for the current transaction but also minimizing the overall fees paid over the lifetime of the wallet may conflict. Especially if a wallet is involved in a large volume of payments, simplistic approaches to Coin Selection like always using the largest UTXOs first, will cause the wallet&amp;rsquo;s UTXO pool to increasingly fragment over time. The biggest contributors to transaction weight are the inputs. When then a large amount is paid while there is high blockspace demand, a heavily fragmented wallet might be forced to use numerous inputs which then causes a high transaction fee.
Obviously, we want to keep our transaction weight at high feerates low to minimize the transaction fee. To that end, a wallet operator might create consolidation transactions for the express purpose of defragmenting the wallet.
While these additional transactions allow minimizing costs at high feerates, a similar effect can be achieved by opportunistically using more inputs than necessary when creating transactions at low feerates without requiring users to manually intervene.
As more UTXOs are spent at lower feerates than at high feerates, the average feerate at which UTXOs are spent is lowered which decreases the overall lifetime fee expenditures of the wallet.&lt;/p&gt;
&lt;h2 id=&#34;the-waste-metric&#34;&gt;The waste metric&lt;/h2&gt;
&lt;p&gt;The waste metric provides a heuristic per which a wallet&amp;rsquo;s automated coin selection can achieve feerate sensitive coin selection.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://latex.codecogs.com/svg.image?waste~score=weight(feerate-L)+change+excess&#34; alt=&#34;waste metric formula: waste = weight×(feerate-longtermfeerate)+change+excess&#34;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;weight: total weight of the input set&lt;/li&gt;
&lt;li&gt;feerate: the transaction&amp;rsquo;s target feerate&lt;/li&gt;
&lt;li&gt;L: the long-term feerate estimate which the wallet might need to pay to redeem remaining UTXOs&lt;/li&gt;
&lt;li&gt;change: the cost of creating &lt;em&gt;and spending&lt;/em&gt; a change output&lt;/li&gt;
&lt;li&gt;excess: the amount by which we exceed our selection target when creating a changeless transaction, mutually exclusive with cost of change&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The resulting &lt;strong&gt;waste score&lt;/strong&gt; is a measure of the fees for the input set at the current feerate compared to spending the same inputs at the hypothetical long-term feerate. The waste score also accounts for the cost of creating a change versus dropping funds that exceed the selection target to fees in the case of a changeless transaction. When using the waste score to evaluate the input set candidates produced by multiple coin selection attempts, the scoring results in a preference for minimal input sets at high feerates and a preference for larger input sets below the long-term feerate estimate. Lighter modern output types have a lower waste score at high feerates and a higher waste score at low feerates, causing legacy inputs to be preferentially spent at low feerates and modern inputs preferred at high feerates. Change avoidance is always preferred as long as the &lt;em&gt;excess&lt;/em&gt; doesn&amp;rsquo;t exceed the &lt;em&gt;cost of change&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Unfortunately, the waste metric cannot capture all of our concerns: we do not account for privacy, and just optimizing for the best score would degenerate at the extremes. At high feerates, a single input solution would always win, while the best score at low feerates would be achieved by spending all UTXOs in the wallet for every transaction. We therefore rely on our selection of coin selection algorithms to produce sensible input set candidates and only use the waste metric to select from those candidates, rather than optimizing for the best waste score outcome.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>A breakdown of different output types and their address formats</title>
      <link>http://murch.one/posts/single-sig-output-types/</link>
      <pubDate>Thu, 23 Dec 2021 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/single-sig-output-types/</guid>
      <description>&lt;p&gt;I was inspired by a recent &lt;a href=&#34;https://www.reddit.com/r/Bitcoin/comments/rjdao2/people_keep_asking_me_about_the_different_types/&#34;&gt;reddit post&lt;/a&gt; to write my own description of the various single-sig output formats in Bitcoin. I’ll be covering only output types that make use of a single signature.&lt;/p&gt;
&lt;h2 id=&#34;legacy-outputs-aka-p2pkh&#34;&gt;“Legacy Outputs” aka P2PKH&lt;/h2&gt;
&lt;p&gt;Pay to Public Key Hash was the first output type that got an address standard. Addresses for P2PKH outputs start with “1” and use the &lt;em&gt;Base58Check&lt;/em&gt; encoding. The address encoding provides a checksum and represents a shorthand to communicate recipient information—which improved the UX over the prior situation which required the sender to handle the recipient’s full public key or non-standard output script to send a transaction.&lt;/p&gt;
&lt;p&gt;Example: &lt;code&gt;1MDPuAy9WCbNQin71j9S3MKAAe9mGBRNVx&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Issues:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;High transaction weight&lt;/li&gt;
&lt;li&gt;Case-sensitive addresses&lt;/li&gt;
&lt;li&gt;Bigger data footprint than Pay to Public Key&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;wrapped-segwit-outputs-aka-p2sh-p2wpkh&#34;&gt;“Wrapped Segwit Outputs” aka P2SH-P2WPKH&lt;/h2&gt;
&lt;p&gt;Segwit aimed to introduce &lt;a href=&#34;https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki&#34;&gt;a new family of output types&lt;/a&gt; which we refer to as &lt;em&gt;native segwit&lt;/em&gt;, but the authors realized that adoption of a new address format would take time. The segwit softfork additionally introduced &lt;em&gt;wrapped segwit&lt;/em&gt; outputs as a transitional solution, to be forward-compatible to wallets that could send to P2SH addresses. Since P2SH was rolled out in March 2012 and already widely used for multisig, most wallet software supported sending to P2SH when segwit was activated in 2017.&lt;/p&gt;
&lt;p&gt;P2SH-wrapped Pay to Witness Public Key outputs are indistinguishable from other P2SH-uses until spent. All P2SH addresses start with the prefix “3” and use the &lt;em&gt;Base58Check&lt;/em&gt; encoding like P2PKH addresses.&lt;/p&gt;
&lt;p&gt;Wrapped segwit outputs lock funds to a &lt;em&gt;P2SH Program&lt;/em&gt;, but their input script contains a &lt;em&gt;Witness Program&lt;/em&gt; that redirects the script validation to the &lt;em&gt;Witness Stack&lt;/em&gt;. While this achieved forward-compatibility, the redirection requires additional data that needs to be relayed on the network and stored in the blockchain. Since witness data is discounted by 75% when assessing transaction weight, wrapped segwit inputs are cheaper to create, even while their data footprint is larger than P2PKH.&lt;/p&gt;
&lt;p&gt;All P2SH addresses start with “3”.&lt;/p&gt;
&lt;p&gt;Example: &lt;code&gt;3Mwz6cg8Fz81B7ukexK8u8EVAW2yymgWNd&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Issues:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Case-sensitive addresses&lt;/li&gt;
&lt;li&gt;Redirection to the witness stack for evaluation adds extra data&lt;/li&gt;
&lt;li&gt;Even bigger data footprint than P2PKH&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;native-segwit-outputs&#34;&gt;Native Segwit Outputs&lt;/h2&gt;
&lt;p&gt;Instead of locking funds to a &lt;em&gt;P2SH Program&lt;/em&gt;, the output script for native segwit outputs directly contains the &lt;em&gt;Witness Program&lt;/em&gt;. This way, native segwit inputs only need a witness stack, and make do without the redirection data needed in the wrapped segwit construction, leaving only a zero-length stub for the input script. Native segwit outputs are represented with &lt;em&gt;bech32&lt;/em&gt; addresses for version 0, and &lt;em&gt;bech32m&lt;/em&gt; for version 1–16. The bech32 encoding is single-case, making it easier to note down and dictate as well as more efficient to encode in QR codes. The bech32 encoding is engineered to provide error-detection guarantees. Bech32 and bech32m addresses start with “bc1”.&lt;/p&gt;
&lt;h3 id=&#34;0-p2wpkh-aka-native-segwit-v0&#34;&gt;0) P2WPKH aka Native Segwit v0&lt;/h3&gt;
&lt;p&gt;Often simply referred to as “native segwit”, Pay to Witness Public Key Hash outputs lock funds to a public key hash similar to how P2PKH works. However, P2WPKH inputs provide the public key and signature in the Witness Stack instead of the input script, thus benefiting from the witness discount. Bech32 addresses encoding version 0 native segwit outputs start with “bc1q”, because “q” encodes 0 in bech32.&lt;/p&gt;
&lt;p&gt;Example: &lt;code&gt;bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Issues:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bech32 addresses are still not supported by some wallets and services&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;1-p2tr-aka-taproot-aka-native-segwit-v1&#34;&gt;1) P2TR aka Taproot aka Native Segwit v1&lt;/h3&gt;
&lt;p&gt;With the recent activation of Taproot, we add native segwit v1 outputs to our portfolio. Pay to Taproot outputs lock funds directly to a public key in the output’s witness program, which means (for single-sig uses) that the input only needs a single script argument, a signature, instead of needing to provide both a public key and signature like P2WPKH. P2TR uses Schnorr signatures, which are more compactly encoded than ECDSA signatures, reducing the signature size from 71-72 B to 64 B. This means that P2TR has the smallest data footprint even while the overall weight of input and output is slightly bigger than for P2WPKH. In addition, more complex spending conditions can be encoded in the leaves of the taptree that’s tweaked into the public key contained in the witness program. Bech32m addresses encoding P2TR outputs are longer than the bech32 addresses encoding P2WPKH outputs, since public keys are longer than the 20-byte hash used in P2WPKH. Addresses for P2TR outputs start with “bc1p”, because “p” encodes 1.&lt;/p&gt;
&lt;p&gt;Example: &lt;code&gt;bc1pay2tapr00tajnawrkf897ccgsmk4e0x8ng5g3rv3qzd7jzfy2zxspy50gj&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Issues:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bech32m addresses are brand-new and not yet supported by many wallets and services&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;cost-considerations&#34;&gt;Cost Considerations&lt;/h2&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/output-types.png&#34; alt=&#34;Table with overview of raw length, weight, and vsize of output types&#34;&gt;
&lt;/figure&gt;

&lt;p&gt;All four described output types satisfy single-sig usage, although P2TR can do a lot more under the hood. Generally, the transaction cost is cheaper for newer output types: Legacy &amp;gt; Wrapped Segwit &amp;gt; Native Segwit. While the overall cost of P2TR input and output is slightly higher than that of P2WPKH, P2TR shifts a portion of the cost from the input to the output. When you don’t know at what feerate you’ll need to pay to spend your funds later, you should keep them in P2TR outputs, since they’ll have the smallest input cost. Likewise, you should prefer P2TR when others are paying you: the sender pays the output cost while the recipient pays the input cost. Although, you may still bump into some counter-parties that cannot send to bech32, and many that cannot send to bech32m, yet, the economic incentives are clear. If your preferred wallet or service doesn’t support bech32(m) yet, please do ask them to do so.&lt;/p&gt;
&lt;p&gt;If you’re considering your transactions’ data footprint on the blockchain, you should also strictly prefer P2TR as it get you the most bang for the byte (see column “raw [B]” in table above). The data footprint for the output types is P2SH-P2WPKH &amp;gt; P2PKH &amp;gt; P2WPKH &amp;gt; P2TR.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>2-of-3 inputs using Pay-to-Taproot</title>
      <link>http://murch.one/posts/2-of-3-using-p2tr/</link>
      <pubDate>Tue, 18 Aug 2020 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/2-of-3-using-p2tr/</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was &lt;a href=&#34;https://murchandamus.medium.com/2-of-3-multisig-inputs-using-pay-to-taproot-d5faf2312ba3&#34;&gt;originally published&lt;/a&gt; on my medium page on 2020-08-18.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;This article was amended on 2020–12–20 to improve the description of the P2TR output scripts. Thanks to Matthew Zipkin, for pointing out the prior imprecision.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The Bitcoin community has been &lt;a href=&#34;https://medium.com/hackernoon/excited-for-schnorr-signatures-a00ee467fc5f&#34;&gt;abuzz for a few years&lt;/a&gt; about bringing Schnorr signatures to Bitcoin. Since then, the idea has evolved into three formal Bitcoin Improvement Proposals: ‘&lt;a href=&#34;https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki&#34;&gt;BIP340 — Schnorr Signatures for secp256k1&lt;/a&gt;’, ‘&lt;a href=&#34;https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki&#34;&gt;BIP341 — Taproot: SegWit version 1 spending rules&lt;/a&gt;’, and ‘&lt;a href=&#34;https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki&#34;&gt;BIP342 — Validation of Taproot Scripts&lt;/a&gt;’. Respectively, they define a standard for Schnorr signatures in Bitcoin, introduce the Taproot construction, and formalize the new Script v1 instruction set. Taproot also iterates on the previous proposal of Merklized Alternative Script Trees (MAST).&lt;/p&gt;
&lt;p&gt;There are two ways of spending a pay-to-taproot (P2TR) output. The first way is called &lt;em&gt;keypath spending&lt;/em&gt;. P2TR funds are locked to a single public key similarly to &lt;em&gt;pay-to-public-key&lt;/em&gt; (P2PK) outputs. The output script appears in the transaction as &lt;code&gt;OP_1 &amp;lt;pubkey&amp;gt;&lt;/code&gt;. This script can be satisfied by providing an empty input script and a Schnorr signature of the corresponding private key in the witness program. The keypath is the default spending path. It is used in single-sig and collaborative multi-party spending.&lt;/p&gt;
&lt;p&gt;Under the hood, the public key is a composition of an &lt;em&gt;inner key&lt;/em&gt; and the Merkle root of a Taproot tree (the inner key is tweaked with the Merkle root). The inner key can optionally be a composite itself, for example multiple public keys aggregated via the &lt;a href=&#34;https://blockstream.com/2019/02/18/en-musig-a-new-multisignature-standard/&#34;&gt;MuSig&lt;/a&gt; scheme. These compositions are possible due to Schnorr signatures being linear.&lt;/p&gt;
&lt;p&gt;The second way of spending a P2TR output uses one of the Taproot leaves. We call this &lt;em&gt;scriptpath spending&lt;/em&gt;. First, the existence of the leaf needs to be proven which is done by revealing the inner key, the Merkle path to the Taproot leaf, and the script encoded in the leaf. Then, the spending conditions of the leaf’s script are fulfilled.&lt;/p&gt;
&lt;p&gt;The remainder of this article explores the input costs of 2-of-3 multisig Taproot constructions. Some familiarity with the details of the proposals is helpful. Check out the &lt;a href=&#34;https://bitcoinops.org/en/topics/taproot/&#34;&gt;Taproot overview&lt;/a&gt; and the excellent &lt;a href=&#34;https://bitcoinops.org/en/newsletters/2019/05/14/#overview-of-the-taproot--tapscript-proposed-bips&#34;&gt;summary of the three BIPs&lt;/a&gt; by the Bitcoin Optech Group if you are looking to refresh the details.&lt;/p&gt;
&lt;h2 id=&#34;the-multisig-user-story&#34;&gt;The multisig user story&lt;/h2&gt;
&lt;p&gt;We are looking at a wallet construction using three keys held by two or three parties. The first key is held by the user, the second key is held by the service provider, and the third key is a backup key either held by the user or a key recovery service. We are assuming that the first two keys are hot and can be used in an interactive signing scheme as employed by MuSig. The backup key may be held cold e.g. on an air-gapped system in which case interactive signing should be avoided.&lt;/p&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/2-of-3-keys.png&#34;&gt;
&lt;figcaption&gt;
2-of-3 multisig with two hot keys and one (optionally) cold key&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Classically, a 2-of-3 multisig address is constructed in the form of a &lt;em&gt;pay-to-scripthash&lt;/em&gt; (P2SH) output of the form &lt;code&gt;2 &amp;lt;pubkey1&amp;gt; &amp;lt;pubkey2&amp;gt; &amp;lt;pubkey3&amp;gt; 3 OP_CHECKMULTISIG&lt;/code&gt;. This construction can logically be expressed as ‘(A ∧ B) ∨(A ∧ C) ∨(B ∧ C)’ which could also be thought of as “one of three 2-of-2 multisig scripts”. The latter translates nicely to Taproot: we can encode the preferred condition of spending with the user and the service key (the two hot keys) in an aggregated pubkey for the keypath, and put the two spending conditions using the backup key in leaves of the Taproot tree. Two variants are explored: one where the backup key is capable of participating in the interactive MuSig signing scheme, another that falls back to a simpler multisig scheme where signing is non-interactive e.g. because the backup key is air-gapped and the multiple roundtrips required for MuSig are inconvenient.&lt;/p&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/tweak.png&#34;&gt;
&lt;figcaption&gt;
The most likely spending option with the two hot keys is encoded as an aggregated key in the keypath. The two backup spending options are put into leaves of the script tree.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id=&#34;keypath-spending-costs&#34;&gt;Keypath spending costs&lt;/h2&gt;
&lt;p&gt;In the general case, all parties agree on a course of action and collaborate to use the keypath. This is the most cost-effective way to spend a P2TR output and allows multiparty spenders (and other complex spending conditions) to be indistinguishable from single-sig spenders.&lt;/p&gt;
&lt;h3 id=&#34;costs-of-keypath-input&#34;&gt;Costs of keypath input&lt;/h3&gt;
&lt;p&gt;An input commits to a specific &lt;em&gt;unspent transaction output&lt;/em&gt; (UTXO) which is defined by the transaction that created it and the position in that transaction’s output list. The UTXO entry provides the spending conditions to be satisfied by the spender. An &lt;em&gt;nSequence&lt;/em&gt; field allows encoding replaceability, and the witness provides the spender’s authentication. In the case of the keypath this is a single Schnorr signature which in some cases may actually consist of multiple aggregated signatures.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;outpoint (txid:vout): 32 vB+4 vB&lt;/li&gt;
&lt;li&gt;scriptSig size: 1 vB&lt;/li&gt;
&lt;li&gt;nSequence: 4 vB&lt;/li&gt;
&lt;li&gt;count witness items: 1 WU&lt;/li&gt;
&lt;li&gt;witness item size: 1 WU&lt;/li&gt;
&lt;li&gt;signature: 64 WU&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;32+4+1+4+(1+1+64)/4 = 57.5 vB&lt;/p&gt;
&lt;h2 id=&#34;control-blocks&#34;&gt;Control Blocks&lt;/h2&gt;
&lt;p&gt;When a fallback to the backup key is necessary, the existence of the Taproot tree must be revealed. If there is only a single leaf, the spender provides only the inner key. Tweaking the inner key with the hashed leaf results in the public key. In sum, the data necessary to prove the existence of a scriptpath is called the &lt;em&gt;control block&lt;/em&gt;.&lt;/p&gt;
&lt;h3 id=&#34;depth-0-control-block&#34;&gt;Depth 0 control block&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Length of control block: 1 WU&lt;/li&gt;
&lt;li&gt;Header byte (script version, sign of output key): 1 WU&lt;/li&gt;
&lt;li&gt;Inner key: 32 WU&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;1+1+32 = 34 WU&lt;/p&gt;
&lt;p&gt;In case of two leaves, additionally the first hashing partner for the Merkle path must be revealed:&lt;/p&gt;
&lt;h3 id=&#34;depth-1-control-block&#34;&gt;Depth 1 control block&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Length of control block: 1 WU&lt;/li&gt;
&lt;li&gt;Header byte: 1 WU&lt;/li&gt;
&lt;li&gt;Inner key of root key: 32 WU&lt;/li&gt;
&lt;li&gt;Hashing partner in tree: 32 WU&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;1+ 1+ 32 + 32 = 66 WU&lt;/p&gt;
&lt;h2 id=&#34;scriptpath-spending-cost&#34;&gt;Scriptpath spending cost&lt;/h2&gt;
&lt;p&gt;The below costs are in addition to the above costs of spending via the keypath.&lt;/p&gt;
&lt;h3 id=&#34;scriptpath-spend-assuming-2-of-2-musig-leaf-hot-backup-key&#34;&gt;Scriptpath spend assuming 2-of-2 MuSig leaf (hot backup key)&lt;/h3&gt;
&lt;p&gt;When the backup key is on a networked system, e.g. an HSM, and can participate in a multi-roundtrip signing process, we can make use of MuSig to aggregate the two public keys.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;script size: 1 WU&lt;/li&gt;
&lt;li&gt;script &lt;code&gt;&amp;lt;pk&amp;gt; OP_CHECKSIG&lt;/code&gt;: 33 WU+1 WU&lt;/li&gt;
&lt;li&gt;Depth 1 Control block: 66 WU&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;57.5+(1+34+66)/4 = 82.75 vB&lt;/p&gt;
&lt;h3 id=&#34;construction-with-2-of-2-op_checksig-cold-backup-key-no-musig&#34;&gt;Construction with 2-of-2 OP_CHECKSIG (cold backup key, no MuSig)&lt;/h3&gt;
&lt;p&gt;In the case that the backup key is offline and a human would have to make multiple trips employing USB sticks or QR codes, saving roundtrips may take precedence over saving a few bytes. Instead of an aggregated public key, we use a non-interactive multisig construction.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;second signature: 1 WU+64 WU&lt;/li&gt;
&lt;li&gt;script size: 1 WU&lt;/li&gt;
&lt;li&gt;script &lt;code&gt;&amp;lt;pk1&amp;gt; OP_CHECKSIGVERIFY &amp;lt;pk2&amp;gt; OP_CHECKSIG&lt;/code&gt;: 33+1+33+1=68 WU&lt;/li&gt;
&lt;li&gt;Depth 1 Control block: 66 WU&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;57.5+(1+64+1+68+66)/4 = 107.5 vB&lt;/p&gt;
&lt;h3 id=&#34;discarded-approach-single-leaf-with-2-of-3-script&#34;&gt;Discarded approach: single leaf with 2-of-3 script&lt;/h3&gt;
&lt;p&gt;It turns out that a single 2-of-3 leaf in lieu of the two 2-of-2 leaves is both more costly and less private.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;+2nd sig: 1+64 WU&lt;/li&gt;
&lt;li&gt;+1 empty witness item: 2 WU&lt;/li&gt;
&lt;li&gt;Length of script: 1 WU&lt;/li&gt;
&lt;li&gt;Script &lt;code&gt;&amp;lt;pk1&amp;gt; OP_CHECKSIG &amp;lt;pk2&amp;gt; OP_CHECKSIGADD &amp;lt;pk3&amp;gt; OP_CHECKSIGADD 2 OP_EQUAL&lt;/code&gt;: 33+1+33+1+33+1+2=104 WU&lt;/li&gt;
&lt;li&gt;Depth 0 Control block: 34 WU&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;57.5+(1+64+2+1+104+34)/4 = 109 vB&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/2-of-3-costs.png&#34;&gt;
&lt;figcaption&gt;
Upper bound of input and output sizes for single-sig and 2-of-3 multisig&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The described 2-of-3 multisig scheme achieves input sizes of 57.5 vbytes for a keypath spend, 82.75 vbytes for the leaves using a hot backup key, and 107.5 vbytes for non-interactive backup spends. This results in a fee reduction by 45% for 2-of-3 inputs when switching from P2WSH to P2TR spending. In the uncommon case of a recovery transaction, the cost is negligibly increased for cold keys. Single-sig users are also incentivized to switch to P2TR as they save 11 vbytes on each input — the output cost is externalized on the sender.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Excited for Schnorr signatures</title>
      <link>http://murch.one/posts/excited-for-schnorr-sigs/</link>
      <pubDate>Sat, 03 Feb 2018 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/excited-for-schnorr-sigs/</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was &lt;a href=&#34;https://medium.com/hackernoon/excited-for-schnorr-signatures-a00ee467fc5f&#34;&gt;originally published&lt;/a&gt; on my medium page and hackernoon on 2018-02-03.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you’re keeping a finger on the pulse of Bitcoin development, you’ve probably already heard about Schnorr signatures and you probably won’t find much new here. You might rather want to check out Pieter Wuille’s recent &lt;a href=&#34;https://www.youtube.com/watch?v=oTsjMz3DaLs&#34;&gt;talk at BPASE18&lt;/a&gt;, or Bryan Bishop’s &lt;a href=&#34;http://diyhpl.us/~bryan/papers2/bitcoin/bitcoin-tech-dev-talks-schnorr-signatures.2018-02-01.pdf&#34;&gt;compilation of transcripts of Schnorr signature talks&lt;/a&gt; whom this article heavily leans on.&lt;/p&gt;
&lt;p&gt;Bitcoin signatures are created using the Elliptic Curve Digital Signing Algorithm (ECDSA). Schnorr signatures are another form of digital signatures. The signatures are based on the same security assumptions as ECDSA and are compatible with the elliptic curve Bitcoin already uses (secp256k1). This means that Schnorr signatures can be created with the same private keys and are compatible with currently used key derivation schemes.&lt;/p&gt;
&lt;h3 id=&#34;schnorr-signatures-are-smaller&#34;&gt;Schnorr signatures are smaller&lt;/h3&gt;
&lt;p&gt;ECDSA signatures vary in size, but almost all come in at a length of 72 or 71 bytes. A small portion will turn out smaller with a theoretical minimum of 8 bytes. [h/t Greg Maxwell]&lt;/p&gt;
&lt;p&gt;Schnorr signatures are more efficient and compact than ECDSA signatures. The maximum length of each signature is 64 bytes. [via &lt;a href=&#34;https://bitcoin.stackexchange.com/q/34288/5406&#34;&gt;Harding&lt;/a&gt;]&lt;/p&gt;
&lt;p&gt;Bitcoin blocks include thousands of signatures, and I estimate from the top of my head that signatures make up more than a third of the blockchain data. Simply by being more compact, Schnorr signatures would reduce the blockchain data footprint by a few percent.&lt;/p&gt;
&lt;h3 id=&#34;schnorr-signatures-allow-for-compact-multi-signature&#34;&gt;Schnorr signatures allow for compact multi-signature…&lt;/h3&gt;
&lt;p&gt;The multi-signature scheme in Bitcoin is straightforward but naïve. You first list the set of public keys of the authorized signers, and then provide a sufficient count of signatures by the former. E.g., in a 2-of-3 multi-signature transaction input, three public keys and two signatures are provided.&lt;/p&gt;
&lt;p&gt;Schnorr signatures have a neat mathematical property that allows multiple signatures to be combined into a single signature. The combined signature has the size of a single signature, but provides the authorization of the original separate signatures.&lt;/p&gt;
&lt;p&gt;This allows for a more compact multi-signature scheme, where you only list the authorized public keys and provide a single signature. This is even more efficient for bigger multi-signature transactions. For example, a 3-of-15 and a 10-of-15 transaction input could now have the same weight (if you don&amp;rsquo;t care who signed).&lt;/p&gt;
&lt;h3 id=&#34;and-aggregated-signatures-across-a-whole-transaction&#34;&gt;…and aggregated signatures across a whole transaction!&lt;/h3&gt;
&lt;p&gt;While multi-signature transactions make up a solid portion of the blockspace, the real breakthrough is that signatures can be aggregated across multiple inputs of a transaction. Instead of providing one (or multiple signatures) for each input, a transaction with Schnorr signatures can have &lt;strong&gt;a single signature for all inputs&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;For example at BitGo, we use 2-of-3 multi-signature transactions. Every transaction input therefore has two signatures. As we&amp;rsquo;re seeing low fee rates on the network, some of our customers have started consolidating funds from low-value UTXO. With the current signature scheme, a 2-of-3 multi-sig transaction with 200 inputs would need 400 signatures or about 28.5 kB of signature data. With Schnorr signatures the same transaction could be signed with a single 64-byte Schnorr signature.&lt;/p&gt;
&lt;p&gt;In his &lt;a href=&#34;https://www.youtube.com/watch?v=oTsjMz3DaLs&#34;&gt;talk at BPASE18&lt;/a&gt;, Pieter Wuille estimated that purely from aggregating signatures for each transaction and leaving everything else the same, the Bitcoin blockchain would be between 25% and 30% smaller.&lt;/p&gt;
&lt;h3 id=&#34;scriptless-scripts-and-various-black-crypto-magic&#34;&gt;Scriptless Scripts, and… various black crypto magic&lt;/h3&gt;
&lt;p&gt;There is some interesting work by Andrew Poelstra lately which he calls &amp;ldquo;Scriptless Scripts&amp;rdquo; (see e.g. his &lt;a href=&#34;https://www.youtube.com/watch?v=ovCBT1gyk9c&#34;&gt;talk at Real World Crypto 2018&lt;/a&gt;). The idea is that you can express conditions in a smart contract by requiring certain signatures to be provided for the payout. By means of the above mentioned signature aggregation, this could be used to compactly encode smart contracts. The terms of the contract would be hidden from other users and only transparent to its participants, yet enforced by the whole Bitcoin network.&lt;/p&gt;
&lt;p&gt;You may have heard about the recent cross-chain atomic swaps. The basic idea is that two payments on two different blockchains are linked in a way that they either both go through or neither. This can be used to decentrally trade cryptocurrencies.
Hereby, the traders first lock up funds in shared addresses on both chains, and then create two interdependent transactions. The second transaction depends on a hash preimage that is revealed by the first transaction. Either party can back out and wait for the lock to expire to reclaim their funds, but when the first transaction is executed, the other transaction becomes immediately valid.&lt;/p&gt;
&lt;p&gt;By means of the same property that allows for the signature aggregation, all of the above cross-chain atomic swap can be expressed in a single Schnorr signature indistinguishable from a regular spending transaction.&lt;/p&gt;
&lt;h3 id=&#34;a-bip-for-schnorr-signatures-is-in-the-works&#34;&gt;A BIP for Schnorr signatures is in the works&lt;/h3&gt;
&lt;p&gt;The introduction of Schnorr signatures into Bitcoin requires a new OP_CODE for signature verification. Luckily, Segwit gave us versioning for Bitcoin script, so support for Schnorr signatures can be activated with a soft fork. I hear that multiple Bitcoin Improvement Proposals are in the works and forthcoming shortly.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Thanks to Pieter Wuille for review.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Edit: Corrected the length of ECDSA DER-encoded signatures.&lt;/em&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>A look at an early LN testnet topology</title>
      <link>http://murch.one/posts/ln-topology/</link>
      <pubDate>Fri, 29 Dec 2017 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/ln-topology/</guid>
      <description>&lt;p&gt;&lt;em&gt;This article originally &lt;a href=&#34;https://murchandamus.medium.com/a-look-at-an-early-ln-testnet-topology-a874a6ff41d9&#34;&gt;appeared&lt;/a&gt; on my medium site on 2017-12-29.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s take a look together.&lt;/p&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/lopp-ln-testnet.png&#34;&gt;
&lt;figcaption&gt;
A commenter on my Fyookball response: &amp;lsquo;This [&lt;a href=&#34;https://twitter.com/lopp/status/932726696364650498&#34;&gt;tweeted image&lt;/a&gt;] shows a lot of centralization around hubs&amp;rsquo;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;We see about ten &amp;ldquo;supernodes&amp;rdquo; that stick out by having a lot of channels. We also see that there are some smaller nodes that form channels exclusively with these supernodes. I assume this is what you&amp;rsquo;re referring to, when you decry &amp;ldquo;centralization around hubs&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;However, I&amp;rsquo;d like to point out a few more things in this graph.&lt;br&gt;
If we look at the cluster in the top left for example, we see that every node in that cluster is connected to the supernode, but there are also numerous channels between the other nodes around it. The supernode is connecting to the bigger cluster with a payment channel directly to another supernode as well as through a small bridge node.&lt;/p&gt;
&lt;p&gt;If we look at the area around the two yellow highlighted supernodes, we see a large number of smaller nodes that form connections to multiple supernodes as well as other nodes.&lt;/p&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/fyookball-decentralized.png&#34;&gt;
&lt;figcaption&gt;
The expected topology of LN according to Fyookball&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Comparing this to the expected topology from Fyookball’s article, you’ll note that the &amp;ldquo;Decentralized (with centralized hubs)&amp;rdquo; topology is distinctly different from what we see in the LN graph. In the suggested &amp;ldquo;Hub and Spoke&amp;rdquo; graph, only hubs connect hubs, while nodes exclusively connect to hubs. Obviously, the &amp;ldquo;Distributed&amp;rdquo; graph is a showcase, but it&amp;rsquo;s clear to see that the actually exhibited topology is at least a mixture between the &amp;ldquo;Decentralized&amp;rdquo; and &amp;ldquo;Distributed&amp;rdquo; topologies.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s take another look, today:&lt;/p&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/testnet-graph.png&#34;&gt;
&lt;figcaption&gt;
The LN testnet graph on 2017–12–28 via stevenroose.github.io/lightninggraph/&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;This marvellous jumble we see, makes it clear that we&amp;rsquo;re not seeing a hub and spoke topology.–
If anything, this clutter illustrates how easy it to bypass the “supernodes”.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>PSA: Wrong fee rates on block explorers</title>
      <link>http://murch.one/posts/psa-wrong-feerates/</link>
      <pubDate>Tue, 12 Dec 2017 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/psa-wrong-feerates/</guid>
      <description>&lt;p&gt;&lt;em&gt;This article &lt;a href=&#34;https://murchandamus.medium.com/psa-wrong-fee-rates-on-block-explorers-48390cbfcc74&#34;&gt;originally appeared&lt;/a&gt; on my medium page on 2017-12-12.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Update: Blockchair.com, BTC.com and Smartbit.com.au have corrected their fee rates since my article. Thank you!&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;We’ve been getting support requests from customers inquiring why their transaction’s fee rate is not matching the parameters they set.&lt;/p&gt;
&lt;p&gt;The problem is that popular blockchain explorers don’t get the fee rate right. Let’s look at the following transaction with two P2SH-P2WSH multisig inputs and six outputs:
&lt;code&gt;c​d​e​e​a​0​d​6​c​3​7​a​0​4​6​d​5​b​7​e​1​3​a​7​5​b​c​0​c​9​8​4​2​4​9​3​f​4​1​d​d​5​a​9​7​d​2​4​8​d​f​4​3​5​5​2​a​d​9​e​1​5​c​8​&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The customer set a fee rate of 160.20 sat/B. Naturally, they were surprised when they saw what blockchain explorers are telling us:&lt;/p&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/tradeblock.png&#34;&gt;
&lt;figcaption&gt;
&lt;a href=&#34;https://tradeblock.com/bitcoin/tx/cdeea0d6c37a046d5b7e13a75bc0c9842493f41dd5a97d248df43552ad9e15c8&#34;&gt;Tradeblock.com says the fee rate is 216.81 sat/B.&lt;/a&gt;&lt;/figcaption&gt;
&lt;/figure&gt;


&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/smartbit.png&#34;&gt;
&lt;figcaption&gt;
&lt;a href=&#34;https://www.smartbit.com.au/tx/cdeea0d6c37a046d5b7e13a75bc0c9842493f41dd5a97d248df43552ad9e15c8&#34;&gt;smartbit.com.au says the fee rate is 90.50 sat/B&lt;/a&gt;. — Update: smartbit.com.au has fixed their fee rates since this article. Thank you.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;It’s pretty clear that the fee is 78,920 satoshis…&lt;/p&gt;
&lt;h2 id=&#34;but-what-does-this-transaction-weigh&#34;&gt;…but what does this transaction “weigh“?&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Stripped size:&lt;/em&gt; &lt;strong&gt;364 bytes&lt;/strong&gt;&lt;br&gt;
This is the size of a transaction when ignoring the witness.&lt;br&gt;
Without witness each input is 76 bytes long, each of the five P2PKH outputs has 34 bytes, the P2SH output has 32 bytes, and the transaction header is 10 bytes.&lt;br&gt;
&lt;code&gt;2×76+5×34+32+10 = 364 bytes&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Fee rate: 78920 satoshis / 364 bytes = 216.8 sat/B&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Raw size:&lt;/em&gt; &lt;strong&gt;872 bytes&lt;/strong&gt;&lt;br&gt;
The raw byte length of the transaction.&lt;br&gt;
Each of the two inputs has a raw byte length of 329 bytes, each of the five P2PKH outputs has 34 bytes, the P2SH output has 32 bytes, and the transaction header is 12 bytes long.&lt;br&gt;
&lt;code&gt;2×329+5×34+32+12 = 872 bytes&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Fee rate: 78920 satoshis / 872 bytes = 90.5 sat/B&lt;/p&gt;
&lt;h2 id=&#34;where-are-the-1602-satb-we-are-looking-for&#34;&gt;Where are the 160.2 sat/B we are looking for?&lt;/h2&gt;
&lt;p&gt;The explorers are showing us “fee / stripped transaction size” and “fee / raw transaction size”. While the calculation with the stripped transaction size overestimates the fee rate by considering the transaction smaller than it is, using the raw transaction size underestimates the fee rate by ignoring the witness discount.&lt;/p&gt;
&lt;p&gt;However, since Segregated Witness activated, the relevant fee rate is “fee / virtual transaction size” in [satoshis per virtual byte].&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Virtual size:&lt;/em&gt; &lt;strong&gt;491 vbytes&lt;/strong&gt;&lt;br&gt;
The virtual size (vsize) of the transaction respective to the portion of a block it occupies, corresponding to the size of non-segwit transactions.&lt;br&gt;
The vsize is calculated as follows:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(3×non-witness size + raw transaction size) / 4&lt;/code&gt;&lt;br&gt;
or&lt;br&gt;
&lt;code&gt;(4×non-witness size + witness size) / 4&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For non-segwit transactions the vsize is equal to the size.
Each of the two inputs weighs 139 vbytes, each of the five P2PKH outputs weighs 34 vbytes, the P2SH output weighs 32 vbytes, and the transaction has a header of 10.5 vbytes.&lt;br&gt;
&lt;code&gt;2×139+5×34+32+11 = 491 vbytes&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Fee rate: 78920 satoshis / 491 vbytes = &lt;strong&gt;160.7 sat/vB&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&#34;at-last-bitflyer-gets-it-right-by-using-scattershot&#34;&gt;At last, BitFlyer gets it right by using scattershot:&lt;/h2&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/bitflyer.png&#34;&gt;
&lt;figcaption&gt;
&lt;a href=&#34;http://chainflyer.bitflyer.jp/Transaction/cdeea0d6c37a046d5b7e13a75bc0c9842493f41dd5a97d248df43552ad9e15c8&#34;&gt;BitFlyer lists all: the fee per raw tx size, the fee per WU and the actual fee rate.&lt;/a&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Could we pretty, pretty please have more blockexplorers that show us the relevant fee rate?&lt;/p&gt;
&lt;h2 id=&#34;appendix-additional-honorary-mentions&#34;&gt;Appendix: Additional honorary mentions&lt;/h2&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/blockchair.png&#34;&gt;
&lt;figcaption&gt;
&lt;a href=&#34;https://blockchair.com/bitcoin/transaction/261494937&#34;&gt;Blockchair tells us the “fee per kB” is 0.00216813 BTC.&lt;/a&gt; — Update: Blockchair has fixed their fee rates since this article. Thank you.&lt;/figcaption&gt;
&lt;/figure&gt;


&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/blockchain.png&#34;&gt;
&lt;figcaption&gt;
&lt;a href=&#34;https://blockchain.info/tx/cdeea0d6c37a046d5b7e13a75bc0c9842493f41dd5a97d248df43552ad9e15c8&#34;&gt;Blockchain.info shows the fee rate over raw byte length and a correct “Fee per weight unit” of 40.2 sat/WU, which however doesn’t compare to the established fee rates.&lt;/a&gt;&lt;/figcaption&gt;
&lt;/figure&gt;


&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/btc-com.png&#34;&gt;
&lt;figcaption&gt;
&lt;a href=&#34;https://btc.com/cdeea0d6c37a046d5b7e13a75bc0c9842493f41dd5a97d248df43552ad9e15c8&#34;&gt;btc.com shows virtual size, but calculates the fee with the raw byte length: 90.5 sats/B.&lt;/a&gt;— Update: BTC.com has fixed their fee rates since this article. Thank you.&lt;/figcaption&gt;
&lt;/figure&gt;


&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/blocktrail.png&#34;&gt;
&lt;figcaption&gt;
[blocktrail.com shows stripped size of 364 bytes and a fee rate of 216.8 sat/B.](blocktrail.com shows stripped size of 364 bytes and a fee rate of 216.8 sat/B.)&lt;/figcaption&gt;
&lt;/figure&gt;


&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/blockcypher.png&#34;&gt;
&lt;figcaption&gt;
&lt;a href=&#34;https://www.blocktrail.com/BTC/tx/cdeea0d6c37a046d5b7e13a75bc0c9842493f41dd5a97d248df43552ad9e15c8&#34;&gt;blocktrail.com shows stripped size of 364 bytes and a fee rate of 216.8 sat/B.&lt;/a&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

</description>
    </item>
    
    <item>
      <title>Some subsidiary points on Lightning Network</title>
      <link>http://murch.one/posts/subsidiary-ln-points/</link>
      <pubDate>Thu, 29 Jun 2017 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/subsidiary-ln-points/</guid>
      <description>&lt;p&gt;&lt;em&gt;This article first &lt;a href=&#34;https://murchandamus.medium.com/some-subsidiary-points-on-lightning-network-cc68bc81d6f1&#34;&gt;appeared&lt;/a&gt; on my medium page on 2017-06-29.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I was pondering whether it is a good use of my time to respond a second time to Jonald Fyookball. Since the new article mostly repackages the same misunderstandings, I have decided to only provide some subsidiary information.&lt;/p&gt;
&lt;h2 id=&#34;who-performs-the-routing-in-lightning-network&#34;&gt;Who performs the Routing in Lightning Network?&lt;/h2&gt;
&lt;p&gt;When a node in Lightning Network wants to initiate a payment &lt;strong&gt;the sender picks every hop of the route&lt;/strong&gt;. To that end, they use &amp;ldquo;Onion routing&amp;rdquo; — they construct a packet much like a prank christmas present from your older brother: a multitude of ever smaller boxes, until it is finally revealed that it&amp;rsquo;s just a pair of alpaca socks.&lt;/p&gt;
&lt;p&gt;For illustration, let&amp;rsquo;s look at a simple example with two hops. Alice wants to send 1mBTC to Carol, and Alice and Carol each have a payment channel with Bob.&lt;/p&gt;
&lt;p&gt;Alice sends an encrypted message to Bob with the following content:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A cryptographic contract which commits Alice to signing over 1 mBTC to Bob if he can provide the secret.&lt;/li&gt;
&lt;li&gt;Designation of Carol as the next hop.&lt;/li&gt;
&lt;li&gt;A cryptographic contract which commits Bob to signing over 1 mBTC to Carol if she can provide the secret.&lt;/li&gt;
&lt;li&gt;An encrypted message to be delivered to Carol.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If Bob agrees to the terms of the payment and has sufficient capacity, he may forward the payment request. If he doesn&amp;rsquo;t, he responds with a failure message, which allows Alice to construct an alternative route. If he doesn&amp;rsquo;t react, the payment request times out after a fraction of a second. Let&amp;rsquo;s assume Bob agrees and forwards the payment request. Bob sends a message to Carol with the following content:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A cryptographic contract which commits Bob to signing over 1 mBTC to Carol if she can provide the secret.&lt;/li&gt;
&lt;li&gt;The encryted message to Carol.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Carol decrypts the message and finds the invoice identifier, and the secret. She can now use the secret to execute her cryptographic contract with Bob. She gets paid &lt;em&gt;immediately&lt;/em&gt; while &lt;em&gt;inextricably&lt;/em&gt; providing Bob with the secret. Bob can now use the secret to get back his prepayment from Alice by executing the cryptographic contract with Alice.&lt;/p&gt;
&lt;h2 id=&#34;observations&#34;&gt;Observations&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;There is no centralized routing queue. Routing is performed by the sender with knowledge of their local neighborhood.&lt;/li&gt;
&lt;li&gt;All participants in a multihop payment have to be online to agree on the contract for it to come to pass. Thus, the expected occurrence of unresponsive channels is low. If a node along the route dropped from the network, a failure response is returned.&lt;/li&gt;
&lt;li&gt;The recipient is paid immediately. Others are incentivized to settle as quickly as possible. Only the amount locked to a contract is unavailable for transactions, the remaining capacity is free to be used in other payments.&lt;/li&gt;
&lt;li&gt;Unresponsive behavior is easy to punish: Nodes that don&amp;rsquo;t respond to payment requests will not be considered for later payment attempts. Eventually they lose their channel partners for not being useful. The network mends by finding routes around them.&lt;/li&gt;
&lt;li&gt;Every participant in a multihop payment learns only about the previous and next hop in the chain. They also cannot tell if a neighboring hop is sender or receiver of the payment.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;hubs-are-just-well-connected-nodes&#34;&gt;&amp;ldquo;Hubs&amp;rdquo; are just well-connected nodes&lt;/h2&gt;
&lt;p&gt;In discussion around Lightning Network the term &amp;ldquo;hub&amp;rdquo; frequently pops up. This term makes little sense, as there is no clear distinction of &amp;ldquo;hubs&amp;rdquo; and other nodes. Each node can create as many payment channels as they wish to commit funds to and find useful. Nodes that are well-connected might be perceived as a more useful payment channel partner, but at some point such nodes would inadvertently arrive at the limit of funds they are willing to commit to payment channels. Besides, if there are fees to be earned for routing payments, it may actually be more profitable to extend routes into remotely connected regions of the network. In any case, there is no restriction on other routes emerging around well-connected nodes.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Responding to Jonald Fyookball&#39;s article on &#34;Lightning Network&#39;s Infeasibility&#34;</title>
      <link>http://murch.one/posts/responding-fyookball/</link>
      <pubDate>Tue, 27 Jun 2017 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/responding-fyookball/</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally &lt;a href=&#34;https://murchandamus.medium.com/i-have-just-read-jonald-fyookballs-article-https-medium-com-jonaldfyookball-mathematical-fd112d13737a&#34;&gt;published&lt;/a&gt; on my medium page on 2017-06-27.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I have just read &lt;a href=&#34;https://medium.com/@jonaldfyookball/mathematical-proof-that-the-lightning-network-cannot-be-a-decentralized-bitcoin-scaling-solution-1b8147650800&#34;&gt;Jonald Fyookball&amp;rsquo;s article&lt;/a&gt; which claims to provide mathematical proof that the Lightning Network will fail to provide a &amp;lsquo;Decentralized Bitcoin Scaling Solution&amp;rsquo;.&lt;/p&gt;
&lt;p&gt;It starts with a short description of single hop and multihop payments. After that it asserts that it will be infeasible to scale such a network topology to a any significant size.&lt;/p&gt;
&lt;p&gt;Before exploring the details, the author already knows what the topology of the Lightning Network will look like (image from the article):&lt;/p&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/fyookball-decentralized.png&#34; alt=&#34;Comparison of centralized, decentralized and distributed networks from Fyookball&amp;#39;s article&#34;&gt;
&lt;/figure&gt;

&lt;p&gt;Let&amp;rsquo;s ignore for a moment the obvious grievance of evidence being circularly derived from preconceived conclusions instead of observations and evidence.&lt;/p&gt;
&lt;p&gt;The author correctly recognizes that using LN for a single payment would be pointless as a direct on-chain payment would be more efficient. Next, they present a model of what they think potential routes would look like from the viewpoint of a user (image from the article):&lt;/p&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/fyookball-tree.png&#34; alt=&#34;Showing a tree with a single path highlighted&#34;&gt;
&lt;/figure&gt;

&lt;p&gt;The author muses that &amp;ldquo;probably only one of these channels will reach the intended recipient at any given time&amp;rdquo;. This crucial assumption is not further corroborated, and doesn&amp;rsquo;t make any sense. Simply, the presented tree model is not an accurate representation:&lt;br&gt;
When a LN participant searches for a route, they&amp;rsquo;re obviously only interested in directed payment capacity. This aspect is correctly represented in the tree. However, the nodes along the route are interconnected. While this could even allow cycles to occur, cycles are not possible in the route construction, as it would allow participants involved multiple times to cut out the cycle when learning the secret for the first time. The resulting graph is what we call a DAG or directed acyclic graph:&lt;/p&gt;

&lt;figure class=&#34;image center&#34;&gt;
&lt;img src=&#34;http://murch.one/images/wikipedia-dag.png&#34; alt=&#34;Image showing a Directed acyclic graph&#34;&gt;
&lt;figcaption&gt;
Directed acyclic graph [&lt;a href=&#34;https://en.wikipedia.org/wiki/Directed_acyclic_graph&#34;&gt;image from wikipedia&lt;/a&gt;]&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The interesting takeaway is that the &lt;strong&gt;assumption of only one route is far-fetched&lt;/strong&gt;: once a connection is found, any part of the route can be exchanged for a parallel path, allowing for a multitude of possible combinations.&lt;/p&gt;
&lt;h3 id=&#34;misrepresentation-of-payment-forwarding-as-lending&#34;&gt;Misrepresentation of payment forwarding as &amp;lsquo;Lending&amp;rsquo;&lt;/h3&gt;
&lt;p&gt;The multihop payments in LN are constructed such that forwarding a contract to the next hop is equivalent to committing to the contract. Once the recipient receives the contract through the route, they can use the enclosed secret to immediately pull in the payment from the last forwarder. To get paid, the recipient inextricably trades the secret to the last forwarder, who in turn then can trigger the payment to themselves. Forwarders do not lend money. They trade balance in one payment channel for balance in another. As each hop has to advance the payment before receiving it, they are intrinsically motivated to execute the next hop as soon as possible. This allows to surmise that the recipient will be paid immediately, and in all likelihood all of the hops will be settled within milliseconds after a route has been established.&lt;br&gt;
Once both hops a forwarder is involved in are resolved, all balances are settled and free to be used in other payments. It is therefore inexplicable what Jonald is getting at, when they suggest that a high amount of routing activity would reduce the availability of a user&amp;rsquo;s channel.&lt;/p&gt;
&lt;h3 id=&#34;assumptions-about-routing&#34;&gt;Assumptions about Routing&lt;/h3&gt;
&lt;p&gt;The author next collects a bunch of assertions from which they conclude that the network would be deficient.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Random searching of the graph has a low success rate&lt;/strong&gt;&lt;br&gt;
This point is likely related to the deficient route model, however, it is trivial to do better than randomly searching the graph. An early approach suggested by &lt;a href=&#34;https://medium.com/@rusty_lightning/lightning-routing-rough-background-dbac930abbad&#34;&gt;Rusty Russel&lt;/a&gt; for example prescribes each peer learning their local topology. If and when the network grows too large for this, it could be overarched with a landmark approach. The suggestion of randomly generating and trying routes is laughably inefficient and thus can&amp;rsquo;t be taken serious as a limiting factor for the network.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Channels are exclusively used in one direction&lt;/strong&gt;&lt;br&gt;
Firstly, by channels being part of various routing attempts in different directions, it is not obvious that channels will not rebalance themselves more frequently, and even if it were true, doubling the channels would not be a solution. Besides, it could for example be feasible to combine onchain payments with a &amp;ldquo;Lightning Network refund&amp;rdquo; for more frequent rebalancing of payment channels, in fact, this could relieve users of creating change outputs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Routing for others unbalances channels and decreases usable channels.&lt;/strong&gt;&lt;br&gt;
Again, since channels are bidirectional and we&amp;rsquo;re not in a tree graph but an interconnected graph, it may actually be possible that e.g. A→B→C→D and A→C→B→D both exist, thus even two subsequent payments from A to D may rebalance the channel between B and C.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Wealth disparity limits number of routes that can forward payments.&lt;/strong&gt;&lt;br&gt;
Obviously channels can only forward to the limit of their own capacity. In conclusion a route can only transfer the capacity of the weakest link. This is in particular why Lightning Network has been described as a &lt;strong&gt;scalability solution for micropayments and low-value payments&lt;/strong&gt;. As low-value payments are least competitive on-chain but more frequent, this is in fact a great proposition. Larger payments are more economical on-chain anyway as the fees will represent a smaller relative portion of the transferred value. It seems obvious, that Lightning Network payment requests would soon be extended to allow payments to be split over multiple routes to mitigate the capacity limitations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&amp;ldquo;There always exists a risk of a routing channel becoming unresponsive (either intentionally or unintentionally). This risk also grows exponentially with an increasing number of hops.&amp;rdquo;&lt;/strong&gt;&lt;br&gt;
As there are many routes from each node to each other node, the network is self-mending. The channel partner of the offline party can choose to terminate the channel and after conclusion thereof put the funds into another channel that is more reliable. If a peer goes offline while participating in a multihop payment, either the payment fails, or the offline participant will only collect their payment with a delay. Participants with low uptimes will likely be peered less with and have smaller channel capacities. They will also likely not be heavy participants in the payment network anyway.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As the model on which Fyookball is basing their calculations is already far-fetched, I will not bother addressing the math.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Capacity vs Scalability</title>
      <link>http://murch.one/posts/capacity-scalability/</link>
      <pubDate>Sat, 14 Jan 2017 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/capacity-scalability/</guid>
      <description>&lt;p&gt;Let&amp;rsquo;s talk about terminology.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Capacity&lt;/strong&gt;: The number of transactions that can be processed on the network.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Scalability&lt;/strong&gt;: Capability of the network to handle a growing amount of work.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Examples&lt;/em&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;A 2MB hardfork is a capacity increase but not a scalability improvement.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Segregated Witness is a capacity increase and a scalability improvement.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Monero has no block size limit and thus a higher capacity than Bitcoin, however its TXO pool is unpruneable, its blockchain would grow faster at same usage, and its transactions take more computational effort to validate, so it doesn&amp;rsquo;t scale as well as Bitcoin.&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;
</description>
    </item>
    
    <item>
      <title>The Lightning Network is not a sidechain</title>
      <link>http://murch.one/posts/ln-no-sidechain/</link>
      <pubDate>Tue, 08 Mar 2016 00:00:00 +0000</pubDate>
      <guid>http://murch.one/posts/ln-no-sidechain/</guid>
      <description>&lt;p&gt;The Lightning network is not a sidechain.&lt;/p&gt;
&lt;p&gt;A sidechain relies on its own blockchain which is coupled to the Bitcoin blockchain via a two-way peg.&lt;/p&gt;
&lt;p&gt;On the other hand, the Lightning Network consists of native Bitcoin 2-of-2 multisig transactions.&lt;/p&gt;
&lt;p&gt;When two Lightning nodes open a payment channel, they both send funds to one multisig address and each provides the counterparty with a pre-signed exit transaction. If a party wants to resolve the payment channel, they can unilaterally add their own (the second) signature and send the transaction to the Bitcoin network for confirmation.&lt;/p&gt;
&lt;p&gt;However, it is more efficient to update the balance of the payment channel repeatedly by exchanging new exit transactions. The updated exit transactions simultaneously invalidate the previous exit transaction. Whenever anyone wants to get out or tries to cheat (by using an invalid exit transaction), the exit transaction is moved to the Bitcoin blockchain for arbitration. Newer exit transactions then may override older ones&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;So, while Lightning transactions can happen off-chain, they can be put on-chain anytime.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;this is a slight simplification of the mechanism&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>
