[Lightning-dev] We don't need R-Value, how OP_CODESEPARATOR saves the day

Nicolas Dorier nicolas.dorier at gmail.com
Mon Mar 7 02:34:09 UTC 2016


I'm amazed as I found a useful case for OP_CODESEPARATOR.
I think the script can be improved to take less byte for removing the
duplication of <KeyA>, will take a look later.
Let's change escape redeem:

OP_HASH160 <RHashA> OP_EQUAL
OP_IF
<KeyB>
OP_ELSE
<Delay> OP_CSV OP_DROP
<KeyA>
OP_ENDIF
OP_CHECKSIG

To

<KeyA> OP_CHECKSIG
OP_IF
<KeyB>
OP_ELSE
<Delay> OP_CSV OP_DROP
OP_CODESEPARATOR <KeyA>
OP_ENDIF
OP_CHECKSIG

The Escape output would be

<SIG-B> <SIGA-Revocation> {<ESCAPE-REDEEM>}

Where SIGA-Revocation is the signature of KeyA computed with the
ScriptCode=<ESCAPE-REDEEM>

The second escape would be

<SIG-A> 0 {<ESCAPE-REDEEMSCRIPT>}

where <SIG-A> script equals to

<KeyA>
OP_ENDIF
OP_CHECKSIG

You would revoke a commitment by revealing <SIGA-Revocation>

Btw, you can play with http://n.bitcoin.ninja/checkscript to test such
script (I'm checking it myself)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20160307/20fd0605/attachment.html>


More information about the Lightning-dev mailing list