Johnson Lau [ARCHIVE] on Nostr: 📅 Original date posted:2018-12-23 📝 Original message:> On 23 Dec 2018, at 12:26 ...
đź“… Original date posted:2018-12-23
📝 Original message:> On 23 Dec 2018, at 12:26 PM, Anthony Towns <aj at erisian.com.au> wrote:
>
> On Sat, Dec 22, 2018 at 02:54:42AM +0800, Johnson Lau wrote:
>> The question I would like to ask is: is OP_CODESEPARATOR useful under taproot? Generally speaking, CODESEPARATOR is useful only with conditional opcodes (OP_IF etc), and conditional opcodes are mostly replaced by merklized scripts. I am not sure how much usability is left with CODESEPARATOR
>
> If you don't have conditionals, then I think committing to the (masked)
> script gives you everything you could do with codeseparator.
I don’t think CODESEPARATOR is useful without conditionals. By useful I mean making a script more compact
>
> If you don't commit to the (masked) script, don't have conditionals,
> and don't have codeseparator, then I don't think you can make a signature
> distinguish which alternative script it's intending to sign; but you can
> just give each alternative script in the MAST a slight variation of the
> key and that seems good enough.
You can and should always use a different in different branch. If this best practice is always followed, committing to masked script is not necessary
>
> OTOH, I think for (roughly) the example you gave:
>
> DEPTH 3 EQUAL
> IF <Bob> CHECKSIGVERIFY HASH160 <H> EQUALVERIFY CODESEP
> ELSE <n> CLTV DROP
> ENDIF
> <Alice> CHECKSIG
>
> then compared to the taproot equivalent:
>
> P = muSig(Alice,Bob)
> S1 = <Alice1> CHECKSIGVERIFY <Bob> CHECKSIGVERIFY HASH160 <H> EQUAL
> S2 = <Alice2> CHECKSIGVERIFY <n> CLTV
>
> the IF+CODESEP approach is actually cheaper (lighter weight) if you're
> mostly (>2/3rds of the time) taking the S1 branch. This is because the
> "DEPTH 3 EQUAL IF/ELSE/ENDIF CODESEP <n> CLTV DROP" overhead is less
> than the 32B overhead to choose a merkle branch).
>
> (That said, I'm not sure what Alice's signature in the S1 branch actually
> achieves in that script; and without that in S1, the taproot approach is
> cheaper all the time. Scriptless scripts would be cheaper still)
>
>> If no one needs CODESEPARATOR, we might just disable it, and makes the validation code a bit simpler
>
> Since it only affects the behaviour of the checkdls (checksig) operators,
> even if it was disabled, it could be re-enabled fairly easily in a new
> script subversion if needed (ie, it could be re-added when upgrading
> witness version 1 from script version 0 to 1).
>
> Cheers,
> aj
>
Yes, I don’t think it needs Alice signature in S1 at all. So the original example doesn’t even need CODESEPARATOR at all.
Could anyone propose a better use case of CODESEPARATOR?
Published at
2023-06-07 18:15:39Event JSON
{
"id": "c206eee7b9f8b122234ae8dacfedd8fa418035d41aea4f085e258fab7670b9cc",
"pubkey": "492fa402e838904bdc8eb2c8fafa1aa895df26438bfd998c71b01cb9db550ff7",
"created_at": 1686161739,
"kind": 1,
"tags": [
[
"e",
"77c824d861e497590991b7dc940a75787db11a7b2eab6adcf5563d0847a4df18",
"",
"root"
],
[
"e",
"f2b0e0aa0b5d64fdcff99902d8cc3e5db614e81c0790e7f1fe22618d6cae1571",
"",
"reply"
],
[
"p",
"f0feda6ad58ea9f486e469f87b3b9996494363a26982b864667c5d8acb0542ab"
]
],
"content": "📅 Original date posted:2018-12-23\n📝 Original message:\u003e On 23 Dec 2018, at 12:26 PM, Anthony Towns \u003caj at erisian.com.au\u003e wrote:\n\u003e \n\u003e On Sat, Dec 22, 2018 at 02:54:42AM +0800, Johnson Lau wrote:\n\u003e\u003e The question I would like to ask is: is OP_CODESEPARATOR useful under taproot? Generally speaking, CODESEPARATOR is useful only with conditional opcodes (OP_IF etc), and conditional opcodes are mostly replaced by merklized scripts. I am not sure how much usability is left with CODESEPARATOR\n\u003e \n\u003e If you don't have conditionals, then I think committing to the (masked)\n\u003e script gives you everything you could do with codeseparator.\n\nI don’t think CODESEPARATOR is useful without conditionals. By useful I mean making a script more compact\n\n\u003e \n\u003e If you don't commit to the (masked) script, don't have conditionals,\n\u003e and don't have codeseparator, then I don't think you can make a signature\n\u003e distinguish which alternative script it's intending to sign; but you can\n\u003e just give each alternative script in the MAST a slight variation of the\n\u003e key and that seems good enough.\n\nYou can and should always use a different in different branch. If this best practice is always followed, committing to masked script is not necessary\n\n\u003e \n\u003e OTOH, I think for (roughly) the example you gave:\n\u003e \n\u003e DEPTH 3 EQUAL\n\u003e IF \u003cBob\u003e CHECKSIGVERIFY HASH160 \u003cH\u003e EQUALVERIFY CODESEP\n\u003e ELSE \u003cn\u003e CLTV DROP\n\u003e ENDIF\n\u003e \u003cAlice\u003e CHECKSIG\n\u003e \n\u003e then compared to the taproot equivalent:\n\u003e \n\u003e P = muSig(Alice,Bob)\n\u003e S1 = \u003cAlice1\u003e CHECKSIGVERIFY \u003cBob\u003e CHECKSIGVERIFY HASH160 \u003cH\u003e EQUAL\n\u003e S2 = \u003cAlice2\u003e CHECKSIGVERIFY \u003cn\u003e CLTV\n\u003e \n\u003e the IF+CODESEP approach is actually cheaper (lighter weight) if you're\n\u003e mostly (\u003e2/3rds of the time) taking the S1 branch. This is because the\n\u003e \"DEPTH 3 EQUAL IF/ELSE/ENDIF CODESEP \u003cn\u003e CLTV DROP\" overhead is less\n\u003e than the 32B overhead to choose a merkle branch).\n\u003e \n\u003e (That said, I'm not sure what Alice's signature in the S1 branch actually\n\u003e achieves in that script; and without that in S1, the taproot approach is\n\u003e cheaper all the time. Scriptless scripts would be cheaper still)\n\u003e \n\u003e\u003e If no one needs CODESEPARATOR, we might just disable it, and makes the validation code a bit simpler\n\u003e \n\u003e Since it only affects the behaviour of the checkdls (checksig) operators,\n\u003e even if it was disabled, it could be re-enabled fairly easily in a new\n\u003e script subversion if needed (ie, it could be re-added when upgrading\n\u003e witness version 1 from script version 0 to 1).\n\u003e \n\u003e Cheers,\n\u003e aj\n\u003e \n\nYes, I don’t think it needs Alice signature in S1 at all. So the original example doesn’t even need CODESEPARATOR at all. \n\nCould anyone propose a better use case of CODESEPARATOR?",
"sig": "a05b375e906b56e7ca50b59094d60e343cd20b51d6ba538e0683c1370ac2526eda1a8ed8260f2e8cf00cb40e7b160d69056db9ad3f0b0cdc5141122819e03d6a"
}