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

v0.11 fixes #111

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions seals/src/lib.rs
Original file line number Diff line number Diff line change
@@ -48,8 +48,3 @@ pub mod txout;
mod secret;

pub use secret::SecretSeal;

/// Method for closing BP single-use-seals.
pub trait SealCloseMethod: dbc::DbcMethod {}

impl SealCloseMethod for dbc::Method {}
261 changes: 98 additions & 163 deletions seals/src/txout/blind.rs

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions seals/src/txout/error.rs
Original file line number Diff line number Diff line change
@@ -32,9 +32,6 @@ use bc::Outpoint;
serde(crate = "serde_crate", rename_all = "camelCase")
)]
pub enum VerifyError<E: Error> {
/// seals provided for a batch verification have inconsistent close method.
InconsistentCloseMethod,

/// the provided witness transaction does not closes seal {0}.
WitnessNotClosingSeal(Outpoint),

67 changes: 21 additions & 46 deletions seals/src/txout/explicit.rs
Original file line number Diff line number Diff line change
@@ -26,11 +26,9 @@

use amplify::hex;
use bc::{Outpoint, Txid, Vout};
use dbc::MethodParseError;

use crate::txout::seal::{SealTxid, TxPtr};
use crate::txout::{CloseMethod, TxoSeal, WitnessVoutError};
use crate::SealCloseMethod;
use crate::txout::{TxoSeal, WitnessVoutError};

/// Revealed seal definition which may point to a witness transactions and does
/// not contain blinding data.
@@ -42,11 +40,7 @@
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = dbc::LIB_NAME_BPCORE)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "serde_crate"))]
pub struct ExplicitSeal<Id: SealTxid, M: SealCloseMethod = CloseMethod> {
/// Commitment to the specific seal close method [`CloseMethod`] which must
/// be used to close this seal.
pub method: M,

pub struct ExplicitSeal<Id: SealTxid> {
/// Txid of the seal definition.
///
/// It may be missed in situations when ID of a transaction is not known,
@@ -59,36 +53,33 @@
pub vout: Vout,
}

impl<M: SealCloseMethod> TryFrom<&ExplicitSeal<TxPtr, M>> for Outpoint {
impl TryFrom<&ExplicitSeal<TxPtr>> for Outpoint {
type Error = WitnessVoutError;

#[inline]
fn try_from(reveal: &ExplicitSeal<TxPtr, M>) -> Result<Self, Self::Error> {
fn try_from(reveal: &ExplicitSeal<TxPtr>) -> Result<Self, Self::Error> {

Check warning on line 60 in seals/src/txout/explicit.rs

Codecov / codecov/patch

seals/src/txout/explicit.rs#L60

Added line #L60 was not covered by tests
reveal.txid.map_to_outpoint(reveal.vout).ok_or(WitnessVoutError)
}
}

impl<M: SealCloseMethod> TryFrom<ExplicitSeal<TxPtr, M>> for Outpoint {
impl TryFrom<ExplicitSeal<TxPtr>> for Outpoint {
type Error = WitnessVoutError;

#[inline]
fn try_from(reveal: ExplicitSeal<TxPtr, M>) -> Result<Self, Self::Error> {
fn try_from(reveal: ExplicitSeal<TxPtr>) -> Result<Self, Self::Error> {

Check warning on line 69 in seals/src/txout/explicit.rs

Codecov / codecov/patch

seals/src/txout/explicit.rs#L69

Added line #L69 was not covered by tests
Outpoint::try_from(&reveal)
}
}

impl<M: SealCloseMethod> From<&ExplicitSeal<Txid, M>> for Outpoint {
fn from(seal: &ExplicitSeal<Txid, M>) -> Self { Outpoint::new(seal.txid, seal.vout) }
impl From<&ExplicitSeal<Txid>> for Outpoint {
fn from(seal: &ExplicitSeal<Txid>) -> Self { Outpoint::new(seal.txid, seal.vout) }

Check warning on line 75 in seals/src/txout/explicit.rs

Codecov / codecov/patch

seals/src/txout/explicit.rs#L75

Added line #L75 was not covered by tests
}

impl<M: SealCloseMethod> From<ExplicitSeal<Txid, M>> for Outpoint {
fn from(seal: ExplicitSeal<Txid, M>) -> Self { Outpoint::from(&seal) }
impl From<ExplicitSeal<Txid>> for Outpoint {
fn from(seal: ExplicitSeal<Txid>) -> Self { Outpoint::from(&seal) }

Check warning on line 79 in seals/src/txout/explicit.rs

Codecov / codecov/patch

seals/src/txout/explicit.rs#L79

Added line #L79 was not covered by tests
}

impl<Id: SealTxid, M: SealCloseMethod> TxoSeal<M> for ExplicitSeal<Id, M> {
#[inline]
fn method(&self) -> M { self.method }

impl<Id: SealTxid> TxoSeal for ExplicitSeal<Id> {
#[inline]
fn txid(&self) -> Option<Txid> { self.txid.txid() }

@@ -107,29 +98,27 @@
}
}

impl<Id: SealTxid, M: SealCloseMethod> ExplicitSeal<Id, M> {
impl<Id: SealTxid> ExplicitSeal<Id> {
/// Constructs seal for the provided outpoint and seal closing method.
#[inline]
pub fn new(method: M, outpoint: Outpoint) -> ExplicitSeal<Id, M> {
pub fn new(outpoint: Outpoint) -> ExplicitSeal<Id> {

Check warning on line 104 in seals/src/txout/explicit.rs

Codecov / codecov/patch

seals/src/txout/explicit.rs#L104

Added line #L104 was not covered by tests
Self {
method,
txid: Id::from(outpoint.txid),
vout: outpoint.vout,
}
}

/// Constructs seal.
#[inline]
pub fn with(method: M, txid: Id, vout: impl Into<Vout>) -> ExplicitSeal<Id, M> {
pub fn with(txid: Id, vout: impl Into<Vout>) -> ExplicitSeal<Id> {

Check warning on line 113 in seals/src/txout/explicit.rs

Codecov / codecov/patch

seals/src/txout/explicit.rs#L113

Added line #L113 was not covered by tests
ExplicitSeal {
method,
txid,
vout: vout.into(),
}
}
}

impl<M: SealCloseMethod> ExplicitSeal<Txid, M> {
impl ExplicitSeal<Txid> {
/// Converts seal into a transaction outpoint.
#[inline]
pub fn to_outpoint(&self) -> Outpoint { Outpoint::new(self.txid, self.vout) }
@@ -140,17 +129,9 @@
#[derive(Clone, PartialEq, Eq, Debug, Display, Error, From)]
#[display(doc_comments)]
pub enum ParseError {
/// single-use-seal must start with method name (e.g. 'tapret1st' etc)
MethodRequired,

/// full transaction id is required for the seal specification
TxidRequired,

/// wrong seal close method id
#[display(inner)]
#[from]
WrongMethod(MethodParseError),

/// unable to parse transaction id value; it must be 64-character
/// hexadecimal string, however {0}
WrongTxid(hex::Error),
@@ -163,18 +144,14 @@
WrongStructure,
}

impl<Id: SealTxid, M: SealCloseMethod> FromStr for ExplicitSeal<Id, M>
where M: FromStr<Err = MethodParseError>
{
impl<Id: SealTxid> FromStr for ExplicitSeal<Id> {
type Err = ParseError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut split = s.split(&[':', '#'][..]);
match (split.next(), split.next(), split.next(), split.next()) {
(Some("~"), ..) | (Some(""), ..) => Err(ParseError::MethodRequired),
(Some(_), Some(""), ..) => Err(ParseError::TxidRequired),
(Some(method), Some(txid), Some(vout), None) => Ok(ExplicitSeal {
method: method.parse()?,
match (split.next(), split.next(), split.next()) {
(Some(""), ..) => Err(ParseError::TxidRequired),
(Some(txid), Some(vout), None) => Ok(ExplicitSeal {

Check warning on line 154 in seals/src/txout/explicit.rs

Codecov / codecov/patch

seals/src/txout/explicit.rs#L152-L154

Added lines #L152 - L154 were not covered by tests
txid: Id::from_str(txid).map_err(ParseError::WrongTxid)?,
vout: vout.parse().map_err(|_| ParseError::WrongVout)?,
}),
@@ -183,10 +160,8 @@
}
}

impl<Id: SealTxid, M: SealCloseMethod> Display for ExplicitSeal<Id, M>
where M: Display
{
impl<Id: SealTxid> Display for ExplicitSeal<Id> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}:{}:{}", self.method, self.txid, self.vout,)
write!(f, "{}:{}", self.txid, self.vout,)

Check warning on line 165 in seals/src/txout/explicit.rs

Codecov / codecov/patch

seals/src/txout/explicit.rs#L165

Added line #L165 was not covered by tests
}
}
7 changes: 1 addition & 6 deletions seals/src/txout/seal.rs
Original file line number Diff line number Diff line change
@@ -27,16 +27,11 @@ use amplify::hex;
use bc::{Outpoint, Txid, Vout};
use strict_encoding::{StrictDecode, StrictDumb, StrictEncode};

use crate::SealCloseMethod;

/// Method for closing single-use-seals.
pub type CloseMethod = dbc::Method;

/// Methods common for all transaction-output based seal types.
pub trait TxoSeal<M: SealCloseMethod = CloseMethod> {
/// Returns method which must be used for seal closing.
fn method(&self) -> M;

pub trait TxoSeal {
/// Returns [`Txid`] part of the seal definition, if known.
fn txid(&self) -> Option<Txid>;

28 changes: 7 additions & 21 deletions seals/src/txout/witness.rs
Original file line number Diff line number Diff line change
@@ -23,16 +23,14 @@

use bc::{Tx, Txid};
use commit_verify::mpc;
use dbc::{DbcMethod, Method};
use single_use_seals::SealWitness;

use crate::txout::{TxoSeal, VerifyError};
use crate::SealCloseMethod;

/// Witness of a bitcoin-based seal being closed. Includes both transaction and
/// extra-transaction data.
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct Witness<D: dbc::Proof<M>, M: DbcMethod = Method> {
pub struct Witness<D: dbc::Proof> {
/// Witness transaction: transaction which contains commitment to the
/// message over which the seal is closed.
pub tx: Tx,
@@ -44,13 +42,13 @@
pub proof: D,

#[doc(hidden)]
pub _phantom: PhantomData<M>,
pub _phantom: PhantomData<D>,
}

impl<D: dbc::Proof<M>, M: DbcMethod> Witness<D, M> {
impl<D: dbc::Proof> Witness<D> {
/// Constructs witness from a witness transaction and extra-transaction
/// proof, taken from an anchor.
pub fn with(tx: Tx, dbc: D) -> Witness<D, M> {
pub fn with(tx: Tx, dbc: D) -> Witness<D> {

Check warning on line 51 in seals/src/txout/witness.rs

Codecov / codecov/patch

seals/src/txout/witness.rs#L51

Added line #L51 was not covered by tests
Witness {
txid: tx.txid(),
tx,
@@ -60,9 +58,7 @@
}
}

impl<Seal: TxoSeal<M>, Dbc: dbc::Proof<M>, M: SealCloseMethod> SealWitness<Seal>
for Witness<Dbc, M>
{
impl<Seal: TxoSeal, Dbc: dbc::Proof> SealWitness<Seal> for Witness<Dbc> {
type Message = mpc::Commitment;
type Error = VerifyError<Dbc::Error>;

@@ -85,25 +81,15 @@
where
Seal: 'seal,
{
let mut method = None;
for seal in seals {
// 1. All seals must have the same closing method
if let Some(method) = method {
if method != seal.method() {
return Err(VerifyError::InconsistentCloseMethod);
}
} else {
method = Some(seal.method());
}

// 2. Each seal must match tx inputs
// 1. Each seal must match tx inputs
let outpoint = seal.outpoint().ok_or(VerifyError::NoWitnessTxid)?;
if !self.tx.inputs.iter().any(|txin| txin.prev_output == outpoint) {
return Err(VerifyError::WitnessNotClosingSeal(outpoint));
}
}

// 3. Verify DBC with the giving closing method
// 2. Verify DBC with the giving closing method
self.proof.verify(msg, &self.tx).map_err(VerifyError::Dbc)
}
}
6 changes: 3 additions & 3 deletions src/bin/bpcore-stl.rs
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
use bp::stl::bp_core_stl;
use commit_verify::stl::commit_verify_stl;
use commit_verify::CommitmentLayout;
use seals::txout::{ChainBlindSeal, CloseMethod, SingleBlindSeal};
use seals::txout::{ChainBlindSeal, SingleBlindSeal};
use strict_encoding::libname;
use strict_types::stl::std_stl;
use strict_types::{parse_args, SystemBuilder};
@@ -113,9 +113,9 @@
"
)
.unwrap();
let layout = SingleBlindSeal::<CloseMethod>::commitment_layout();
let layout = SingleBlindSeal::commitment_layout();

Check warning on line 116 in src/bin/bpcore-stl.rs

Codecov / codecov/patch

src/bin/bpcore-stl.rs#L116

Added line #L116 was not covered by tests
writeln!(file, "{layout}").unwrap();
let layout = ChainBlindSeal::<CloseMethod>::commitment_layout();
let layout = ChainBlindSeal::commitment_layout();

Check warning on line 118 in src/bin/bpcore-stl.rs

Codecov / codecov/patch

src/bin/bpcore-stl.rs#L118

Added line #L118 was not covered by tests
writeln!(file, "{layout}").unwrap();
let tt = sys.type_tree("BPCore.BlindSealTxid").unwrap();
writeln!(file, "{tt}").unwrap();
114 changes: 0 additions & 114 deletions src/bp.rs

This file was deleted.

6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -50,20 +50,16 @@ pub extern crate seals;
#[cfg(feature = "stl")]
#[macro_use]
extern crate amplify;
#[cfg(feature = "stl")]
#[macro_use]
extern crate strict_encoding;
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde_crate as serde;

#[cfg(feature = "stl")]
pub mod stl;
mod bp;

pub use ::bc::*;
#[cfg(feature = "stl")]
#[allow(missing_docs)]
pub mod bc {
pub use bc::stl;
}
pub use bp::Bp;
12 changes: 6 additions & 6 deletions src/stl.rs
Original file line number Diff line number Diff line change
@@ -25,14 +25,14 @@ use bc::Txid;
use commit_verify::mpc;
use dbc::opret::OpretProof;
use dbc::tapret::TapretProof;
use dbc::{Method, LIB_NAME_BPCORE};
use dbc::LIB_NAME_BPCORE;
use seals::txout::TxPtr;
use strict_types::{CompileError, LibBuilder, TypeLib};

/// Strict types id for the library providing data types from [`dbc`] and
/// [`seals`] crates.
pub const LIB_ID_BPCORE: &str =
"stl:VhPW19SH-c5lzr1y-TLIsx8z-Z5nB!$Q-IgwrAQA-OqXLwUg#austin-story-retro";
"stl:IXCrofWg-Kg2!RIk-Hzlc5GO-7tH2hNB-YeBTdmN-$HZ0tPw#symbol-tropic-grand";

fn _bp_core_stl() -> Result<TypeLib, CompileError> {
LibBuilder::new(libname!(LIB_NAME_BPCORE), tiny_bset! {
@@ -46,11 +46,11 @@ fn _bp_core_stl() -> Result<TypeLib, CompileError> {
.transpile::<dbc::Anchor<mpc::MerkleTree, OpretProof>>()
.transpile::<dbc::Anchor<mpc::MerkleBlock, OpretProof>>()
.transpile::<dbc::Anchor<mpc::MerkleProof, OpretProof>>()
.transpile::<seals::txout::ExplicitSeal<TxPtr, Method>>()
.transpile::<seals::txout::ExplicitSeal<Txid, Method>>()
.transpile::<seals::txout::ExplicitSeal<TxPtr>>()
.transpile::<seals::txout::ExplicitSeal<Txid>>()
.transpile::<seals::SecretSeal>()
.transpile::<seals::txout::BlindSeal<TxPtr, Method>>()
.transpile::<seals::txout::BlindSeal<Txid, Method>>()
.transpile::<seals::txout::BlindSeal<TxPtr>>()
.transpile::<seals::txout::BlindSeal<Txid>>()
.compile()
}

53 changes: 25 additions & 28 deletions stl/BPCore@0.1.0.sta
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-----BEGIN STRICT TYPE LIB-----
Id: stl:VhPW19SH-c5lzr1y-TLIsx8z-Z5nB!$Q-IgwrAQA-OqXLwUg#austin-story-retro
Id: stl:IXCrofWg-Kg2!RIk-Hzlc5GO-7tH2hNB-YeBTdmN-$HZ0tPw#symbol-tropic-grand
Name: BPCore
Dependencies:
CommitVerify#miller-pancake-elastic,
Std#ralph-blue-lucky,
Bitcoin#signal-color-cipher
Check-SHA256: ffe8ef061b2a6733287e1874f8781a637640f3c99f05eb07d25c3a0aa5ed269e
Check-SHA256: 966bc6fd6b923e8a537bad15c2ff36d2a461864324d254bfd7277317801cadd9

20~CnZ*pY=dIKHbX?@G`sCP;~6&DQwR5(-fxrUo0Th<KzD#g<#3`1{iZE18?WpZg|dCDvvZ-bfLFbqC#
o>4E?M+l67UG^w8*<_XZ#%uyqCj(P-Wc6$lVk7oBr%DNv+($;q`HHK!gIHa)*%m(-e#9sm3I{@IbYpL6
@@ -19,7 +19,7 @@ HS#3Ua|L6d7%qre2Ut&TY<W;?3`1{iZE18?WpZg|c?SRpR`-7%<v!(6CSPt8P+`uam~C7&J!(5--hXnL
h1^p2tAX-yWl;qtQ<OqiuZa`rd(@k;(+5pub8}&5WjLNgh9?yTI7S;;e;>sZfv!yd427@;7veO2zMB=|
GYU;*a%*g5NMUnmT+QYFd;Umr-dgNEFCuu*?Wk)@WS(Jw`th(K{eY_63r%HmYiwmgY;R+0h0#5^R?l+2
>x*OcO&#*^E;5@PQ20HKbE5LJk_Il(3r%HmYiwmua&K>D*tNNq^HspzKK^|l-Ci`?%`u0U6ZHVlY`S(f
i`CFq2vl-qWlnEoWdl=mWB~wXSa8^mT+s=T=}Z?`J=~w8Q=GLzSfImTncuED0}GM@RW%X-8$oVkXm4^&
i`CFq2vl-qWlnEoWdl=mWB~wXSa8^mT+s=T=}Z?`J=~w8Q=GLzSfImTnc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pF1bWU$%Wk_LjXae<Y6JjIwIj2eqliWu}$@z+_xPw?-wb>Rw7=FYk8VWJHuIPk`cg3&=F>*1@lJ+pR
DJ{*3f84s>#k$1lf7u08cu;h51OfmFcWHEPWpi^>cmMzZ0R(h-X=DHe0Rr`G6JjIwIj2eqliWu}$@z+_
xPw?-wb>Rw7=FYk8VaL=Li5Yl(a@n1+Ku60FILp}Zw|!7cE!MGSxid=WmW

-----END STRICT TYPE LIB-----

Binary file modified stl/BPCore@0.1.0.stl
Binary file not shown.
28 changes: 9 additions & 19 deletions stl/BPCore@0.1.0.sty
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-
Id: stl:VhPW19SH-c5lzr1y-TLIsx8z-Z5nB!$Q-IgwrAQA-OqXLwUg#austin-story-retro
Id: stl:IXCrofWg-Kg2!RIk-Hzlc5GO-7tH2hNB-YeBTdmN-$HZ0tPw#symbol-tropic-grand
Name: BPCore
Version: 0.1.0
Description: Bitcoin client-side-validation library
@@ -52,31 +52,21 @@ data AnchorMerkleTreeOpretProof : mpcProof CommitVerify.MerkleTree, dbcProof Opr
@mnemonic(europe-mister-imitate)
data AnchorMerkleTreeTapretProof : mpcProof CommitVerify.MerkleTree, dbcProof TapretProof
@mnemonic(report-process-stuart)
data BlindSealTxPtr : method Method
, txid TxPtr
@mnemonic(metro-mars-canada)
data BlindSealTxPtr : txid TxPtr
, vout Bitcoin.Vout
, blinding U64
@mnemonic(baby-region-proxy)
data BlindSealTxid : method Method
, txid Bitcoin.Txid
@mnemonic(halt-crash-valid)
data BlindSealTxid : txid Bitcoin.Txid
, vout Bitcoin.Vout
, blinding U64
@mnemonic(meaning-extra-sherman)
data ExplicitSealTxPtr : method Method
, txid TxPtr
, vout Bitcoin.Vout
@mnemonic(june-total-denver)
data ExplicitSealTxid : method Method
, txid Bitcoin.Txid
, vout Bitcoin.Vout
@mnemonic(bali-boris-plasma)
data Method : opretFirst | tapretFirst
@mnemonic(velvet-neptune-bazooka)
data ExplicitSealTxPtr : txid TxPtr, vout Bitcoin.Vout
@mnemonic(chicago-europe-phantom)
data ExplicitSealTxid : txid Bitcoin.Txid, vout Bitcoin.Vout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type becomes strictly equal to Outpoint. I do not think we need it anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do need it because ExplicitSeal can be ExplicitSeal<Txid> or ExplicitSeal<TxPtr>. Or do you think we could drop the generic from ExplicitSeal?

Copy link
Member

@dr-orlovsky dr-orlovsky Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop generic form and just implement the trait we need (something like TxoSeal... there were some traits for explicit seals) and have ExplicitSeal<TxPtr> renamed into GraphSeal (which is a type alias to it anyway, so we do not need both) - and ExplicitSeal<Txid> (with its alias GenesisSeal) removed, and Outpoint uses instead of them.

We can make things even more simple: in v0.12 I got rid of TxPtr taking convention that Txid of zeros means witness output-based seal. This reduces a lot of code here, at no risk cost (from my experience, each time you have an enum in core, add 1000 lines at least where you deal with it's matches....)

So, if you follow v0.12 approach, you will end up with having just Outpoint as a seal definition - and that's it.

(To be fully frank, in v0.12 we do have just one seal type, TxoSeal, but not Outpoint, since there we support failback seal definition. Not sure we need that in v0.11, which is temporary anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here I can say the same I said in RGB-WG/rgb-core#285 (comment): since this is just refactor I'll do this in another set of PRs after these ones are ACKed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am taking my suggestion back: single type of seals doesn't work and I had to differentiate two seal types it in v0.12: #112

@mnemonic(good-village-flex)
data OpretProof : ()
2 changes: 0 additions & 2 deletions stl/Seals.vesper
Original file line number Diff line number Diff line change
@@ -14,13 +14,11 @@ SecretSeal commitment hasher=SHA256 tagged=urn:lnp-bp:seals:secret#2024-02-03
BlindSealTxPtr serialized

BlindSealTxid rec
method enum Method opretFirst=0 tapretFirst=1
txid bytes len=32 aka=Txid
vout is U32 aka=Vout
blinding is U64

BlindSealTxPtr rec
method enum Method opretFirst=0 tapretFirst=1
txid union TxPtr
witnessTx is Unit tag=0
txid bytes len=32 wrapped aka=Txid tag=1