leather-io / extension

Leather browser extension
https://leather.io
MIT License
305 stars 144 forks source link

Support Signing Stacks transactions with Bitcoin keys #5889

Open Rapha-btc opened 1 month ago

Rapha-btc commented 1 month ago

We would like our users to sign Stacks transactions using their Bitcoin keys. Can Leather support this? The Stacks transactions using Bitcoin keys will be sponsored, so we don't need to worry about Stacks gas assets on the Bitcoin address.

Extract from conversation with Friedger: "When a user reserves a swap on Stacks, they can submit an inputthat must be used in the BTC transaction" [that unlocks the swap STX collateral] "Then the contract can verify whether the submitted BTC transaction has the required input. If the first input is the same as the signer of the submitted signature, then the BTC transaction is accepted for the swap."

Our catamaran swap protocol at a high level would perform this (unless my understanding is slightly incorrect): For "take-offer" on Stacks: We use a Bitcoin key to link the STX receiving address with the Bitcoin sending address. For unlocking STX collateral: The Bitcoin sender address is derived from the Bitcoin transaction hash, which is then connected to the STX receiver address.

More context: https://docs.jing.cash/ Image

markmhendrickson commented 1 month ago

@kyranjamie curious about your initial thoughts on this concept given your recent work on signing? Also cc @friedger

kyranjamie commented 1 month ago

Our implementation doesn't support this currently, but it's certainly possible.

I'd advise against this design, though. It will not work with hardware wallets, many of which will only sign Bitcoin transactions with approved derivation paths, Stacks' m/44'/5757' would not be supported (on Ledgers at least).

Rapha-btc commented 1 month ago

Kyran, thank you for your input. If I'm understanding correctly, you're saying it's technically impossible to sign a Stacks transaction using Bitcoin keys from Ledger. Please correct me if I've misinterpreted this.

That said, I'm always focused on meeting user needs. I believe that as technology evolves, we can find ways to expand capabilities to better serve our community.

There's a legitimate reason for Stacks and Bitcoin addresses not sharing the same derivation path, from both a technical and user experience perspective. However, allowing this binding connection for some use cases is, in my opinion, going to be crucial for various products that need optional physical Bitcoin settlement.

friedger commented 1 month ago

I'd advise against this design, though. It will not work with hardware wallets, many of which will only sign Bitcoin transactions with approved derivation paths, Stacks' m/44'/5757' would not be supported (on Ledgers at least).

I understand the issue differently:

Leather and Ledger should use the approved Bitcoin derivation path to sign a (sponsored) Stacks transaction.

Is this a duplicate of https://github.com/leather-io/extension/issues/4090