> On 21 Dec 2018, at 7:17 AM, Rusty Russell <ru...@rustcorp.com.au> wrote:
> 
> Johnson Lau <jl2...@xbt.hk> writes:
> 
>>> But I don't see how OP_CODESEPARATOR changes anything here, wrt NOINPUT?
>>> Remember, anyone can create an output which can be spent by any NOINPUT,
>>> whether we go for OP_MASK or simply not commiting to the input script.
>>> 
>> 
>> Let me elaborate more. Currently, scriptCode is truncated at the last 
>> executed CODESEPARATOR. If we have a very big script with many 
>> CODESEPARATORs and CHECKSIGs, there will be a lot of hashing to do.
>> 
>> To fix this problem, it is proposed that the new sighash will always commit 
>> to the same H(script), instead of the truncated scriptCode. So we only need 
>> to do the H(script) once, even if the script is very big
> 
> Yes, I read this as proposed, it is clever.  Not sure we'd be
> introducing it if OP_CODESEPARATOR didn't already exist, but at least
> it's a simplfication.
> 
>> In the case of NOINPUT with MASKEDSCRIPT, it will commit to the 
>> H(masked_script) instead of H(script).
>> 
>> To make CODESEPARATOR works as before, the sighash will also commit to the 
>> position of the last executed CODESEPARATOR. So the semantics doesn’t 
>> change. For scripts without CODESEPARATOR, the committed value is a constant.
>> 
>> IF NOINPUT does not commit to H(masked_script), technically it could still 
>> commit to the position of the last executed CODESEPARATOR. But since the 
>> wallet is not aware of the actual content of the script, it has to guess the 
>> meaning of such committed positions, like “with the HD key path m/x/y/z, I 
>> assume the script template is blah blah blah because I never use this path 
>> for another script template, and the meaning of signing the 3rd 
>> CODESEPARATOR is blah blah blah”. It still works if the assumptions hold, 
>> but sounds quite unreliable to me.
> 
> My question is more fundamental.  If NOINPUT doesn't commit to the input
> at all, no script, no code separator, nothing.  I'm struggling to
> understand your original comment was "without signing the script or
> masked script, OP_CODESEPARATOR becomes unusable or insecure with
> NOINPUT."
> 
> I mean, non-useful, sure.  Its purpose is to alter signature behavior,
> and from the script POV there's no signature with this form of NOINPUT.
> But other than the already-established "I reused keys for multiple
> outputs" oops, I don't see any new dangers?
> 
> Thanks,
> Rusty.

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 no one needs CODESEPARATOR, we might just disable it, and makes the 
validation code a bit simpler

If CODESEPARATOR is useful, then we should find a way to make it works with 
NOINPUT. With H(masked_script) committed, the meaning of the CODESEPARATOR 
position is very clear. Without H(masked_script), the meaning of the position 
totally relies on the assumption that “this public key is only used in this 
script template”.

Ignore CODESEPARATOR and more generally, I agree with you that script masking 
does not help in the case of address (scriptPubKey) reuse, which is the 
commonest type of reuse. However, it prevents replayability when the same 
public key is reused in different scripts
_______________________________________________
bitcoin-dev mailing list
bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev

Reply via email to