[Design]: Deposit into sBTC directly from Bitcoin #1168
Labels
deposit
The deposit sBTC operation.
design
making a design decision.
sbtc signer binary
The sBTC Bootstrap Signer.
Milestone
Design - Deposit into sBTC directly from Bitcoin
This ticket holds the design of depositing into sBTC directly from the bitcoin layer, with no need for the user to use Emily or a bridge.
1. Summary
Include the necessary peg-in data in an
OP_RETURN
output. Signers will then be able to identify and process transactions if theOP_RETURN
and deposit outputs are formatted correctly.2. Context & Purpose
The proposed design is to have deposit transactions that have enough data on chain to make deposit UTXOs discoverable without the need for the transaction to be revealed to an external API like Emily. This will make it easier for others to build their own bridges, or forgo using a bridge entirely if they desire.
Pegging in directly from Bitcoin L1 places the burden on wallets
Relevant Research Discussions
Other bridges support direct from the L1 peg-ins, link to them from #153.
External Resources
OP_RETURN
style deposit flow to commit-reveal style deposit flow.3. Design
3.1 Proposed Component Design
The design is to have an
OP_RETURN
that is discoverable, and contains enough data for the signers to spend the deposit UTXO, committing the full deposit data on chain.Process Overview:
OP_RETURN
output containing data correlating with their deposit UTXO specifics.OP_RETURN
outputs matching the HASH160 of a signer’s aggregate key. Valid transactions are considered for sweep operations.Note that the signers already scan all outputs in all transactions in every block that they process, so matching on an
OP_RETURN
output is not much additional effort.The proposed layout for the
OP_RETURN
output is this:Meaning:
version
(1 byte) is just a version byte for the layout.signer pubkey hash
(20 bytes) is the HASH160 of one of the signers’ x-only aggregate key.vout
(1 byte) is the output index of the deposit UTXO.max fee
(1 byte) determines the max fee by taking the byte, interpreting it as an unsigned integer between 1 and 256, and multiplying it by 1000.locktime
(1 byte) determines theOP_CSV
locktime, interpreting the byte as an unsigned integer between 6 and 262.reclaim pubkey hash
(20 bytes) is the HASH160 of the x-only public key locking the reclaim script.recipient
(21 bytes) is the recipient address. It is always a standard address.The above information maps to proper deposit and reclaim scripts while allowing for future updates. Reclaim scripts are assumed to be of the form
vout
,max fee
, andlocktime
by standardizing their values.3.1.1 Deposit scripts
Each sBTC deposit script have the following form
The
<x-only-public-key>
is the signers’ aggregate key. It’s HASH160 maps to thesigner pubkey hash
from above. The<deposit-data>
is expected to have the format<max-fee><recipient-address>
, where the recipient address follows the format for a principal from SIP-005. The expected wire format for<deposit-data>
is:The max fee is an unsigned integer written in big endian format. The type prefix will be fixed to 5, since the Stacks address is always the standard variant, while the version and hash160 map to the recipient above.
3.1.2 Wallets
The tough part with supporting direct from L1 to sBTC is wallet support. But we could influence the state of things by adding support for them into the Leather wallet.
I believe the Leather wallet doesn’t necessarily use the same derivation path for Stacks and Bitcoin keypairs. If so, this means that Leather may not associate public keys underlying their bitcoin address with a Stacks address, even though they could control the associated Stacks address with the bitcoin keypair.
3.2 Design Diagram
TODO
3.3 Considerations & Alternatives
TODO
3.4 Areas of Ambiguity
For wallets where the derivation path of bitcoin and stacks addresses are the same, we could simplify the
OP_RETURN
data to something likeThe assumption is that the stacks address is formed from the same pubkey hash noted in bytes 21-41, so we do not need to note the recipient.
Wallets
TODO
Closing Checklist
The text was updated successfully, but these errors were encountered: