<oembed><type>rich</type><version>1.0</version><author_name>npub1mlpmsc5sm93tw2fp2dhhuwmxcqm59wz6hjg5g3afq5rucfll3f9sh4yf8d</author_name><author_url>https://nostr.ae/npub1mlpmsc5sm93tw2fp2dhhuwmxcqm59wz6hjg5g3afq5rucfll3f9sh4yf8d</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2017-11-06&#xA;📝 Original message:Thanks Mats, this proposal makes sense to me (especially the idea of&#xA;fork-specific addresses).  It prevents replay across forks, and makes it&#xA;easy for client software, and thus potentially users, to specify which fork&#xA;a tx is for.  But, like other (rougher) past proposals I&#39;ve seen, it does&#xA;little to prevent users from accidentally sending on the wrong fork.&#xA;&#xA;Take the specific and common case of non-upgraded wallet software.  Suppose&#xA;a HF happens, and becomes the network used by 90% of users.  Will old&#xA;wallets still default to the old nForkId (10% legacy chain)?  If so, I&#39;d&#xA;expect a lot of accidental mis-sends on that chain.&#xA;&#xA;This is just a gap in your proposal, not a flaw, but it&#39;s worth thinking&#xA;about less hazard-prone ways wallets could default nForkId.  Perhaps they&#xA;could listen to all forks, and default to the one whose last (recent) block&#xA;had the highest difficulty?  Or just check those blocks to see if multiple&#xA;forks are (nontrivially) active, and if so warn the user and force them to&#xA;confirm?  Something like that.&#xA;&#xA;&#xA;On Nov 6, 2017 7:05 AM, &#34;Mats Jerratsch via bitcoin-dev&#34; &lt;&#xA;bitcoin-dev at lists.linuxfoundation.org&gt; wrote:&#xA;&#xA;&#xA;Presented is a generalised way of providing replay protection for future&#xA;hard forks. On top of replay protection, this schema also allows for&#xA;fork-distinct addresses and potentially a way to opt-out of replay&#xA;protection of any fork, where deemed necessary (can be beneficial for some&#xA;L2 applications).&#xA;&#xA;## Rationale&#xA;&#xA;Currently when a hard fork happens, there is ad-hoc replay protection built&#xA;within days with little review at best, or no replay protection at all.&#xA;Often this is either resource problem, where not enough time and developers&#xA;are available to sufficiently address replay protection, or the idea that&#xA;not breaking compatibility is favourable. Furthermore, this is potentially&#xA;a recurring problem with no generally accepted solution yet. Services that&#xA;want to deal in multiple forks are expected to closely follow all projects.&#xA;Since there is no standard, the solutions differ for each project,&#xA;requiring custom code for every fork. By integrating replay protection into&#xA;the protocol, we advocate the notion of non-hostile forks.&#xA;&#xA;Users are protected against accidentally sending coins on the wrong chain&#xA;through the introduction of a fork-specific incompatible address space. The&#xA;coin/token type is encoded in the address itself, removing some of the&#xA;importance around the question _What is Bitcoin?_. By giving someone an&#xA;address, it is explicitly stated _I will only honour a payment of token X_,&#xA;enforcing the idea of validating the payment under the rules chosen by the&#xA;payee.&#xA;&#xA;## Iterative Forks&#xA;&#xA;In this schema, any hard fork is given an incremented id, `nForkId`.&#xA;`nForkId` starts at `1`, with `0` being reserved as a wildcard. When&#xA;project X decides to make an incompatible change to the protocol, it will&#xA;get assigned a new unique `nForkId` for this fork. A similar approach like&#xA;for BIP43 can be taken here. Potentially `nForkId` can be reused if a&#xA;project has not gained any amount of traction.&#xA;&#xA;When preparing the transaction for signing or validation, `nForkId` is&#xA;appended to the final template as a 4B integer (similar to [1]). Amending&#xA;BIP143, this would result in&#xA;&#xA;```&#xA;Double SHA256 of the serialization of:&#xA;    1. nVersion of the transaction (4-byte little endian)&#xA;    2. hashPrevouts (32-byte hash)&#xA;    3. hashSequence (32-byte hash)&#xA;    4. outpoint (32-byte hash + 4-byte little endian)&#xA;    5. scriptCode of the input (serialized as scripts inside CTxOuts)&#xA;    6. value of the output spent by this input (8-byte little endian)&#xA;    7. nSequence of the input (4-byte little endian)&#xA;    8. hashOutputs (32-byte hash)&#xA;    9. nLocktime of the transaction (4-byte little endian)&#xA;   10. sighash type of the signature (4-byte little endian)&#xA;   11. nForkId (4-byte little endian)&#xA;```&#xA;&#xA;&#xA;For `nForkId=0` this step is ommitted. This will immediately invalidate&#xA;signatures for any other branch of the blockchain than this specific fork.&#xA;To distinguish between `nForkId=0` and `nForkId` hardcoded into the&#xA;software, another bit has to be set in the 1B SigHashId present at the end&#xA;of signatures.&#xA;&#xA;To make this approach more generic, payment addresses will contain the fork&#xA;id, depending on which tokens a payee expects payments in. This would&#xA;require a change on bech32 addresses, maybe to use a similar format used in&#xA;lightning-rfc [2]. A wallet will parse the address, it will extract&#xA;`nForkId`, and it displays which token the user is about to spend. When&#xA;signing the transaction, it will use `nForkId`, such that the transaction&#xA;is only valid for this specific token. This can be generalised in software&#xA;to the point where replay protection *and* a new address space can be&#xA;introduced for forks without breaking existing clients.&#xA;&#xA;For light clients, this can be extended by enforcing the coinbase/block&#xA;header to contain the `nForkId` of the block. Then the client can&#xA;distinguish between different chains and tokens it received on each.&#xA;Alternatively, a new P2P message type for sending transactions could be&#xA;introduced, where prevOut and `nForkId` is transmitted, such that the lite&#xA;client can check for himself, which token he received.&#xA;&#xA;Allowing signatures with `nForkId=1` can be achieved with a soft fork by&#xA;incrementing the script version of SegWit, making this a fully backwards&#xA;compatible change.&#xA;&#xA;[1]&#xA;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/&#xA;2017-February/013542.html&#xA;&#xA;[2]&#xA;https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-&#xA;encoding.md&#xA;&#xA;_______________________________________________&#xA;bitcoin-dev mailing list&#xA;bitcoin-dev at lists.linuxfoundation.org&#xA;https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20171106/91e3799f/attachment.html&gt;</html></oembed>