Skip to content
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

Withdrawal Transaction Creation should use both STX and BTC private keys from the Wallet #181

Open
jferrant opened this issue Jul 7, 2023 · 4 comments

Comments

@jferrant
Copy link

jferrant commented Jul 7, 2023

During alpha testing, it was discovered that assumptions were made about the private keys inside a Hiro wallet:

Kyran has explained our problem...
My question: "what the relationship between the BTC private key and the STX private key is for a Hiro wallet?"
Kyran's answer: "So the root key is the same, but the descendant keys are different
And addresses for both come from different decendent keys"

Explanation: This is why we were not having success with our withdrawal transaction. We had previously sent a deposit to the STX address listed in the Hiro Wallet. When we tried to withdraw, we used the BTC private key corresponding to the BTC address in the Hiro wallet (which was holding all the bitcoin) to try to withdraw funds. HOWEVER, the corresponding STX address for this BTC private key of course does not match the STX address listed in the Hiro wallet (that contained our previously deposited sBTC). hence the "Not enough funds".

Conclusion: We need to be able to sign the BTC transaction with the BTC private key and fill the tx data with a signature signed with the STX private key.

Definition of Done:

The bridge creates a signed withdrawal BTC transaction with the private key associated with user's Hiro Wallet BTC address. The signature stored WITHIN the Withdrawal transaction data should be generated by signing the amount with the private key associated with the user's Hiro Wallet STX address. They are NOT the same.

@markmhendrickson
Copy link

Resources for arbitrary message signing with Hiro Wallet, for Bitcoin and Stacks respectively:

https://docs.hiro.so/build-apps/message-signing
https://www.hiro.so/blog/how-arbitrary-message-signing-works-in-the-hiro-wallet
https://hirowallet.gitbook.io/developers/bitcoin/sign-messages

@radicleart
Copy link
Collaborator

Related to leather-io/extension#4223

@friedger
Copy link
Collaborator

Is this solved?

@radicleart
Copy link
Collaborator

@jferrant - as things stand, afaik, the payload is signed with the the stacks address private key. Are you saying this should be the cardinal/payment bitcoin private key ?

The PSBT is signed with the private key of the cardinal/payment bitcoin private key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants