Abstract witness-tx verification behind a WitnessTx trait#1
Open
bitwalt wants to merge 1 commit into
Open
Conversation
The DBC verification path is typed against bitcoin::Transaction in three places: dbc::Proof::verify, Anchor::verify, and the Witness<D> struct. That type cannot represent an Elements/Liquid transaction, which is the only thing preventing RGB anchors from being verified on Liquid. This change introduces a WitnessTx trait exposing exactly what the verification path needs from a transaction: its txid, its input outpoints, and its output script_pubkeys. dbc::Proof::verify and Anchor::verify become generic over W: WitnessTx. The concrete TapretProof / OpretProof impls iterate output_script_pubkeys() and dispatch to the existing ScriptBuf-level ConvolveCommitProof / EmbedCommitVerify paths, which were already chain-agnostic. bitcoin::Transaction implements WitnessTx directly, so existing callers are unaffected. Any Elements/Liquid transaction type can implement the same three methods. 207 lines across 8 files (1 new). The upstream test suite passes unchanged (45/45). rgb-ops, rgb-schemas, rgb-invoicing and rgb-aluvm compile against the patched crate with no source changes. Signed-off-by: KaleidoSwap <info.kaleidoswap@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status
Internal review PR, staged on the KaleidoSwap fork. Not submitted upstream.
This exists so the patch can be reviewed as a clean diff before any
conversation with the rgb-protocol maintainers. Base branch
release/0.11.1-rc.10is the pristine0.11.1-rc.10release; the diffhere is exactly the proposed change.
What this does
RGB's DBC verification path is typed against
bitcoin::Transactioninthree places (
dbc::Proof::verify,Anchor::verify, theWitness<D>struct). That type cannot represent an Elements/Liquid transaction,
which is the one thing preventing RGB anchors from being verified on
Liquid.
This introduces a
WitnessTxtrait exposing exactly what theverification path uses from a transaction:
dbc::Proof::verifyandAnchor::verifybecome generic overW: WitnessTx. The concreteTapretProof/OpretProofimpls iterateoutput_script_pubkeys()and dispatch to the existingScriptBuf-levelConvolveCommitProof/EmbedCommitVerifypaths, which were alreadychain-agnostic.
bitcoin::TransactionimplementsWitnessTxdirectly, so everyexisting caller compiles and behaves unchanged.
Diff
207 lines across 8 files (1 new):
src/dbc/witness_tx.rs(new)impl WitnessTx for bitcoin::Transactionsrc/dbc/mod.rssrc/dbc/proof.rsProof::verifygeneric overWitnessTxsrc/dbc/anchor.rsAnchor::verifygenericsrc/dbc/tapret/mod.rsProofimpl iterates output scriptssrc/dbc/opret/mod.rsProofimpl iterates output scriptssrc/seals/txout/witness.rsverify_sealdelegates to a sharedWitnessTx-generic helpersrc/validation/commitments.rsDbcProof::verifygenericTesting
cargo test --features randis 45/45.bitcoin::Transactioncallers.rgb-ops,rgb-schemas,rgb-invoicing, andrgb-aluvmcompile andrun against the patched crate with no source modification.
transfer, and a cross-chain Bitcoin/Liquid atomic swap) in a separate
proof-of-concept repository.
Open questions for a future upstream discussion
WitnessTxlive inrgb-consensusor a sibling crate?Witness<D>gain a generic tx parameter, or a generic sibling type?