It seems odd at first that the coop_close message (sent by the swap taker) contains a private key.
This should be safe because the swap taker must create a random private key for each swap (not derived from an HD wallet). This simplifies the protocol because the swap maker can create the claim_by_coop transaction immediately without further communication with the swap taker.
An alternative approach would be for the swap taker to send a signature signed with SIGHASH_NONE | ANYONECANPAY. With this approach, the swap taker would not have to create a random private key for each swap, but could safely use an xpub scheme to derive their key. This could simplify backups because they do not need to synchronously backup a random private key for each swap; a derived key can be restored by iterating a predefined xpub branch. On the other hand, if the taker loses the <preimage> or <redeem_script> of a swap, it won't matter if they can recover their private key. The taker must always back up some information for each swap.
It seems odd at first that the
coop_closemessage (sent by the swap taker) contains a private key.This should be safe because the swap taker must create a random private key for each swap (not derived from an HD wallet). This simplifies the protocol because the swap maker can create the
claim_by_cooptransaction immediately without further communication with the swap taker.An alternative approach would be for the swap taker to send a signature signed with
SIGHASH_NONE | ANYONECANPAY. With this approach, the swap taker would not have to create a random private key for each swap, but could safely use an xpub scheme to derive their key. This could simplify backups because they do not need to synchronously backup a random private key for each swap; a derived key can be restored by iterating a predefined xpub branch. On the other hand, if the taker loses the<preimage>or<redeem_script>of a swap, it won't matter if they can recover their private key. The taker must always back up some information for each swap.