{"type":"rich","version":"1.0","author_name":"npub1gaszwl7qd0tjmnwcaamgzzgsmzzjlvle6kz0td66pwa8z69vsxsqxgac47","author_url":"https://nostr.ae/npub1gaszwl7qd0tjmnwcaamgzzgsmzzjlvle6kz0td66pwa8z69vsxsqxgac47","provider_name":"njump","provider_url":"https://nostr.ae","html":"📅 Original date posted:2019-10-03\n📝 Original message:I hope you are having an great afternoon ZmnSCPxj,\n\nYou make an excellent point!\n\nI had thought about doing the following to tag nodes\n\n|| means OP_CAT\n\n`node = SHA256(type||SHA256(data))`\nso a subnode would be\n`subnode1 = SHA256(1||SHA256(subnode2||subnode3))`\nand a leaf node would be\n`leafnode = SHA256(0||SHA256(leafdata))`\n\nYet, I like your idea better. Increasing the size of the two inputs to\nOP_CAT to be 260 Bytes each where 520 Bytes is the maximum allowable\nsize of object on the stack seems sensible and also doesn't special\ncase the logic of OP_CAT.\n\nIt would also increase performance. SHA256(tag||subnode2||subnode3)\nrequires 2 compression function calls whereas\nSHA256(1||SHA256(subnode2||subnode3)) requires 2+1=3 compression\nfunction calls (due to padding).\n\n\u003eOr we could implement tagged SHA256 as a new opcode...\n\nI agree that tagged SHA256 as an op code that would certainty be\nuseful, but OP_CAT provides far more utility and is a simpler change.\n\nThanks,\nEthan\n\nOn Thu, Oct 3, 2019 at 7:42 PM ZmnSCPxj \u003cZmnSCPxj at protonmail.com\u003e wrote:\n\u003e\n\u003e Good morning Ethan,\n\u003e\n\u003e\n\u003e \u003e To avoid derailing the NO_INPUT conversation, I have changed the\n\u003e \u003e subject to OP_CAT.\n\u003e \u003e\n\u003e \u003e Responding to:\n\u003e \u003e \"\"\"\n\u003e \u003e\n\u003e \u003e -   `SIGHASH` flags attached to signatures are a misdesign, sadly\n\u003e \u003e     retained from the original BitCoin 0.1.0 Alpha for Windows design, on\n\u003e \u003e     par with:\n\u003e \u003e     [..]\n\u003e \u003e\n\u003e \u003e -   `OP_CAT` and `OP_MULT` and `OP_ADD` and friends\n\u003e \u003e     [..]\n\u003e \u003e     \"\"\"\n\u003e \u003e\n\u003e \u003e     OP_CAT is an extremely valuable op code. I understand why it was\n\u003e \u003e     removed as the situation at the time with scripts was dire. However\n\u003e \u003e     most of the protocols I've wanted to build on Bitcoin run into the\n\u003e \u003e     limitation that stack values can not be concatenated. For instance\n\u003e \u003e     TumbleBit would have far smaller transaction sizes if OP_CAT was\n\u003e \u003e     supported in Bitcoin. If it happens to me as a researcher it is\n\u003e \u003e     probably holding other people back as well. If I could wave a magic\n\u003e \u003e     wand and turn on one of the disabled op codes it would be OP_CAT. Of\n\u003e \u003e     course with the change that size of each concatenated value must be 64\n\u003e \u003e     Bytes or less.\n\u003e\n\u003e Why 64 bytes in particular?\n\u003e\n\u003e It seems obvious to me that this 64 bytes is most suited for building Merkle trees, being the size of two SHA256 hashes.\n\u003e\n\u003e However we have had issues with the use of Merkle trees in Bitcoin blocks.\n\u003e Specifically, it is difficult to determine if a hash on a Merkle node is the hash of a Merkle subnode, or a leaf transaction.\n\u003e My understanding is that this is the reason for now requiring transactions to be at least 80 bytes.\n\u003e\n\u003e The obvious fix would be to prepend the type of the hashed object, i.e. add at least one byte to determine this type.\n\u003e Taproot for example uses tagged hash functions, with a different tag for leaves, and tagged hashes are just prepend-this-32-byte-constant-twice-before-you-SHA256.\n\u003e\n\u003e This seems to indicate that to check merkle tree proofs, an `OP_CAT` with only 64 bytes max output size would not be sufficient.\n\u003e\n\u003e Or we could implement tagged SHA256 as a new opcode...\n\u003e\n\u003e Regards,\n\u003e ZmnSCPxj\n\u003e\n\u003e\n\u003e \u003e\n\u003e \u003e     On Tue, Oct 1, 2019 at 10:04 PM ZmnSCPxj via bitcoin-dev\n\u003e \u003e     bitcoin-dev at lists.linuxfoundation.org wrote:\n\u003e \u003e\n\u003e \u003e\n\u003e \u003e \u003e Good morning lists,\n\u003e \u003e \u003e Let me propose the below radical idea:\n\u003e \u003e \u003e\n\u003e \u003e \u003e -   `SIGHASH` flags attached to signatures are a misdesign, sadly retained from the original BitCoin 0.1.0 Alpha for Windows design, on par with:\n\u003e \u003e \u003e     -   1 RETURN\n\u003e \u003e \u003e     -   higher-`nSequence` replacement\n\u003e \u003e \u003e     -   DER-encoded pubkeys\n\u003e \u003e \u003e     -   unrestricted `scriptPubKey`\n\u003e \u003e \u003e     -   Payee-security-paid-by-payer (i.e. lack of P2SH)\n\u003e \u003e \u003e     -   `OP_CAT` and `OP_MULT` and `OP_ADD` and friends\n\u003e \u003e \u003e     -   transaction malleability\n\u003e \u003e \u003e     -   probably many more\n\u003e \u003e \u003e\n\u003e \u003e \u003e So let me propose the more radical excision, starting with SegWit v1:\n\u003e \u003e \u003e\n\u003e \u003e \u003e -   Remove `SIGHASH` from signatures.\n\u003e \u003e \u003e -   Put `SIGHASH` on public keys.\n\u003e \u003e \u003e\n\u003e \u003e \u003e Public keys are now encoded as either 33-bytes (implicit `SIGHASH_ALL`) or 34-bytes (`SIGHASH` byte, followed by pubkey type, followed by pubkey coordinate).\n\u003e \u003e \u003e `OP_CHECKSIG` and friends then look at the public key to determine sighash algorithm rather than the signature.\n\u003e \u003e \u003e As we expect public keys to be indirectly committed to on every output `scriptPubKey`, this is automatically output tagging to allow particular `SIGHASH`.\n\u003e \u003e \u003e However, we can then utilize the many many ways to hide public keys away until they are needed, exemplified in MAST-inside-Taproot.\n\u003e \u003e \u003e I propose also the addition of the opcode:\n\u003e \u003e \u003e\n\u003e \u003e \u003e     \u003csighash\u003e \u003cpubkey\u003e OP_SETPUBKEYSIGHASH\n\u003e \u003e \u003e\n\u003e \u003e \u003e\n\u003e \u003e \u003e -   `sighash` must be one byte.\n\u003e \u003e \u003e -   `pubkey` may be the special byte `0x1`, meaning \"just use the Taproot internal pubkey\".\n\u003e \u003e \u003e -   `pubkey` may be 33-byte public key, in which case the `sighash` byte is just prepended to it.\n\u003e \u003e \u003e -   `pubkey` may be 34-byte public key with sighash, in which case the first byte is replaced with `sighash` byte.\n\u003e \u003e \u003e -   If `sighash` is `0x00` then the result is a 33-byte public key (the sighash byte is removed) i.e. `SIGHASH_ALL` implicit.\n\u003e \u003e \u003e\n\u003e \u003e \u003e This retains the old feature where the sighash is selected at time-of-spending rather than time-of-payment.\n\u003e \u003e \u003e This is done by using the script:\n\u003e \u003e \u003e\n\u003e \u003e \u003e     \u003cpubkey\u003e OP_SETPUBKEYSIGHASH OP_CHECKSIG\n\u003e \u003e \u003e\n\u003e \u003e \u003e\n\u003e \u003e \u003e Then the sighash can be put in the witness stack after the signature, letting the `SIGHASH` flag be selected at time-of-signing, but only if the SCRIPT specifically is formed to do so.\n\u003e \u003e \u003e This is malleability-safe as the signature still commits to the `SIGHASH` it was created for.\n\u003e \u003e \u003e However, by default, public keys will not have an attached `SIGHASH` byte, implying `SIGHASH_ALL` (and disallowing-by-default non-`SIGHASH_ALL`).\n\u003e \u003e \u003e This removes the problems with `SIGHASH_NONE` `SIGHASH_SINGLE`, as they are allowed only if the output specifically says they are allowed.\n\u003e \u003e \u003e Would this not be a superior solution?\n\u003e \u003e \u003e Regards,\n\u003e \u003e \u003e ZmnSCPxj\n\u003e \u003e \u003e\n\u003e \u003e \u003e bitcoin-dev mailing list\n\u003e \u003e \u003e bitcoin-dev at lists.linuxfoundation.org\n\u003e \u003e \u003e https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev\n\u003e \u003e\n\u003e \u003e Lightning-dev mailing list\n\u003e \u003e Lightning-dev at lists.linuxfoundation.org\n\u003e \u003e https://lists.linuxfoundation.org/mailman/listinfo/lightning-dev\n\u003e\n\u003e"}
