From e6423564ff792fc26d343377213b3f409c76e1ab Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 18 Feb 2024 20:10:33 +0100 Subject: [PATCH 1/2] stl: support vesper for commitment descriptions --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- src/bin/bpcore-stl.rs | 8 ++++++++ stl/ChainBlindSeal.vesper | 2 ++ stl/SingleBlindSeal.vesper | 2 ++ 5 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 stl/ChainBlindSeal.vesper create mode 100644 stl/SingleBlindSeal.vesper diff --git a/Cargo.lock b/Cargo.lock index e83be0c3..1e11d7af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -263,7 +263,7 @@ dependencies = [ [[package]] name = "commit_encoding_derive" version = "0.11.0-beta.3" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#5359d8437f5e63289ad0a63ecb66a3bd7d42f816" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=layouts#2b822b93e4088a36ca3fc23e5034c07452f322ba" dependencies = [ "amplify", "amplify_syn", @@ -275,7 +275,7 @@ dependencies = [ [[package]] name = "commit_verify" version = "0.11.0-beta.3" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#5359d8437f5e63289ad0a63ecb66a3bd7d42f816" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=layouts#2b822b93e4088a36ca3fc23e5034c07452f322ba" dependencies = [ "amplify", "commit_encoding_derive", @@ -285,6 +285,7 @@ dependencies = [ "sha2", "strict_encoding", "strict_types", + "vesper-lang", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 81c9f403..1ad8638f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,4 +91,4 @@ wasm-bindgen-test = "0.3" features = [ "all" ] [patch.crates-io] -commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.11" } +commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "layouts" } diff --git a/src/bin/bpcore-stl.rs b/src/bin/bpcore-stl.rs index 5a2bf95b..435a153f 100644 --- a/src/bin/bpcore-stl.rs +++ b/src/bin/bpcore-stl.rs @@ -24,6 +24,8 @@ use std::fs; use bc::stl::{bp_consensus_stl, bp_tx_stl}; use bp::stl::bp_core_stl; use commit_verify::stl::commit_verify_stl; +use commit_verify::CommitmentLayout; +use seals::txout::{ChainBlindSeal, CloseMethod, SingleBlindSeal}; use strict_encoding::libname; use strict_types::stl::std_stl; use strict_types::{parse_args, SystemBuilder}; @@ -96,6 +98,12 @@ fn main() { let dir = dir.unwrap_or_else(|| ".".to_owned()); + let layout = ChainBlindSeal::::commitment_layout(); + fs::write(format!("{dir}/ChainBlindSeal.vesper",), format!("{layout}")).unwrap(); + + let layout = SingleBlindSeal::::commitment_layout(); + fs::write(format!("{dir}/SingleBlindSeal.vesper",), format!("{layout}")).unwrap(); + let tt = sys.type_tree("BPCore.AnchorMerkleTreeTapretProof").unwrap(); fs::write(format!("{dir}/Anchor.MerkleTree.Tapret.vesper",), format!("{tt}")).unwrap(); diff --git a/stl/ChainBlindSeal.vesper b/stl/ChainBlindSeal.vesper new file mode 100644 index 00000000..79d3e1ff --- /dev/null +++ b/stl/ChainBlindSeal.vesper @@ -0,0 +1,2 @@ +SecretSeal commitment tagged=urn:lnp-bp:seals:secret#2024-02-03 + BlindSealTxPtr serialize diff --git a/stl/SingleBlindSeal.vesper b/stl/SingleBlindSeal.vesper new file mode 100644 index 00000000..b37e992a --- /dev/null +++ b/stl/SingleBlindSeal.vesper @@ -0,0 +1,2 @@ +SecretSeal commitment tagged=urn:lnp-bp:seals:secret#2024-02-03 + BlindSealTxid serialize From e15d688f66f6ceabe13a8e4ab6c8d45208788c19 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sun, 18 Feb 2024 20:27:05 +0100 Subject: [PATCH 2/2] stl: add Seals vesper description --- Cargo.lock | 7 +++--- Cargo.toml | 1 + src/bin/bpcore-stl.rs | 32 ++++++++++++++++++++++------ stl/Anchor.MerkleBlock.Tapret.vesper | 32 +++++++++++++++------------- stl/Anchor.MerkleProof.Tapret.vesper | 10 ++++----- stl/Anchor.MerkleTree.Opret.vesper | 13 +++++------ stl/Anchor.MerkleTree.Tapret.vesper | 21 +++++++++--------- stl/ChainBlindSeal.vesper | 2 -- stl/Seals.vesper | 29 +++++++++++++++++++++++++ stl/SingleBlindSeal.vesper | 2 -- 10 files changed, 98 insertions(+), 51 deletions(-) delete mode 100644 stl/ChainBlindSeal.vesper create mode 100644 stl/Seals.vesper delete mode 100644 stl/SingleBlindSeal.vesper diff --git a/Cargo.lock b/Cargo.lock index 1e11d7af..d9f80b50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -263,7 +263,7 @@ dependencies = [ [[package]] name = "commit_encoding_derive" version = "0.11.0-beta.3" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=layouts#2b822b93e4088a36ca3fc23e5034c07452f322ba" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=layouts#49345a16d6125af5aab58b2b4e83f3bfd222b097" dependencies = [ "amplify", "amplify_syn", @@ -275,7 +275,7 @@ dependencies = [ [[package]] name = "commit_verify" version = "0.11.0-beta.3" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=layouts#2b822b93e4088a36ca3fc23e5034c07452f322ba" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=layouts#49345a16d6125af5aab58b2b4e83f3bfd222b097" dependencies = [ "amplify", "commit_encoding_derive", @@ -652,8 +652,7 @@ dependencies = [ [[package]] name = "strict_types" version = "2.7.0-beta.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66de5cdf197b68e13fcac9fad7ed288f44052a319a3df3abbaba9c6e52f735b" +source = "git+https://github.com/strict-types/strict-types?branch=vesper#266f2d8b6e015522e9e7e72af663af9c9d3c7d2c" dependencies = [ "amplify", "baid58", diff --git a/Cargo.toml b/Cargo.toml index 1ad8638f..1eff42c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,4 +91,5 @@ wasm-bindgen-test = "0.3" features = [ "all" ] [patch.crates-io] +strict_types = { git = "https://github.com/strict-types/strict-types", branch = "vesper" } commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "layouts" } diff --git a/src/bin/bpcore-stl.rs b/src/bin/bpcore-stl.rs index 435a153f..19b51f65 100644 --- a/src/bin/bpcore-stl.rs +++ b/src/bin/bpcore-stl.rs @@ -20,6 +20,7 @@ // limitations under the License. use std::fs; +use std::io::Write; use bc::stl::{bp_consensus_stl, bp_tx_stl}; use bp::stl::bp_core_stl; @@ -98,25 +99,42 @@ fn main() { let dir = dir.unwrap_or_else(|| ".".to_owned()); - let layout = ChainBlindSeal::::commitment_layout(); - fs::write(format!("{dir}/ChainBlindSeal.vesper",), format!("{layout}")).unwrap(); + let mut file = fs::File::create(format!("{dir}/Seals.vesper")).unwrap(); + writeln!( + file, + "{{- + Description: Bitcoin TxO2 blind seals + Author: Dr Maxim Orlovsky + Copyright (C) 2024 LNP/BP Standards Association. All rights reserved. + License: Apache-2.0 +-}} +Seals vesper lexicon=types+commitments +" + ) + .unwrap(); let layout = SingleBlindSeal::::commitment_layout(); - fs::write(format!("{dir}/SingleBlindSeal.vesper",), format!("{layout}")).unwrap(); + writeln!(file, "{layout}").unwrap(); + let layout = ChainBlindSeal::::commitment_layout(); + writeln!(file, "{layout}").unwrap(); + let tt = sys.type_tree("BPCore.BlindSealTxid").unwrap(); + writeln!(file, "{tt}").unwrap(); + let tt = sys.type_tree("BPCore.BlindSealTxPtr").unwrap(); + writeln!(file, "{tt}").unwrap(); let tt = sys.type_tree("BPCore.AnchorMerkleTreeTapretProof").unwrap(); - fs::write(format!("{dir}/Anchor.MerkleTree.Tapret.vesper",), format!("{tt}")).unwrap(); + fs::write(format!("{dir}/Anchor.MerkleTree.Tapret.vesper"), format!("{tt}")).unwrap(); let tt = sys.type_tree("BPCore.AnchorMerkleTreeOpretProof").unwrap(); - fs::write(format!("{dir}/Anchor.MerkleTree.Opret.vesper",), format!("{tt}")).unwrap(); + fs::write(format!("{dir}/Anchor.MerkleTree.Opret.vesper"), format!("{tt}")).unwrap(); let tt = sys .type_tree("BPCore.AnchorMerkleBlockTapretProof") .unwrap(); - fs::write(format!("{dir}/Anchor.MerkleBlock.Tapret.vesper",), format!("{tt}")).unwrap(); + fs::write(format!("{dir}/Anchor.MerkleBlock.Tapret.vesper"), format!("{tt}")).unwrap(); let tt = sys .type_tree("BPCore.AnchorMerkleProofTapretProof") .unwrap(); - fs::write(format!("{dir}/Anchor.MerkleProof.Tapret.vesper",), format!("{tt}")).unwrap(); + fs::write(format!("{dir}/Anchor.MerkleProof.Tapret.vesper"), format!("{tt}")).unwrap(); } diff --git a/stl/Anchor.MerkleBlock.Tapret.vesper b/stl/Anchor.MerkleBlock.Tapret.vesper index e8395f79..2f913607 100644 --- a/stl/Anchor.MerkleBlock.Tapret.vesper +++ b/stl/Anchor.MerkleBlock.Tapret.vesper @@ -1,29 +1,31 @@ AnchorMerkleBlockTapretProof rec txid bytes len=32 aka=Txid - mpcProof rec -- MerkleBlock + mpcProof rec MerkleBlock depth enum { - _0=0 _1=1 _2=2 _3=3 _4=4 _5=5 _6=6 _7=7 _8=8 - _9=9 _10=10 _11=11 _12=12 _13=13 _14=14 _15=15 _16=16 - _17=17 _18=18 _19=19 _20=20 _21=21 _22=22 _23=23 _24=24 - _25=25 _26=26 _27=27 _28=28 _29=29 _30=30 _31=31 - } -- U5 + U5 _0=0 _1=1 _2=2 _3=3 _4=4 _5=5 _6=6 _7=7 + _8=8 _9=9 _10=10 _11=11 _12=12 _13=13 _14=14 _15=15 + _16=16 _17=17 _18=18 _19=19 _20=20 _21=21 _22=22 _23=23 + _24=24 _25=25 _26=26 _27=27 _28=28 _29=29 _30=30 _31=31 + + } cofactor is U16 crossSection list len=0..MAX32 TreeNode union concealedNode rec tag=0 depth enum { - _0=0 _1=1 _2=2 _3=3 _4=4 _5=5 _6=6 _7=7 _8=8 - _9=9 _10=10 _11=11 _12=12 _13=13 _14=14 _15=15 _16=16 - _17=17 _18=18 _19=19 _20=20 _21=21 _22=22 _23=23 _24=24 - _25=25 _26=26 _27=27 _28=28 _29=29 _30=30 _31=31 - } -- U5 + U5 _0=0 _1=1 _2=2 _3=3 _4=4 _5=5 _6=6 _7=7 + _8=8 _9=9 _10=10 _11=11 _12=12 _13=13 _14=14 _15=15 + _16=16 _17=17 _18=18 _19=19 _20=20 _21=21 _22=22 _23=23 + _24=24 _25=25 _26=26 _27=27 _28=28 _29=29 _30=30 _31=31 + + } hash bytes len=32 aka=MerkleHash commitmentLeaf rec tag=1 protocolId bytes len=32 aka=ProtocolId message bytes len=32 aka=Message some is U64 option wrapped tag=1 - dbcProof rec -- TapretProof - pathProof rec -- TapretPathProof - some union option wrapped tag=1 -- TapretNodePartner - rightBranch rec wrapped tag=2 -- TapretRightBranch + dbcProof rec TapretProof + pathProof rec TapretPathProof + some union TapretNodePartner option wrapped tag=1 + rightBranch rec TapretRightBranch wrapped tag=2 nonce is U8 diff --git a/stl/Anchor.MerkleProof.Tapret.vesper b/stl/Anchor.MerkleProof.Tapret.vesper index e7e2bb7b..027b1e08 100644 --- a/stl/Anchor.MerkleProof.Tapret.vesper +++ b/stl/Anchor.MerkleProof.Tapret.vesper @@ -1,12 +1,12 @@ AnchorMerkleProofTapretProof rec txid bytes len=32 aka=Txid - mpcProof rec -- MerkleProof + mpcProof rec MerkleProof pos is U32 cofactor is U16 path list len=0..32 element bytes len=32 aka=MerkleHash - dbcProof rec -- TapretProof - pathProof rec -- TapretPathProof - some union option wrapped tag=1 -- TapretNodePartner - rightBranch rec wrapped tag=2 -- TapretRightBranch + dbcProof rec TapretProof + pathProof rec TapretPathProof + some union TapretNodePartner option wrapped tag=1 + rightBranch rec TapretRightBranch wrapped tag=2 nonce is U8 diff --git a/stl/Anchor.MerkleTree.Opret.vesper b/stl/Anchor.MerkleTree.Opret.vesper index 5d71467f..13de5143 100644 --- a/stl/Anchor.MerkleTree.Opret.vesper +++ b/stl/Anchor.MerkleTree.Opret.vesper @@ -1,12 +1,13 @@ AnchorMerkleTreeOpretProof rec txid bytes len=32 aka=Txid - mpcProof rec -- MerkleTree + mpcProof rec MerkleTree depth enum { - _0=0 _1=1 _2=2 _3=3 _4=4 _5=5 _6=6 _7=7 _8=8 - _9=9 _10=10 _11=11 _12=12 _13=13 _14=14 _15=15 _16=16 - _17=17 _18=18 _19=19 _20=20 _21=21 _22=22 _23=23 _24=24 - _25=25 _26=26 _27=27 _28=28 _29=29 _30=30 _31=31 - } -- U5 + U5 _0=0 _1=1 _2=2 _3=3 _4=4 _5=5 _6=6 _7=7 + _8=8 _9=9 _10=10 _11=11 _12=12 _13=13 _14=14 _15=15 + _16=16 _17=17 _18=18 _19=19 _20=20 _21=21 _22=22 _23=23 + _24=24 _25=25 _26=26 _27=27 _28=28 _29=29 _30=30 _31=31 + + } entropy is U64 cofactor is U16 messages map len=0..MAX24 diff --git a/stl/Anchor.MerkleTree.Tapret.vesper b/stl/Anchor.MerkleTree.Tapret.vesper index b42c9feb..5de7efaa 100644 --- a/stl/Anchor.MerkleTree.Tapret.vesper +++ b/stl/Anchor.MerkleTree.Tapret.vesper @@ -1,12 +1,13 @@ AnchorMerkleTreeTapretProof rec txid bytes len=32 aka=Txid - mpcProof rec -- MerkleTree + mpcProof rec MerkleTree depth enum { - _0=0 _1=1 _2=2 _3=3 _4=4 _5=5 _6=6 _7=7 _8=8 - _9=9 _10=10 _11=11 _12=12 _13=13 _14=14 _15=15 _16=16 - _17=17 _18=18 _19=19 _20=20 _21=21 _22=22 _23=23 _24=24 - _25=25 _26=26 _27=27 _28=28 _29=29 _30=30 _31=31 - } -- U5 + U5 _0=0 _1=1 _2=2 _3=3 _4=4 _5=5 _6=6 _7=7 + _8=8 _9=9 _10=10 _11=11 _12=12 _13=13 _14=14 _15=15 + _16=16 _17=17 _18=18 _19=19 _20=20 _21=21 _22=22 _23=23 + _24=24 _25=25 _26=26 _27=27 _28=28 _29=29 _30=30 _31=31 + + } entropy is U64 cofactor is U16 messages map len=0..MAX24 @@ -17,8 +18,8 @@ AnchorMerkleTreeTapretProof rec value tuple _ bytes len=32 aka=ProtocolId _ bytes len=32 aka=Message - dbcProof rec -- TapretProof - pathProof rec -- TapretPathProof - some union option wrapped tag=1 -- TapretNodePartner - rightBranch rec wrapped tag=2 -- TapretRightBranch + dbcProof rec TapretProof + pathProof rec TapretPathProof + some union TapretNodePartner option wrapped tag=1 + rightBranch rec TapretRightBranch wrapped tag=2 nonce is U8 diff --git a/stl/ChainBlindSeal.vesper b/stl/ChainBlindSeal.vesper deleted file mode 100644 index 79d3e1ff..00000000 --- a/stl/ChainBlindSeal.vesper +++ /dev/null @@ -1,2 +0,0 @@ -SecretSeal commitment tagged=urn:lnp-bp:seals:secret#2024-02-03 - BlindSealTxPtr serialize diff --git a/stl/Seals.vesper b/stl/Seals.vesper new file mode 100644 index 00000000..f212aaef --- /dev/null +++ b/stl/Seals.vesper @@ -0,0 +1,29 @@ +{- + Description: Bitcoin TxO2 blind seals + Author: Dr Maxim Orlovsky + Copyright (C) 2024 LNP/BP Standards Association. All rights reserved. + License: Apache-2.0 +-} + +Seals vesper lexicon=types+commitments + +SecretSeal commitment hasher=SHA256 tagged=urn:lnp-bp:seals:secret#2024-02-03 + BlindSealTxid serialized + +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 + vout is U32 aka=Vout + blinding is U64 + diff --git a/stl/SingleBlindSeal.vesper b/stl/SingleBlindSeal.vesper deleted file mode 100644 index b37e992a..00000000 --- a/stl/SingleBlindSeal.vesper +++ /dev/null @@ -1,2 +0,0 @@ -SecretSeal commitment tagged=urn:lnp-bp:seals:secret#2024-02-03 - BlindSealTxid serialize