-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposed Taproot implementation of onchain HTLC #12
Comments
Now that I think about it a little more, we could use ECDSA still with this "private key handover" technique, as the signing algo is strictly single-sig like in most ECDSA implementations extant. This would let us use just a single signature after private key handover even without using Schnorr sigs, instead of 2 signatures. But without Taproot we would need to publish MuSig( But Taproot > ECDSA anyway so ... |
Note however that private key handover is incompatible with #7, as private key handover assumes that the entire UTXO is owned by one or the other, but #7 wants the option of splitting the HTLC-bearing UTXO. In a "true Taproot" implementation you would need a MuSig2 implementation for that, you could also just use classic |
As requested by @nepet here: #4 (comment)
Here is a concrete implementation of the onchain HTLC using Taproot. IMPORTANT: This proposal does NOT require a MuSig2 signing ritual implementation; it only requires an implementation of the MuSig public key aggregation scheme. This has the advantage that the peerswap impl state machine requires practically no change, as there are no extra messages needed to implement the two-round MuSig2 signing ritual. In particular, this should neatly sidestep potential issues with protocol design that could render MuSig2 signing insecure such as this or this.
S
, an ephemeral pubkey generated by the node that instantiates the HTLC and should have control of the timelock branch to recover funds in case of timeout.s
first, then computeS = s * G
.s
should be safe for the node to reveal without compromising its other keypairs, thus recommended to be an ephemeral privkey. In case derivation from a root privkey is needed, it could be derived using a hardened derivation at the final path element in an HD.R
, an ephemeral pubkey generated by the node that accepts the HTLC and should have control of the hashlock branch.r
should be safe for the node to reveal without compromising its other keypairs.H
, the SHA256 hash of the preimageP
.T
, the relative timeout agreed upon.S
,R
).OP_HASH160 <ripemd160(H)> OP_EQUALVERIFY <R> OP_CHECKSIG
- the hashlock branch controlled byR
.<T> OP_CHECKSEQUENCEVERIFY OP_DROP <S> OP_CHECKSIG
- the timelock branch controlled byS
.We also add a new message
coop_success
which the sender of the onchain HTLC sends to contains
. This message SHOULD be sent any time after the sender of the onchain HTLC claims the corresponding in-Lightning HTLC, i.e. after it sendsupdate_fulfill_htlc
for the corresponding in-Lightning HTLC.In all cases, there is no need for a MuSig2 or MuSig signing ritual in order to utilize the keypath spend path. It is enough to send the
r
privkey withcoop_close
in case of an abort (which a receiver MUST NOT send after it has offerred the corresponding in-channel HTLC and it has not beenupdate_fail_htlc
ed), or thes
privkey withcoop_success
in case of protocol completion. Once one node is in possession of both privkeys, it can derive the privkey corresponding to MuSig(S
,R
), and use a standard single-signing Schnorr algorithm using its own compute resources.We expect single-signing Schnorr algorithms to be simpler to implement, test, and prove secure, so we expect that we can deploy this earlier compared to relying on MuSig2 signing algorithms (and also removing protocol-related bugs when doing MuSig2 signing).
Both
coop_close
andcoop_success
would benefit from an ACK as in #6. In case of a disconnection of the TCP tunnel between the nodes, if noack
has been received, the sender ofcoop_close
/coop_success
SHOULD re-send the message on reestablishment of connection. This is not absolutely necessary for security since the hashlock and timelock branches remain valid even if delivery of ther
ors
privkey fails, but are important for convenience and to avoid having to reveal Tapscript branches, which degrade privacy.This technique of "private key handover" is generally only utilizable by onchain swap / HTLC protocols, where possession of the entire UTXO is taken by one or the other participant in a 2-participant protocol. The technique does not easily generalize to other protocols and is potentially insecure outside of swap protocols. As peerswap is a swap protocol it is safe to use "private key handover", and simplifies implementation and state machines involved.
Corresponding cases for aborting via the timelock branch, or force-claiming via the hashlock branch, use the obvious approach and will not be described in further detail.
The text was updated successfully, but these errors were encountered: