<oembed><type>rich</type><version>1.0</version><author_name>npub1u03cz099kt69z9awg232rjvlt34azukpzkkvy5uqv64dj9j5fqtshdnn03</author_name><author_url>https://nostr.ae/npub1u03cz099kt69z9awg232rjvlt34azukpzkkvy5uqv64dj9j5fqtshdnn03</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2019-10-01&#xA;📝 Original message:&#xA;I do have some concerns about SIGHASH_NOINPUT, mainly that it does&#xA;introduce another footgun into the bitcoin protocol with address reuse.&#xA;It&#39;s common practice for bitcoin businesses to re-use addresses. Many&#xA;exchanges [1] reuse addresses for cold storage with very large sums of&#xA;money that is stored in these addreses.&#xA;&#xA;It is my understanding with this part of BIP118&#xA;&#xA;&gt;Using NOINPUT the input containing the signature no longer references a&#xA;specific output. Any participant can take a transaction and rewrite it by&#xA;changing the hash reference to the previous output, without invalidating&#xA;the signatures. This allows transactions to be bound to any output that&#xA;matches the value committed to in the witness and whose witnessProgram,&#xA;combined with the spending transaction&#39;s witness returns true.&#xA;&#xA;if an exchange were to once produce a digital signature from that cold&#xA;storage address with a SIGHASH_NOINPUT signature, that signature can be&#xA;replayed again and again on the blockchain until their wallet is drained.&#xA;This might be able to mitigated since the signatures commit to outputs,&#xA;which may be small in value for the transaction that SIGHASH_NOINPUT was&#xA;used. This means that an exchange could move coins from the address with a&#xA;larger transaction that spends money to a new output (and presumably pays a&#xA;higher fee than the smaller transactions).&#xA;&#xA;### Why does this matter?&#xA;&#xA;It seems that SIGHASH_NOINPUT will be an extremely useful tool for offchain&#xA;protocols like Lightning. This gives us the building blocks for enforcing&#xA;specific offchain states to end up onchain [2].&#xA;&#xA;Since this tool is useful, we can presume that it will be integrated into&#xA;the signing path of large economic entities in bitcoin -- namely exchanges.&#xA;Many exchanges have specific signing procedures for transactions that are&#xA;leaving an exchange that is custom software. Now -- presuming wide adoption&#xA;of off chain protocols -- they will need to have a _second unique signing&#xA;path that uses SIGHASH_NOINPUT_.&#xA;&#xA;It is imperative that this second signing path -- which uses&#xA;SIGHASH_NOINPUT -- does NOT get mixed up with the first signing path that&#xA;controls an exchanges onchain funds. If this were to happen, fund lost&#xA;could occur if the exchange is reusing address, which seems to be common&#xA;practice.&#xA;&#xA;This is stated here in BIP118:&#xA;&#xA;&gt;This also means that particular care has to be taken in order to avoid&#xA;unintentionally enabling this rebinding mechanism. NOINPUT MUST NOT be&#xA;used, unless it is explicitly needed for the application, e.g., it MUST NOT&#xA;be a default signing flag in a wallet implementation. Rebinding is only&#xA;possible when the outputs the transaction may bind to all use the same&#xA;public keys. Any public key that is used in a NOINPUT signature MUST only&#xA;be used for outputs that the input may bind to, and they MUST NOT be used&#xA;for transactions that the input may not bind to. For example an application&#xA;SHOULD generate a new key-pair for the application instance using NOINPUT&#xA;signatures and MUST NOT reuse them afterwards.&#xA;&#xA;This means we need to encourage onchain hot wallet signing procedures to be&#xA;kept separate from offchain hot wallet signing procedures, which introduces&#xA;more complexity for key management (two keychains).&#xA;&#xA;One (of the few) upsides of the current Lightning penalty mechanism is that&#xA;fund loss can be contained to balance of the channel. You cannot do&#xA;something in the current protocol that will effect your funds outside of&#xA;that channel. With SIGHASH_NOINPUT, that property changes.&#xA;&#xA;### A side note&#xA;In general, i think we should start disallowing uses of the SIGHASH&#xA;protocols that have unexpected behavior. The classic example of this is&#xA;SIGHASH_SINGLE [3]. I get uneasy about adding more footguns to the&#xA;protocol, which with current network behavior (address re-use)&#xA;SIGHASH_NOINPUT would be a big one.&#xA;&#xA;&#xA;[1] - https://bitinfocharts.com/top-100-richest-bitcoin-addresses.html&#xA;[2] -&#xA;https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-September/002136.html&#xA;[3] -&#xA;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-May/016048.html&#xA;&#xA;On Mon, Sep 30, 2019 at 9:24 AM Christian Decker via bitcoin-dev &lt;&#xA;bitcoin-dev at lists.linuxfoundation.org&gt; wrote:&#xA;&#xA;&gt; With the recently renewed interest in eltoo, a proof-of-concept&#xA;&gt; implementation&#xA;&gt; [1], and the discussions regarding clean abstractions for off-chain&#xA;&gt; protocols&#xA;&gt; [2,3], I thought it might be time to revisit the `sighash_noinput` proposal&#xA;&gt; (BIP-118 [4]), and AJ&#39;s `bip-anyprevout` proposal [5].&#xA;&gt;&#xA;&gt; (sorry for the long e-mail. I wanted to give enough context and describe&#xA;&gt; the&#xA;&gt; various tradeoffs so people don&#39;t have to stitch them together from&#xA;&gt; memory. If&#xA;&gt; you&#39;re impatient there are a couple of open questions at the bottom)&#xA;&gt;&#xA;&gt; Both proposals are ways to allow rebinding of transactions to new outputs,&#xA;&gt; by&#xA;&gt; adding a sighash flag that excludes the output when signing. This allows&#xA;&gt; the&#xA;&gt; transaction to be bound to any output, without needing a new signature, as&#xA;&gt; long as output script and input script are compatible, e.g., the signature&#xA;&gt; matches the public key specified in the output.&#xA;&gt;&#xA;&gt; BIP-118 is limited to explaining the details of signature verification, and&#xA;&gt; omits anything related to deployment and dependency on other proposals.&#xA;&gt; This&#xA;&gt; was done in order not to depend on bip-taproot which is also in draft-phase&#xA;&gt; currently, and to allow deployment alongside the next version of segwit&#xA;&gt; script. `bip-anyprevout` builds on top of BIP-118, adding integration with&#xA;&gt; `bip-taproot`, chaperone signatures, limits the use of the sighash flag to&#xA;&gt; script path spends, as well as a new pubkey serialization which uses the&#xA;&gt; first&#xA;&gt; byte to signal opt-in.&#xA;&gt;&#xA;&gt; I&#39;d like to stress that both proposals are complementary and not competing,&#xA;&gt; which is something that I&#39;ve heard a couple of times.&#xA;&gt;&#xA;&gt; There remain a couple of unclear points which I hope we can address in the&#xA;&gt; coming days, to get this thing moving again, and hopefully get a new tool&#xA;&gt; in&#xA;&gt; our toolbox soon(ish).&#xA;&gt;&#xA;&gt; In the following I will quote a couple of things that were discussed during&#xA;&gt; the CoreDev meeting earlier this year, but not everybody could join, and&#xA;&gt; it is&#xA;&gt; important that we engage the wider community, to get a better picture, and&#xA;&gt; I&#xA;&gt; think not everybody is up-to-date about the current state.&#xA;&gt;&#xA;&gt;&#xA;&gt; ## Dangers of `sighash_noinput`&#xA;&gt;&#xA;&gt; An argument I have heard against noinput is that it is slightly less&#xA;&gt; complex&#xA;&gt; or compute intensive than `sighash_all` signatures, which may encourage&#xA;&gt; wallet&#xA;&gt; creators to only implement the noinput variant, and use it indiscrimi-&#xA;&gt; nately. This is certainly a good argument, and indeed we have seen at least&#xA;&gt; one developer proposing to use noinput for all transactions to discourage&#xA;&gt; address reuse.&#xA;&gt;&#xA;&gt; This was also mentioned at CoreDev [6]:&#xA;&gt;&#xA;&gt; &gt; When [...] said he wanted to write a wallet that only used&#xA;&gt; SIGHASH\_NOINPUT,&#xA;&gt; &gt; that was pause for concern. Some people might want to use&#xA;&gt; SIGHASH\_NOINPUT as a&#xA;&gt; &gt; way to cheapen or reduce the complexity of making a wallet&#xA;&gt; &gt; implementation. SIGHASH\_NOINPUT is from a purely procedural point of&#xA;&gt; view&#xA;&gt; &gt; easier than doing a SIGHASH\_ALL, that&#39;s all I&#39;m saying. So you&#39;re&#xA;&gt; hashing&#xA;&gt; &gt; less. It&#39;s way faster. That concern has been brought to my attention and&#xA;&gt; it&#39;s&#xA;&gt; &gt; something I can see. Do we want to avoid people being stupid and shooting&#xA;&gt; &gt; themselves and their customers in the foot? Or do we treat this as a&#xA;&gt; special&#xA;&gt; &gt; case where you mark we&#39;re aware of how it should be used and we just try&#xA;&gt; to&#xA;&gt; &gt; get that awareness out?&#xA;&gt;&#xA;&gt; Another issue that is sometimes brought up is that an external user may&#xA;&gt; attempt to send funds to a script that was really part of a higher-level&#xA;&gt; protocol. This leads to those funds becoming inaccessible unless you gather&#xA;&gt; all the participants and sign off on those funds. I don&#39;t believe this is&#xA;&gt; anything new, and if users really want to shoot themselves in the foot and&#xA;&gt; send funds to random addresses they fish out of a blockexplorer there&#39;s&#xA;&gt; little&#xA;&gt; we can do. What we could do is make the scripts used internally in our&#xA;&gt; protocols unaddressable (see output tagging below), removing this issue&#xA;&gt; altogether.&#xA;&gt;&#xA;&gt;&#xA;&gt; ## Chaperone signatures&#xA;&gt;&#xA;&gt; Chaperone signatures are signatures that ensure that there is no&#xA;&gt; third-party&#xA;&gt; malleability of transactions. The idea is to have an additional signature,&#xA;&gt; that doesn&#39;t use noinput, or any of its variants, and therefore needs to be&#xA;&gt; authored by one of the pubkeys in the output script, i.e., one or more of&#xA;&gt; the&#xA;&gt; participants of the contract the transaction belongs to. Concretely in&#xA;&gt; eltoo&#xA;&gt; we&#39;d be using a shared key known to all participants in the eltoo&#xA;&gt; instance, so&#xA;&gt; any participant can sign an update to rebind it to the desired output.&#xA;&gt;&#xA;&gt; Chaperone signatures have a number of downsides however:&#xA;&gt;&#xA;&gt; -   Additional size: both the public key and the signature actually need&#xA;&gt; to be&#xA;&gt;     stored along with the real noinput signature, resulting in transfer,&#xA;&gt;     computational and storage overhead. We can&#39;t reuse the same pubkey&#xA;&gt; from the&#xA;&gt;     noinput signature since that&#39;d require access to the matching privkey&#xA;&gt; which&#xA;&gt;     is what we want to get rid of using noinput in the first place.&#xA;&gt; -   Protocols can still simply use a globally known privkey, voiding the&#xA;&gt;     benefit of chaperone signatures, since third-parties can sign again. I&#xA;&gt;     argue that third-party malleability is a subset of first-party&#xA;&gt;     malleability, and we should protect against first-party malleability&#xA;&gt; first&#xA;&gt;     and foremost. My counterparty has the incentive to trick me, a&#xA;&gt; third-party&#xA;&gt;     may not.&#xA;&gt;&#xA;&gt; On the plus side chaperone signatures certainly address the lazy-wallet-dev&#xA;&gt; scenario, and as AJ points out in [bip-anyprevout] we get back the same&#xA;&gt; security guarantees as we had without noinput.&#xA;&gt;&#xA;&gt; From what I remember and the transcript (thanks Kanzure for your awesome&#xA;&gt; work&#xA;&gt; by the way), there was no strong support for chaperone signatures during&#xA;&gt; the&#xA;&gt; meeting [6], but feedback from people that were not present is needed:&#xA;&gt;&#xA;&gt; &gt; if everyone who wanted to use NOINPUT was convinced there was a problem,&#xA;&gt; then&#xA;&gt; &gt; they would pick the right thing, but clearly people aren&#39;t. It&#39;s not a&#xA;&gt; &gt; foot-gun defense mechanism because it&#39;s easily bypassed, and it&#39;s easier&#xA;&gt; to&#xA;&gt; &gt; bypass it than to use it. Whereas for tagged outputs, it&#39;s that if you&#xA;&gt; want&#xA;&gt; &gt; any NOINPUT then you must tag.&#xA;&gt;&#xA;&gt;&#xA;&gt; ## Output tagging&#xA;&gt;&#xA;&gt; One proposal that I found rather fascinating during the discussion in&#xA;&gt; Amsterdam was that we could achieve the same disincentive to use on&#xA;&gt; non-smart-contract cases by simply making the output scripts&#xA;&gt; unaddressable. This can be done by specifying a version of taproot outputs&#xA;&gt; for&#xA;&gt; which the bech32 addressing scheme simply doesn&#39;t have a representation&#xA;&gt; [6]:&#xA;&gt;&#xA;&gt; &gt; The tagged outputs idea is that we don&#39;t have NOINPUT ANYPREVOUT&#xA;&gt; supported for&#xA;&gt; &gt; taproot v1 outputs, instead we have a segwit version 16 v16 that supports&#xA;&gt; &gt; taproot. The reason for v16 is that we redefine bech32 to not cover&#xA;&gt; &gt; v16. There&#39;s no addresses for this type of output. If you&#39;re an exchange&#xA;&gt; and&#xA;&gt; &gt; receive a bech32 address, you declare it invalid. You make it less user&#xA;&gt; &gt; friendly here; and there shouldn&#39;t be an address anyway. You might want&#xA;&gt; to see&#xA;&gt; &gt; it on a block explorer, but you don&#39;t want to pass it around to anyone.&#xA;&gt;&#xA;&gt; We don&#39;t need addresses in our contract constructions because we deal&#xA;&gt; directly&#xA;&gt; with the scripts. This would also have the desired effect of no allowing&#xA;&gt; generic wallets to send to these addresses, or users accidentally sending&#xA;&gt; funds to what was supposed to be a one-off script used internally in the&#xA;&gt; off-chain contract.&#xA;&gt;&#xA;&gt; Notice that this idea was already used by Russell O&#39;Connor when performing&#xA;&gt; a&#xA;&gt; transaction on elements using his new scripting language simplicity&#xA;&gt; [7]:&#xA;&gt;&#xA;&gt; &gt; For this experimental development, we created an improper segwit version,&#xA;&gt; &gt; &#34;version 31&#34; for Simplicity addresses. The payload of this segwit&#xA;&gt; version 31&#xA;&gt; &gt; address contains a commitment Merkle root of a Simplicity program to&#xA;&gt; control&#xA;&gt; &gt; the UTXO.&#xA;&gt;&#xA;&gt; The concern with output tagging is that it hurts fungibility, marking&#xA;&gt; outputs&#xA;&gt; used in a contract as such and making them identifiable. But maybe it&#xA;&gt; would be&#xA;&gt; a good idea to create two domains anyway: one for user-addressable&#xA;&gt; destinations which users can use with their general purpose wallets, and&#xA;&gt; one&#xA;&gt; domain for contracts, which users cannot send to directly.&#xA;&gt;&#xA;&gt; This also came up during the CoreDev meeting [ams-coredev]:&#xA;&gt;&#xA;&gt; &gt; these sort of NOINPUT signatures are only things that are within some&#xA;&gt; &gt; application or within some protocol that gets negotiated between&#xA;&gt; participants,&#xA;&gt; &gt; but they don&#39;t cross-independent domains where you see a wallet or a&#xA;&gt; protocol&#xA;&gt; &gt; as a kind of domain. You can&#39;t tell the difference, is this an address I&#xA;&gt; can&#xA;&gt; &gt; give to someone else or not? It&#39;s all scripts, no real addresses. There&#xA;&gt; are&#xA;&gt; &gt; types of outputs that are completely insecure unconditionally; there are&#xA;&gt; &gt; things that are protected and I can give to anyone, you don&#39;t want to&#xA;&gt; reuse&#xA;&gt; &gt; it, but there&#39;s no security issue from doing so. This is an additional&#xA;&gt; class&#xA;&gt; &gt; that is secure perfectly but only when used in the right way.&#xA;&gt;&#xA;&gt;&#xA;&gt; ## Open questions&#xA;&gt;&#xA;&gt; The questions that remain to be addressed are the following:&#xA;&gt;&#xA;&gt; 1.  General agreement on the usefulness of noinput / anyprevoutanyscript /&#xA;&gt;     anyprevout. While at the CoreDev meeting I think everybody agreed that&#xA;&gt;     these proposals a useful, also beyond eltoo, not everybody could be&#xA;&gt;     there. I&#39;d therefore like to elicit some feedback from the wider&#xA;&gt; community.&#xA;&gt; 2.  Is there strong support or opposition to the chaperone signatures&#xA;&gt;     introduced in anyprevout / anyprevoutanyscript? I think it&#39;d be best to&#xA;&gt;     formulate a concrete set of pros and contras, rather than talk about&#xA;&gt;     abstract dangers or advantages.&#xA;&gt; 3.  The same for output tagging / explicit opt-in. What are the advantages&#xA;&gt; and&#xA;&gt;     disadvantages?&#xA;&gt; 4.  Shall we merge BIP-118 and bip-anyprevout. This would likely reduce the&#xA;&gt;     confusion and make for simpler discussions in the end.&#xA;&gt; 5.  Anything I forgot to mention :-)&#xA;&gt;&#xA;&gt; Cheers,&#xA;&gt; Christian&#xA;&gt;&#xA;&gt; [1] &lt;&#xA;&gt; https://lists.linuxfoundation.org/pipermail/lightning-dev/2019-September/002131.html&#xA;&gt; &gt;&#xA;&gt; [2] &lt;&#xA;&gt; https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-September/017285.html&#xA;&gt; &gt;&#xA;&gt; [3] &lt;&#xA;&gt; https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-August/001383.html&#xA;&gt; &gt;&#xA;&gt; [4] &lt;https://github.com/bitcoin/bips/blob/master/bip-0118.mediawiki&gt;&#xA;&gt; [5] &lt;&#xA;&gt; https://github.com/ajtowns/bips/blob/bip-anyprevout/bip-anyprevout.mediawiki&#xA;&gt; &gt;&#xA;&gt; [6] &lt;&#xA;&gt; http://diyhpl.us/wiki/transcripts/bitcoin-core-dev-tech/2019-06-06-noinput-etc/&#xA;&gt; &gt;&#xA;&gt; [7] &lt;https://lists.ozlabs.org/pipermail/simplicity/2019/000018.html&gt;&#xA;&gt; _______________________________________________&#xA;&gt; bitcoin-dev mailing list&#xA;&gt; bitcoin-dev at lists.linuxfoundation.org&#xA;&gt; https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&#xA;&gt;&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20191001/6260f1ba/attachment-0001.html&gt;</html></oembed>