From d9460f14a34a307f8538169d40d4c0ef280c410c Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 12:38:49 +0100 Subject: [PATCH 01/13] seal: remove SecretSeal conceal and string methods They must be non-chain specific --- seals/src/txout/blind.rs | 85 ---------------------------------------- 1 file changed, 85 deletions(-) diff --git a/seals/src/txout/blind.rs b/seals/src/txout/blind.rs index df0261a1..4803ebd0 100644 --- a/seals/src/txout/blind.rs +++ b/seals/src/txout/blind.rs @@ -26,10 +26,7 @@ use std::hash::Hash; use std::str::FromStr; use amplify::{hex, Bytes32, Wrapper}; -use baid58::{Baid58ParseError, Chunking, FromBaid58, ToBaid58, CHUNKING_32CHECKSUM}; use bc::{Outpoint, Txid, Vout}; -use commit_verify::{CommitVerify, Conceal}; -use dbc::tapret::TapretFirst; use rand::{thread_rng, RngCore}; use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; @@ -133,13 +130,6 @@ impl From> for BlindSeal { fn from(seal: ExplicitSeal) -> Self { BlindSeal::::from(&seal) } } -impl Conceal for BlindSeal { - type Concealed = SecretSeal; - - #[inline] - fn conceal(&self) -> Self::Concealed { SecretSeal::commit(self) } -} - impl TxoSeal for BlindSeal { #[inline] fn method(&self) -> CloseMethod { self.method } @@ -225,10 +215,6 @@ impl BlindSeal { blinding, } } - - /// Converts revealed seal into concealed. - #[inline] - pub fn to_concealed_seal(&self) -> SecretSeal { self.conceal() } } impl BlindSeal { @@ -361,81 +347,10 @@ pub struct SecretSeal( Bytes32, ); -impl ToBaid58<32> for SecretSeal { - const HRI: &'static str = "utxob"; - const CHUNKING: Option = CHUNKING_32CHECKSUM; - fn to_baid58_payload(&self) -> [u8; 32] { self.0.into_inner() } - fn to_baid58_string(&self) -> String { self.to_string() } -} -impl FromBaid58<32> for SecretSeal {} -impl FromStr for SecretSeal { - type Err = Baid58ParseError; - fn from_str(s: &str) -> Result { - SecretSeal::from_baid58_maybe_chunked_str(s, ':', ' ') - } -} -impl Display for SecretSeal { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - if f.alternate() { - write!(f, "{::^}", self.to_baid58()) - } else { - write!(f, "{::^.3}", self.to_baid58()) - } - } -} - -impl From for SecretSeal { - #[inline] - fn from(outpoint: Outpoint) -> Self { BlindSeal::::from(outpoint).conceal() } -} - -impl CommitVerify, TapretFirst> for SecretSeal { - fn commit(reveal: &BlindSeal) -> Self { Bytes32::commit(reveal).into() } -} - #[cfg(test)] mod test { - use amplify::hex::FromHex; - use super::*; - #[test] - fn secret_seal_is_sha256d() { - let reveal = BlindSeal { - method: CloseMethod::TapretFirst, - blinding: 54683213134637, - txid: TxPtr::Txid( - Txid::from_hex("646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839") - .unwrap(), - ), - vout: Vout::from(2), - }; - assert_eq!(reveal.to_concealed_seal(), reveal.conceal()) - } - - #[test] - fn secret_seal_baid58() { - let seal = BlindSeal { - method: CloseMethod::TapretFirst, - blinding: 54683213134637, - txid: TxPtr::Txid( - Txid::from_hex("646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839") - .unwrap(), - ), - vout: Vout::from(2), - } - .to_concealed_seal(); - - let baid58 = "utxob:2eFrirU-RjqLnqR74-AKRfdnc9M-DpvSRjmZG-mFPrw7nvu-Te1wy83"; - assert_eq!(baid58, seal.to_string()); - assert_eq!(baid58.replace('-', ""), format!("{seal:#}")); - assert_eq!(seal.to_string(), seal.to_baid58_string()); - let reconstructed = SecretSeal::from_str(baid58).unwrap(); - assert_eq!(reconstructed, seal); - let reconstructed = SecretSeal::from_str(&baid58.replace('-', "")).unwrap(); - assert_eq!(reconstructed, seal); - } - #[test] fn blind_seal_str() { let mut outpoint_reveal = BlindSeal { From c08459093fd8852861c1022cac1a67938b780fc1 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 12:54:27 +0100 Subject: [PATCH 02/13] core: add Bp enumeration over different chain types --- src/bp.rs | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 2 files changed, 99 insertions(+) create mode 100644 src/bp.rs diff --git a/src/bp.rs b/src/bp.rs new file mode 100644 index 00000000..760f114a --- /dev/null +++ b/src/bp.rs @@ -0,0 +1,98 @@ +// Bitcoin protocol core library. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Written in 2019-2023 by +// Dr Maxim Orlovsky +// +// Copyright (C) 2019-2023 LNP/BP Standards Association. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use serde_crate::{Deserialize, Serialize}; +use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; + +/// Enumeration over types related to bitcoin protocol-compatible chains. +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)] +#[strict_type(lib = super::LIB_NAME_RGB, tags = custom, dumb = Self::Bitcoin(strict_dumb!()))] +#[cfg_attr( + feature = "serde", + derive(Serialize, Deserialize), + serde(crate = "serde_crate", rename_all = "camelCase") +)] +pub enum Bp +where T: StrictDumb + StrictEncode + StrictDecode +{ + #[strict_type(tag = 0x00)] + Bitcoin(T), + + #[strict_type(tag = 0x01)] + Liquid(T), +} + +impl Bp { + pub fn is_bitcoin(&self) -> bool { matches!(self, Bp::Bitcoin(_)) } + pub fn is_liquid(&self) -> bool { matches!(self, Bp::Liquid(_)) } + pub fn as_bitcoin(&self) -> Option<&T> { + match self { + Bp::Bitcoin(t) => Some(t), + Bp::Liquid(_) => None, + } + } + pub fn as_liquid(&self) -> Option<&T> { + match self { + Bp::Bitcoin(_) => None, + Bp::Liquid(t) => Some(t), + } + } + pub fn into_bitcoin(self) -> Option { + match self { + Bp::Bitcoin(t) => Some(t), + Bp::Liquid(_) => None, + } + } + pub fn into_liquid(self) -> Option { + match self { + Bp::Bitcoin(_) => None, + Bp::Liquid(t) => Some(t), + } + } + + pub fn map(self, f: impl FnOnce(T) -> U) -> Bp { + match self { + Bp::Bitcoin(t) => Bp::Bitcoin(f(t)), + Bp::Liquid(t) => Bp::Liquid(f(t)), + } + } + + pub fn try_map( + self, + f: impl FnOnce(T) -> Result, + ) -> Result, E> { + match self { + Bp::Bitcoin(t) => f(t).map(Bp::Bitcoin), + Bp::Liquid(t) => f(t).map(Bp::Liquid), + } + } + + pub fn maybe_map( + self, + f: impl FnOnce(T) -> Option, + ) -> Option> { + match self { + Bp::Bitcoin(t) => f(t).map(Bp::Bitcoin), + Bp::Liquid(t) => f(t).map(Bp::Liquid), + } + } +} diff --git a/src/lib.rs b/src/lib.rs index d7a19a3e..5428cb65 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,6 +56,7 @@ extern crate strict_encoding; #[cfg(feature = "stl")] pub mod stl; +mod bp; pub use ::bc::*; #[cfg(feature = "stl")] From f86807235bc2d72f17b8e6f5ada81218e2249015 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 13:00:16 +0100 Subject: [PATCH 03/13] seals: move SecretSeal to the top-level module --- seals/src/lib.rs | 3 +++ seals/src/secret.rs | 40 ++++++++++++++++++++++++++++++++++++++++ seals/src/txout/blind.rs | 20 +------------------- 3 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 seals/src/secret.rs diff --git a/seals/src/lib.rs b/seals/src/lib.rs index 4d864a0e..3534e715 100644 --- a/seals/src/lib.rs +++ b/seals/src/lib.rs @@ -45,3 +45,6 @@ extern crate serde_crate as serde; pub mod resolver; pub mod txout; +mod secret; + +pub use secret::SecretSeal; diff --git a/seals/src/secret.rs b/seals/src/secret.rs new file mode 100644 index 00000000..ceb6bbd4 --- /dev/null +++ b/seals/src/secret.rs @@ -0,0 +1,40 @@ +// Bitcoin protocol single-use-seals library. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Written in 2019-2023 by +// Dr Maxim Orlovsky +// +// Copyright (C) 2019-2023 LNP/BP Standards Association. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use amplify::Bytes32; + +/// Confidential version of transaction outpoint-based single-use-seal +#[derive(Wrapper, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, From)] +#[wrapper(Index, RangeOps, BorrowSlice, Hex)] +#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)] +#[strict_type(lib = dbc::LIB_NAME_BPCORE)] +#[derive(CommitEncode)] +#[commit_encode(strategy = strict)] +#[cfg_attr( + feature = "serde", + derive(Serialize, Deserialize), + serde(crate = "serde_crate", transparent) +)] +pub struct SecretSeal( + #[from] + #[from([u8; 32])] + Bytes32, +); diff --git a/seals/src/txout/blind.rs b/seals/src/txout/blind.rs index 4803ebd0..5ee9d70e 100644 --- a/seals/src/txout/blind.rs +++ b/seals/src/txout/blind.rs @@ -25,7 +25,7 @@ use std::fmt::{self, Debug, Display, Formatter}; use std::hash::Hash; use std::str::FromStr; -use amplify::{hex, Bytes32, Wrapper}; +use amplify::hex; use bc::{Outpoint, Txid, Vout}; use rand::{thread_rng, RngCore}; use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; @@ -329,24 +329,6 @@ where Self: TxoSeal } } -/// Blind version of transaction outpoint-based single-use-seal -#[derive(Wrapper, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, From)] -#[wrapper(Index, RangeOps, BorrowSlice, Hex)] -#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)] -#[strict_type(lib = dbc::LIB_NAME_BPCORE)] -#[derive(CommitEncode)] -#[commit_encode(strategy = strict)] -#[cfg_attr( - feature = "serde", - derive(Serialize, Deserialize), - serde(crate = "serde_crate", transparent) -)] -pub struct SecretSeal( - #[from] - #[from([u8; 32])] - Bytes32, -); - #[cfg(test)] mod test { use super::*; From f9e22a0587f2112bff4f3d8c9be18623cc143f13 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 13:02:12 +0100 Subject: [PATCH 04/13] seals: reformat exports --- seals/src/txout/mod.rs | 1 + src/lib.rs | 1 + src/stl.rs | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/seals/src/txout/mod.rs b/seals/src/txout/mod.rs index 72a8ad27..15a73a90 100644 --- a/seals/src/txout/mod.rs +++ b/seals/src/txout/mod.rs @@ -28,6 +28,7 @@ pub mod explicit; mod seal; mod witness; +pub use blind::{BlindSeal, ChainBlindSeal, SingleBlindSeal}; pub use error::{MethodParseError, VerifyError, WitnessVoutError}; pub use explicit::ExplicitSeal; pub use seal::{CloseMethod, SealTxid, TxPtr, TxoSeal}; diff --git a/src/lib.rs b/src/lib.rs index 5428cb65..63390dd4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,3 +64,4 @@ pub use ::bc::*; pub mod bc { pub use bc::stl; } +pub use bp::Bp; diff --git a/src/stl.rs b/src/stl.rs index eca984d5..d1e13fe3 100644 --- a/src/stl.rs +++ b/src/stl.rs @@ -48,9 +48,9 @@ fn _bp_core_stl() -> Result { .transpile::>() .transpile::>() .transpile::>() - .transpile::() - .transpile::>() - .transpile::>() + .transpile::() + .transpile::>() + .transpile::>() .compile() } From f70e8d8cce491eaafb9d52953db024bf3d5e8e33 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 13:02:22 +0100 Subject: [PATCH 05/13] core: add doc comments for Bp type --- src/bp.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bp.rs b/src/bp.rs index 760f114a..3528b4b6 100644 --- a/src/bp.rs +++ b/src/bp.rs @@ -25,7 +25,7 @@ use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; /// Enumeration over types related to bitcoin protocol-compatible chains. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)] -#[strict_type(lib = super::LIB_NAME_RGB, tags = custom, dumb = Self::Bitcoin(strict_dumb!()))] +#[strict_type(lib = dbc::LIB_NAME_BPCORE, tags = custom, dumb = Self::Bitcoin(strict_dumb!()))] #[cfg_attr( feature = "serde", derive(Serialize, Deserialize), @@ -34,34 +34,46 @@ use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; pub enum Bp where T: StrictDumb + StrictEncode + StrictDecode { + /// Bitcoin blockchain-based. + /// + /// NB: The type does not distinguish mainnet from testnets. #[strict_type(tag = 0x00)] Bitcoin(T), + /// Liquid blockchain-based + /// + /// NB: The type does not distinguish mainnet from testnets. #[strict_type(tag = 0x01)] Liquid(T), } impl Bp { + /// Detects if the variant matches bitcoin blockchain. pub fn is_bitcoin(&self) -> bool { matches!(self, Bp::Bitcoin(_)) } + /// Detects if the variant matches liquid blockchain. pub fn is_liquid(&self) -> bool { matches!(self, Bp::Liquid(_)) } + /// Returns bitcoin blockchain variant as an optional. pub fn as_bitcoin(&self) -> Option<&T> { match self { Bp::Bitcoin(t) => Some(t), Bp::Liquid(_) => None, } } + /// Returns liquid blockchain variant as an optional. pub fn as_liquid(&self) -> Option<&T> { match self { Bp::Bitcoin(_) => None, Bp::Liquid(t) => Some(t), } } + /// Converts into bitcoin blockchain optional. pub fn into_bitcoin(self) -> Option { match self { Bp::Bitcoin(t) => Some(t), Bp::Liquid(_) => None, } } + /// Converts into liquid blockchain optional. pub fn into_liquid(self) -> Option { match self { Bp::Bitcoin(_) => None, @@ -69,6 +81,7 @@ impl Bp { } } + /// Maps the value from one internal type into another. pub fn map(self, f: impl FnOnce(T) -> U) -> Bp { match self { Bp::Bitcoin(t) => Bp::Bitcoin(f(t)), @@ -76,6 +89,8 @@ impl Bp { } } + /// Maps the value from one internal type into another, covering cases which + /// may error. pub fn try_map( self, f: impl FnOnce(T) -> Result, @@ -86,6 +101,8 @@ impl Bp { } } + /// Maps the value from one internal type into another, covering cases which + /// may result in an optional value. pub fn maybe_map( self, f: impl FnOnce(T) -> Option, From c6347f17e2fe60f1282b68edb939a60605897f39 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 13:05:28 +0100 Subject: [PATCH 06/13] seals: remove From convertors generating random blinding numbers --- seals/src/txout/blind.rs | 24 +----------------------- seals/src/txout/seal.rs | 2 +- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/seals/src/txout/blind.rs b/seals/src/txout/blind.rs index 5ee9d70e..2547ddad 100644 --- a/seals/src/txout/blind.rs +++ b/seals/src/txout/blind.rs @@ -32,7 +32,7 @@ use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; use super::{CloseMethod, MethodParseError, WitnessVoutError}; use crate::txout::seal::{SealTxid, TxPtr}; -use crate::txout::{ExplicitSeal, TxoSeal}; +use crate::txout::TxoSeal; /// Seal type which can be blinded and chained with other seals. pub type ChainBlindSeal = BlindSeal; @@ -108,28 +108,6 @@ impl From<&Outpoint> for BlindSeal { fn from(outpoint: &Outpoint) -> Self { BlindSeal::tapret_first(outpoint.txid, outpoint.vout) } } -impl From for BlindSeal { - #[inline] - fn from(outpoint: Outpoint) -> Self { BlindSeal::from(&outpoint) } -} - -impl From<&ExplicitSeal> for BlindSeal { - #[inline] - fn from(seal: &ExplicitSeal) -> Self { - Self { - method: seal.method, - blinding: thread_rng().next_u64(), - txid: seal.txid, - vout: seal.vout, - } - } -} - -impl From> for BlindSeal { - #[inline] - fn from(seal: ExplicitSeal) -> Self { BlindSeal::::from(&seal) } -} - impl TxoSeal for BlindSeal { #[inline] fn method(&self) -> CloseMethod { self.method } diff --git a/seals/src/txout/seal.rs b/seals/src/txout/seal.rs index 49f5c562..d1205fd9 100644 --- a/seals/src/txout/seal.rs +++ b/seals/src/txout/seal.rs @@ -31,7 +31,7 @@ use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; pub type CloseMethod = dbc::Method; /// Methods common for all transaction-output based seal types. -pub trait TxoSeal: From { +pub trait TxoSeal { /// Returns method which must be used for seal closing. fn method(&self) -> CloseMethod; From c1a35b621ebaae09da57616a3de72bd7b0357c4f Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 13:08:38 +0100 Subject: [PATCH 07/13] selas: make methods generating random blinding explicitly named --- seals/src/txout/blind.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/seals/src/txout/blind.rs b/seals/src/txout/blind.rs index 2547ddad..0e8f7d96 100644 --- a/seals/src/txout/blind.rs +++ b/seals/src/txout/blind.rs @@ -31,8 +31,7 @@ use rand::{thread_rng, RngCore}; use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; use super::{CloseMethod, MethodParseError, WitnessVoutError}; -use crate::txout::seal::{SealTxid, TxPtr}; -use crate::txout::TxoSeal; +use crate::txout::{SealTxid, TxPtr, TxoSeal}; /// Seal type which can be blinded and chained with other seals. pub type ChainBlindSeal = BlindSeal; @@ -105,7 +104,9 @@ impl From> for Outpoint { impl From<&Outpoint> for BlindSeal { #[inline] - fn from(outpoint: &Outpoint) -> Self { BlindSeal::tapret_first(outpoint.txid, outpoint.vout) } + fn from(outpoint: &Outpoint) -> Self { + BlindSeal::tapret_first_rand(outpoint.txid, outpoint.vout) + } } impl TxoSeal for BlindSeal { @@ -133,31 +134,31 @@ impl TxoSeal for BlindSeal { impl BlindSeal { /// Creates new seal for the provided outpoint and seal closing method. Uses /// `thread_rng` to initialize blinding factor. - pub fn new(method: CloseMethod, txid: impl Into, vout: impl Into) -> Self { + pub fn new_random(method: CloseMethod, txid: impl Into, vout: impl Into) -> Self { BlindSeal::with_rng(method, txid, vout, &mut thread_rng()) } /// Creates new seal using TapretFirst closing method for the provided /// outpoint. Uses `thread_rng` to initialize blinding factor. - pub fn tapret_first_from(outpoint: Outpoint) -> Self { - BlindSeal::tapret_first(outpoint.txid, outpoint.vout) + pub fn tapret_first_rand_from(outpoint: Outpoint) -> Self { + BlindSeal::tapret_first_rand(outpoint.txid, outpoint.vout) } /// Creates new seal using OpretFirst closing method for the provided /// outpoint. Uses `thread_rng` to initialize blinding factor. - pub fn opret_first_from(outpoint: Outpoint) -> Self { - BlindSeal::opret_first(outpoint.txid, outpoint.vout) + pub fn opret_first_rand_from(outpoint: Outpoint) -> Self { + BlindSeal::opret_first_rand(outpoint.txid, outpoint.vout) } /// Creates new seal using TapretFirst closing method for the provided /// outpoint. Uses `thread_rng` to initialize blinding factor. - pub fn tapret_first(txid: impl Into, vout: impl Into) -> Self { + pub fn tapret_first_rand(txid: impl Into, vout: impl Into) -> Self { BlindSeal::with_rng(CloseMethod::TapretFirst, txid, vout, &mut thread_rng()) } /// Creates new seal using OpretFirst closing method for the provided /// outpoint. Uses `thread_rng` to initialize blinding factor. - pub fn opret_first(txid: impl Into, vout: impl Into) -> Self { + pub fn opret_first_rand(txid: impl Into, vout: impl Into) -> Self { BlindSeal::with_rng(CloseMethod::OpretFirst, txid, vout, &mut thread_rng()) } @@ -200,7 +201,7 @@ impl BlindSeal { /// Takes seal closing method and witness transaction output number as /// arguments. Uses `thread_rng` to initialize blinding factor. #[inline] - pub fn new_vout(method: CloseMethod, vout: impl Into) -> Self { + pub fn new_random_vout(method: CloseMethod, vout: impl Into) -> Self { Self { method, blinding: thread_rng().next_u64(), @@ -212,7 +213,7 @@ impl BlindSeal { /// Reconstructs previously defined seal pointing to a witness transaction /// of another seal with a given method, witness transaction output number /// and previously generated blinding factor value.. - pub fn with_vout(method: CloseMethod, vout: impl Into, blinding: u64) -> Self { + pub fn with_blinded_vout(method: CloseMethod, vout: impl Into, blinding: u64) -> Self { BlindSeal { method, txid: TxPtr::WitnessTx, From ff7ec6e18ff2735b102a10ceb9374f05e24911a1 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 14:04:24 +0100 Subject: [PATCH 08/13] epic: make DBC and seals generic over methods --- Cargo.lock | 12 ++-- Cargo.toml | 4 ++ dbc/src/anchor.rs | 23 ++++--- dbc/src/lib.rs | 2 +- dbc/src/opret/mod.rs | 2 +- dbc/src/proof.rs | 19 +++++- dbc/src/tapret/mod.rs | 2 +- seals/src/lib.rs | 5 ++ seals/src/txout/blind.rs | 127 +++++++++++++++++++----------------- seals/src/txout/error.rs | 1 - seals/src/txout/explicit.rs | 58 +++++++--------- seals/src/txout/mod.rs | 2 +- seals/src/txout/seal.rs | 6 +- seals/src/txout/witness.rs | 19 ++++-- src/bp.rs | 1 - src/lib.rs | 3 + src/stl.rs | 24 +++---- stl/BPCore@0.1.0.sta | 117 +++++++++++++++++---------------- stl/BPCore@0.1.0.stl | Bin 3664 -> 3728 bytes stl/BPCore@0.1.0.sty | 46 ++++++------- 20 files changed, 255 insertions(+), 218 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7026d5af..316a6abc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -267,8 +267,7 @@ dependencies = [ [[package]] name = "commit_encoding_derive" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00033f14d67c4169d588f085ea2faeb7b610cf03a74d42ea09eeba31abef2047" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#2d3a0a2981409c493067edfc94338088884b1aa7" dependencies = [ "amplify", "amplify_syn", @@ -280,8 +279,7 @@ dependencies = [ [[package]] name = "commit_verify" version = "0.11.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5598661b1d90b149f0b944faef8c1d1d131f847678a6c450b9540b629ac11291" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#2d3a0a2981409c493067edfc94338088884b1aa7" dependencies = [ "amplify", "commit_encoding_derive", @@ -666,8 +664,7 @@ dependencies = [ [[package]] name = "strict_encoding" version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7b75b4af0aff9dd97b68df262bf0e807b7d007cc860fa217943f898a05a5ab" +source = "git+https://github.com/strict-types/strict-encoding?branch=phantom#2123237a512bbe28e8e419e7d4f899dfedfa758c" dependencies = [ "amplify", "half", @@ -677,8 +674,7 @@ dependencies = [ [[package]] name = "strict_encoding_derive" version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37064ec285e2a633465eb525c8698eea51373dee889fe310e0d32df8343e7f4f" +source = "git+https://github.com/strict-types/strict-encoding?branch=phantom#2123237a512bbe28e8e419e7d4f899dfedfa758c" dependencies = [ "amplify_syn", "heck", diff --git a/Cargo.toml b/Cargo.toml index c66cf0b4..82978110 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,3 +81,7 @@ stl = ["strict_types", "strict_types/base64", "bp-consensus/stl", "commit_verify [package.metadata.docs.rs] features = [ "all" ] + +[patch.crates-io] +strict_encoding = { git = "https://github.com/strict-types/strict-encoding", branch = "phantom" } +commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.11" } diff --git a/dbc/src/anchor.rs b/dbc/src/anchor.rs index 68e0f11f..2acc062d 100644 --- a/dbc/src/anchor.rs +++ b/dbc/src/anchor.rs @@ -25,12 +25,13 @@ //! defined by LNPBP-4. use std::error::Error; +use std::marker::PhantomData; use bc::{Tx, Txid}; use commit_verify::mpc::{self, Message, ProtocolId}; use strict_encoding::{StrictDumb, StrictEncode}; -use crate::LIB_NAME_BPCORE; +use crate::{DbcMethod, LIB_NAME_BPCORE}; mod dbc { pub use crate::Proof; @@ -67,7 +68,7 @@ pub enum VerifyError { derive(Serialize, Deserialize), serde(crate = "serde_crate", rename_all = "camelCase") )] -pub struct Anchor { +pub struct Anchor, M: DbcMethod> { /// Transaction containing deterministic bitcoin commitment. pub txid: Txid, @@ -76,6 +77,10 @@ pub struct Anchor { /// Proof of the DBC commitment. pub dbc_proof: D, + + #[doc(hidden)] + #[strict_type(skip)] + pub _method: PhantomData, } /// Error merging two [`Anchor`]s. @@ -94,19 +99,20 @@ pub enum MergeError { DbcMismatch, } -impl Anchor { +impl, M: DbcMethod> Anchor { /// Reconstructs anchor containing merkle block pub fn into_merkle_block( self, protocol_id: impl Into, message: impl Into, - ) -> Result, mpc::InvalidProof> { + ) -> Result, mpc::InvalidProof> { let lnpbp4_proof = mpc::MerkleBlock::with(&self.mpc_proof, protocol_id.into(), message.into())?; Ok(Anchor { txid: self.txid, mpc_proof: lnpbp4_proof, dbc_proof: self.dbc_proof, + _method: default!(), }) } @@ -115,7 +121,7 @@ impl Anchor { &self, protocol_id: impl Into, message: impl Into, - ) -> Result, mpc::InvalidProof> { + ) -> Result, mpc::InvalidProof> { self.clone().into_merkle_block(protocol_id, message) } @@ -145,13 +151,13 @@ impl Anchor { } } -impl Anchor { +impl, M: DbcMethod> Anchor { /// Conceals all LNPBP-4 data except specific protocol and produces merkle /// proof anchor. pub fn to_merkle_proof( &self, protocol: impl Into, - ) -> Result, mpc::LeafNotKnown> { + ) -> Result, mpc::LeafNotKnown> { self.clone().into_merkle_proof(protocol) } @@ -160,12 +166,13 @@ impl Anchor { pub fn into_merkle_proof( self, protocol: impl Into, - ) -> Result, mpc::LeafNotKnown> { + ) -> Result, mpc::LeafNotKnown> { let lnpbp4_proof = self.mpc_proof.to_merkle_proof(protocol.into())?; Ok(Anchor { txid: self.txid, mpc_proof: lnpbp4_proof, dbc_proof: self.dbc_proof, + _method: default!(), }) } diff --git a/dbc/src/lib.rs b/dbc/src/lib.rs index 024ae299..17c8ca59 100644 --- a/dbc/src/lib.rs +++ b/dbc/src/lib.rs @@ -60,4 +60,4 @@ pub mod tapret; mod proof; pub use anchor::Anchor; -pub use proof::{Method, MethodParseError, Proof}; +pub use proof::{DbcMethod, Method, MethodParseError, Proof}; diff --git a/dbc/src/opret/mod.rs b/dbc/src/opret/mod.rs index 353e1369..8f5aa5f3 100644 --- a/dbc/src/opret/mod.rs +++ b/dbc/src/opret/mod.rs @@ -72,7 +72,7 @@ pub struct OpretProof(()); impl StrictSerialize for OpretProof {} impl StrictDeserialize for OpretProof {} -impl Proof for OpretProof { +impl Proof for OpretProof { type Error = EmbedVerifyError; const METHOD: Method = Method::OpretFirst; diff --git a/dbc/src/proof.rs b/dbc/src/proof.rs index e99e6275..28e73ec6 100644 --- a/dbc/src/proof.rs +++ b/dbc/src/proof.rs @@ -29,6 +29,19 @@ use strict_encoding::{StrictDecode, StrictDeserialize, StrictDumb, StrictEncode, use crate::LIB_NAME_BPCORE; +/// Trait defining DBC method - or enumberation of allowed DBC methods used by +/// proofs, single-use-seals etc. +pub trait DbcMethod: + Copy + + Eq + + Ord + + std::hash::Hash + + strict_encoding::StrictDumb + + strict_encoding::StrictEncode + + strict_encoding::StrictDecode +{ +} + /// wrong deterministic bitcoin commitment closing method id '{0}'. #[derive(Clone, PartialEq, Eq, Debug, Display, Error, From)] #[display(doc_comments)] @@ -57,6 +70,8 @@ pub enum Method { TapretFirst = 0x01, } +impl DbcMethod for Method {} + impl FromStr for Method { type Err = MethodParseError; @@ -70,14 +85,14 @@ impl FromStr for Method { } /// Deterministic bitcoin commitment proof types. -pub trait Proof: +pub trait Proof: Clone + Eq + Debug + CommitEncode + StrictSerialize + StrictDeserialize + StrictDumb { /// Verification error. type Error: Error; /// Returns DBC method used by the proof. - const METHOD: Method; + const METHOD: M; /// Verifies DBC proof against the provided transaction. fn verify(&self, msg: &mpc::Commitment, tx: &Tx) -> Result<(), Self::Error>; diff --git a/dbc/src/tapret/mod.rs b/dbc/src/tapret/mod.rs index 4368a2c5..78d750ec 100644 --- a/dbc/src/tapret/mod.rs +++ b/dbc/src/tapret/mod.rs @@ -382,7 +382,7 @@ impl TapretProof { } } -impl Proof for TapretProof { +impl Proof for TapretProof { type Error = ConvolveVerifyError; const METHOD: Method = Method::TapretFirst; diff --git a/seals/src/lib.rs b/seals/src/lib.rs index 3534e715..dcdcdd26 100644 --- a/seals/src/lib.rs +++ b/seals/src/lib.rs @@ -48,3 +48,8 @@ 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 {} diff --git a/seals/src/txout/blind.rs b/seals/src/txout/blind.rs index 0e8f7d96..e9c18885 100644 --- a/seals/src/txout/blind.rs +++ b/seals/src/txout/blind.rs @@ -27,16 +27,18 @@ use std::str::FromStr; use amplify::hex; use bc::{Outpoint, Txid, Vout}; +use dbc::MethodParseError; use rand::{thread_rng, RngCore}; use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; -use super::{CloseMethod, MethodParseError, WitnessVoutError}; +use super::{CloseMethod, WitnessVoutError}; use crate::txout::{SealTxid, TxPtr, TxoSeal}; +use crate::SealCloseMethod; /// Seal type which can be blinded and chained with other seals. -pub type ChainBlindSeal = BlindSeal; +pub type ChainBlindSeal = BlindSeal; /// Seal type which can be blinded, but can't be chained with other seals. -pub type SingleBlindSeal = BlindSeal; +pub type SingleBlindSeal = BlindSeal; /// Revealed seal definition which may point to a witness transactions and /// contains blinding data. @@ -49,10 +51,10 @@ pub type SingleBlindSeal = BlindSeal; #[derive(CommitEncode)] #[commit_encode(conceal, strategy = strict)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "serde_crate"))] -pub struct BlindSeal { +pub struct BlindSeal { /// Commitment to the specific seal close method [`CloseMethod`] which must /// be used to close this seal. - pub method: CloseMethod, + pub method: M, /// Txid of the seal definition. /// @@ -71,11 +73,11 @@ pub struct BlindSeal { pub blinding: u64, } -impl TryFrom<&BlindSeal> for Outpoint { +impl TryFrom<&BlindSeal> for Outpoint { type Error = WitnessVoutError; #[inline] - fn try_from(reveal: &BlindSeal) -> Result { + fn try_from(reveal: &BlindSeal) -> Result { reveal .txid .map_to_outpoint(reveal.vout) @@ -83,35 +85,28 @@ impl TryFrom<&BlindSeal> for Outpoint { } } -impl TryFrom> for Outpoint { +impl TryFrom> for Outpoint { type Error = WitnessVoutError; #[inline] - fn try_from(reveal: BlindSeal) -> Result { + fn try_from(reveal: BlindSeal) -> Result { Outpoint::try_from(&reveal) } } -impl From<&BlindSeal> for Outpoint { +impl From<&BlindSeal> for Outpoint { #[inline] - fn from(reveal: &BlindSeal) -> Self { Outpoint::new(reveal.txid, reveal.vout) } + fn from(reveal: &BlindSeal) -> Self { Outpoint::new(reveal.txid, reveal.vout) } } -impl From> for Outpoint { +impl From> for Outpoint { #[inline] - fn from(reveal: BlindSeal) -> Self { Outpoint::from(&reveal) } + fn from(reveal: BlindSeal) -> Self { Outpoint::from(&reveal) } } -impl From<&Outpoint> for BlindSeal { +impl TxoSeal for BlindSeal { #[inline] - fn from(outpoint: &Outpoint) -> Self { - BlindSeal::tapret_first_rand(outpoint.txid, outpoint.vout) - } -} - -impl TxoSeal for BlindSeal { - #[inline] - fn method(&self) -> CloseMethod { self.method } + fn method(&self) -> M { self.method } #[inline] fn txid(&self) -> Option { self.txid.txid() } @@ -131,13 +126,7 @@ impl TxoSeal for BlindSeal { } } -impl BlindSeal { - /// Creates new seal for the provided outpoint and seal closing method. Uses - /// `thread_rng` to initialize blinding factor. - pub fn new_random(method: CloseMethod, txid: impl Into, vout: impl Into) -> Self { - BlindSeal::with_rng(method, txid, vout, &mut thread_rng()) - } - +impl BlindSeal { /// Creates new seal using TapretFirst closing method for the provided /// outpoint. Uses `thread_rng` to initialize blinding factor. pub fn tapret_first_rand_from(outpoint: Outpoint) -> Self { @@ -161,11 +150,19 @@ impl BlindSeal { pub fn opret_first_rand(txid: impl Into, vout: impl Into) -> Self { BlindSeal::with_rng(CloseMethod::OpretFirst, txid, vout, &mut thread_rng()) } +} + +impl BlindSeal { + /// Creates new seal for the provided outpoint and seal closing method. Uses + /// `thread_rng` to initialize blinding factor. + pub fn new_random(method: M, txid: impl Into, vout: impl Into) -> Self { + BlindSeal::with_rng(method, txid, vout, &mut thread_rng()) + } /// Creates new seal for the provided outpoint and seal closing method. Uses /// provided random number generator to create a new blinding factor. pub fn with_rng( - method: CloseMethod, + method: M, txid: impl Into, vout: impl Into, rng: &mut impl RngCore, @@ -182,7 +179,7 @@ impl BlindSeal { /// of another seal with a given method, witness transaction output number /// and previously generated blinding factor value.. pub fn with_blinding( - method: CloseMethod, + method: M, txid: impl Into, vout: impl Into, blinding: u64, @@ -196,12 +193,12 @@ impl BlindSeal { } } -impl BlindSeal { +impl BlindSeal { /// Creates new seal pointing to a witness transaction of another seal. /// Takes seal closing method and witness transaction output number as /// arguments. Uses `thread_rng` to initialize blinding factor. #[inline] - pub fn new_random_vout(method: CloseMethod, vout: impl Into) -> Self { + pub fn new_random_vout(method: M, vout: impl Into) -> Self { Self { method, blinding: thread_rng().next_u64(), @@ -213,7 +210,7 @@ impl BlindSeal { /// Reconstructs previously defined seal pointing to a witness transaction /// of another seal with a given method, witness transaction output number /// and previously generated blinding factor value.. - pub fn with_blinded_vout(method: CloseMethod, vout: impl Into, blinding: u64) -> Self { + pub fn with_blinded_vout(method: M, vout: impl Into, blinding: u64) -> Self { BlindSeal { method, txid: TxPtr::WitnessTx, @@ -223,16 +220,16 @@ impl BlindSeal { } } -impl BlindSeal { +impl BlindSeal { /// Converts `BlindSeal` into `BlindSeal`. - pub fn transmutate(self) -> BlindSeal { + pub fn transmutate(self) -> BlindSeal { BlindSeal::with_blinding(self.method, self.txid, self.vout, self.blinding) } } -impl BlindSeal { +impl BlindSeal { /// Converts `BlindSeal` into `BlindSeal`. - pub fn resolve(self, txid: Txid) -> BlindSeal { + pub fn resolve(self, txid: Txid) -> BlindSeal { BlindSeal::with_blinding(self.method, self.txid().unwrap_or(txid), self.vout, self.blinding) } } @@ -276,7 +273,9 @@ pub enum ParseError { NonHexBlinding, } -impl FromStr for BlindSeal { +impl FromStr for BlindSeal +where M: FromStr +{ type Err = ParseError; fn from_str(s: &str) -> Result { @@ -300,8 +299,10 @@ impl FromStr for BlindSeal { } } -impl Display for BlindSeal -where Self: TxoSeal +impl Display for BlindSeal +where + Self: TxoSeal, + M: Display, { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{}:{}:{}#{:#010x}", self.method, self.txid, self.vout, self.blinding) @@ -341,7 +342,7 @@ mod test { // wrong method assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:0x765#\ 0x78ca95" ), @@ -350,21 +351,21 @@ mod test { // wrong vout value assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:0x765#\ 0x78ca95" ), Err(ParseError::WrongVout) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:i9#\ 0x78ca95" ), Err(ParseError::WrongVout) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:-5#\ 0x78ca95" ), @@ -373,27 +374,27 @@ mod test { // wrong blinding secret value assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:5#\ 0x78cs" ), Err(ParseError::WrongBlinding) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:5#\ 78ca95" ), Err(ParseError::NonHexBlinding) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:5#857" ), Err(ParseError::NonHexBlinding) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:5#-5" ), Err(ParseError::NonHexBlinding) @@ -401,18 +402,18 @@ mod test { // wrong txid value assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d607719dfd820551fb773e4dc8c4ed67965a8d1fae839:5#\ 0x78ca69" ), Err(ParseError::WrongTxid(hex::Error::OddLengthString(63))) ); assert_eq!( - ChainBlindSeal::from_str("tapret1st:rvgbdg:5#0x78ca69"), + ChainBlindSeal::::from_str("tapret1st:rvgbdg:5#0x78ca69"), Err(ParseError::WrongTxid(hex::Error::InvalidChar(b'r'))) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:10@646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:5#\ 0x78ca69" ), @@ -421,42 +422,48 @@ mod test { // wrong structure assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:1" ), Err(ParseError::WrongStructure) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839#0x78ca" ), Err(ParseError::WrongStructure) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839" ), Err(ParseError::BlindingRequired) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839##\ 0x78ca" ), Err(ParseError::WrongVout) ); assert_eq!( - ChainBlindSeal::from_str( + ChainBlindSeal::::from_str( "tapret1st:646ca5c1062619e2a2d60771c9dfd820551fb773e4dc8c4ed67965a8d1fae839:#\ 0x78ca95" ), Err(ParseError::WrongVout) ); assert_eq!( - ChainBlindSeal::from_str("tapret1st:_:5#0x78ca"), + ChainBlindSeal::::from_str("tapret1st:_:5#0x78ca"), Err(ParseError::WrongTxid(hex::Error::OddLengthString(1))) ); - assert_eq!(ChainBlindSeal::from_str(":5#0x78ca"), Err(ParseError::MethodRequired)); - assert_eq!(ChainBlindSeal::from_str("~:5#0x78ca"), Err(ParseError::MethodRequired)); + assert_eq!( + ChainBlindSeal::::from_str(":5#0x78ca"), + Err(ParseError::MethodRequired) + ); + assert_eq!( + ChainBlindSeal::::from_str("~:5#0x78ca"), + Err(ParseError::MethodRequired) + ); } } diff --git a/seals/src/txout/error.rs b/seals/src/txout/error.rs index 915d2e52..04848521 100644 --- a/seals/src/txout/error.rs +++ b/seals/src/txout/error.rs @@ -22,7 +22,6 @@ use std::error::Error; use bc::Outpoint; -pub use dbc::MethodParseError; /// Seal verification errors. #[derive(Clone, PartialEq, Eq, Debug, Display, From, Error)] diff --git a/seals/src/txout/explicit.rs b/seals/src/txout/explicit.rs index 27a3bc5a..18b0607f 100644 --- a/seals/src/txout/explicit.rs +++ b/seals/src/txout/explicit.rs @@ -26,9 +26,11 @@ use std::str::FromStr; use amplify::hex; use bc::{Outpoint, Txid, Vout}; +use dbc::MethodParseError; use crate::txout::seal::{SealTxid, TxPtr}; -use crate::txout::{CloseMethod, MethodParseError, TxoSeal, WitnessVoutError}; +use crate::txout::{TxoSeal, WitnessVoutError}; +use crate::SealCloseMethod; /// Revealed seal definition which may point to a witness transactions and does /// not contain blinding data. @@ -40,10 +42,10 @@ use crate::txout::{CloseMethod, MethodParseError, TxoSeal, WitnessVoutError}; #[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 { +pub struct ExplicitSeal { /// Commitment to the specific seal close method [`CloseMethod`] which must /// be used to close this seal. - pub method: CloseMethod, + pub method: M, /// Txid of the seal definition. /// @@ -57,11 +59,11 @@ pub struct ExplicitSeal { pub vout: Vout, } -impl TryFrom<&ExplicitSeal> for Outpoint { +impl TryFrom<&ExplicitSeal> for Outpoint { type Error = WitnessVoutError; #[inline] - fn try_from(reveal: &ExplicitSeal) -> Result { + fn try_from(reveal: &ExplicitSeal) -> Result { reveal .txid .map_to_outpoint(reveal.vout) @@ -69,42 +71,26 @@ impl TryFrom<&ExplicitSeal> for Outpoint { } } -impl TryFrom> for Outpoint { +impl TryFrom> for Outpoint { type Error = WitnessVoutError; #[inline] - fn try_from(reveal: ExplicitSeal) -> Result { + fn try_from(reveal: ExplicitSeal) -> Result { Outpoint::try_from(&reveal) } } -impl From<&ExplicitSeal> for Outpoint { - fn from(seal: &ExplicitSeal) -> Self { Outpoint::new(seal.txid, seal.vout) } +impl From<&ExplicitSeal> for Outpoint { + fn from(seal: &ExplicitSeal) -> Self { Outpoint::new(seal.txid, seal.vout) } } -impl From> for Outpoint { - fn from(seal: ExplicitSeal) -> Self { Outpoint::from(&seal) } +impl From> for Outpoint { + fn from(seal: ExplicitSeal) -> Self { Outpoint::from(&seal) } } -impl From<&Outpoint> for ExplicitSeal { +impl TxoSeal for ExplicitSeal { #[inline] - fn from(outpoint: &Outpoint) -> Self { - Self { - method: CloseMethod::TapretFirst, - txid: outpoint.txid.into(), - vout: outpoint.vout, - } - } -} - -impl From for ExplicitSeal { - #[inline] - fn from(outpoint: Outpoint) -> Self { ExplicitSeal::from(&outpoint) } -} - -impl TxoSeal for ExplicitSeal { - #[inline] - fn method(&self) -> CloseMethod { self.method } + fn method(&self) -> M { self.method } #[inline] fn txid(&self) -> Option { self.txid.txid() } @@ -124,10 +110,10 @@ impl TxoSeal for ExplicitSeal { } } -impl ExplicitSeal { +impl ExplicitSeal { /// Constructs seal for the provided outpoint and seal closing method. #[inline] - pub fn new(method: CloseMethod, outpoint: Outpoint) -> ExplicitSeal { + pub fn new(method: M, outpoint: Outpoint) -> ExplicitSeal { Self { method, txid: Id::from(outpoint.txid), @@ -137,7 +123,7 @@ impl ExplicitSeal { /// Constructs seal. #[inline] - pub fn with(method: CloseMethod, txid: Id, vout: impl Into) -> ExplicitSeal { + pub fn with(method: M, txid: Id, vout: impl Into) -> ExplicitSeal { ExplicitSeal { method, txid, @@ -174,7 +160,9 @@ pub enum ParseError { WrongStructure, } -impl FromStr for ExplicitSeal { +impl FromStr for ExplicitSeal +where M: FromStr +{ type Err = ParseError; fn from_str(s: &str) -> Result { @@ -192,7 +180,9 @@ impl FromStr for ExplicitSeal { } } -impl Display for ExplicitSeal { +impl Display for ExplicitSeal +where M: Display +{ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{}:{}:{}", self.method, self.txid, self.vout,) } diff --git a/seals/src/txout/mod.rs b/seals/src/txout/mod.rs index 15a73a90..6fc3acc1 100644 --- a/seals/src/txout/mod.rs +++ b/seals/src/txout/mod.rs @@ -29,7 +29,7 @@ mod seal; mod witness; pub use blind::{BlindSeal, ChainBlindSeal, SingleBlindSeal}; -pub use error::{MethodParseError, VerifyError, WitnessVoutError}; +pub use error::{VerifyError, WitnessVoutError}; pub use explicit::ExplicitSeal; pub use seal::{CloseMethod, SealTxid, TxPtr, TxoSeal}; pub use witness::Witness; diff --git a/seals/src/txout/seal.rs b/seals/src/txout/seal.rs index d1205fd9..6453e349 100644 --- a/seals/src/txout/seal.rs +++ b/seals/src/txout/seal.rs @@ -27,13 +27,15 @@ 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 { +pub trait TxoSeal { /// Returns method which must be used for seal closing. - fn method(&self) -> CloseMethod; + fn method(&self) -> M; /// Returns [`Txid`] part of the seal definition, if known. fn txid(&self) -> Option; diff --git a/seals/src/txout/witness.rs b/seals/src/txout/witness.rs index d28aafca..459471de 100644 --- a/seals/src/txout/witness.rs +++ b/seals/src/txout/witness.rs @@ -19,17 +19,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +use std::marker::PhantomData; + use bc::{Tx, Txid}; use commit_verify::mpc; -use dbc::Anchor; +use dbc::{Anchor, DbcMethod}; use single_use_seals::SealWitness; use strict_encoding::StrictDumb; use crate::txout::{TxoSeal, VerifyError}; +use crate::SealCloseMethod; /// Witness of a bitcoin-based seal being closed. Includes both transaction and /// extra-transaction data. -pub struct Witness { +pub struct Witness, M: DbcMethod> { /// Witness transaction: transaction which contains commitment to the /// message over which the seal is closed. pub tx: Tx, @@ -39,21 +42,27 @@ pub struct Witness { /// Deterministic bitcoin commitment proof from the anchor. pub proof: D, + + #[doc(hidden)] + pub _phantom: PhantomData, } -impl Witness { +impl, M: DbcMethod> Witness { /// Constructs witness from a witness transaction and extra-transaction /// proof, taken from an anchor. - pub fn with(tx: Tx, anchor: Anchor) -> Witness { + pub fn with(tx: Tx, anchor: Anchor) -> Witness { Witness { tx, txid: anchor.txid, proof: anchor.dbc_proof, + _phantom: default!(), } } } -impl SealWitness for Witness { +impl, Dbc: dbc::Proof, M: SealCloseMethod> SealWitness + for Witness +{ type Message = mpc::Commitment; type Error = VerifyError; diff --git a/src/bp.rs b/src/bp.rs index 3528b4b6..791ca24e 100644 --- a/src/bp.rs +++ b/src/bp.rs @@ -19,7 +19,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use serde_crate::{Deserialize, Serialize}; use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; /// Enumeration over types related to bitcoin protocol-compatible chains. diff --git a/src/lib.rs b/src/lib.rs index 63390dd4..28be4949 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,6 +53,9 @@ 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; diff --git a/src/stl.rs b/src/stl.rs index d1e13fe3..f6694fec 100644 --- a/src/stl.rs +++ b/src/stl.rs @@ -25,14 +25,14 @@ use bc::Txid; use commit_verify::mpc; use dbc::opret::OpretProof; use dbc::tapret::TapretProof; -use dbc::LIB_NAME_BPCORE; +use dbc::{Method, 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 = - "urn:ubideco:stl:JAeer3PsTTQRrGttsnPXJKdBTJqQwQ5ZwWHiABEDoCyd#simple-lava-lady"; + "urn:ubideco:stl:BhYxQht7Lv4Cu2s1HEjEo243nDA5oFactqiM8g9y3X5c#bagel-symbol-puma"; fn _bp_core_stl() -> Result { LibBuilder::new(libname!(LIB_NAME_BPCORE), tiny_bset! { @@ -40,17 +40,17 @@ fn _bp_core_stl() -> Result { bc::stl::bp_tx_stl().to_dependency(), commit_verify::stl::commit_verify_stl().to_dependency() }) - .transpile::>() - .transpile::>() - .transpile::>() - .transpile::>() - .transpile::>() - .transpile::>() - .transpile::>() - .transpile::>() + .transpile::>() + .transpile::>() + .transpile::>() + .transpile::>() + .transpile::>() + .transpile::>() + .transpile::>() + .transpile::>() .transpile::() - .transpile::>() - .transpile::>() + .transpile::>() + .transpile::>() .compile() } diff --git a/stl/BPCore@0.1.0.sta b/stl/BPCore@0.1.0.sta index c4afd4f7..3975eb76 100644 --- a/stl/BPCore@0.1.0.sta +++ b/stl/BPCore@0.1.0.sta @@ -1,5 +1,5 @@ -----BEGIN STRICT TYPE LIB----- -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kZQAEAgAE +bm9uZQAAAAEEc29tZQAFAQEBfAddAEBLFpWYGxfDYS3GuOquDX9wWWKSFnVa5RmT +EQVub25jZQAAAQtUYXByZXRQcm9vZgYCCXBhdGhQcm9vZgETxFNSZie7RCWMO2f0 +zMJ+/vzkJ7fPXg/9gY8vfnvYfAppbnRlcm5hbFBrAvVsE2Ij9jmnSgmT3EdGyfmK +q7iDWF212RY/GH7EKBoKqYWEd1OeaPuwv+7HmiHEV0PBVPj6vT+Y4NORPee3N3gR +VGFwcmV0UmlnaHRCcmFuY2gGAgxsZWZ0Tm9kZUhhc2gC9WwTYiP2OadKCZPcR0bJ ++YqruINYXbXZFj8YfsQoGgoxu67ohIl3xbAHMXIxzZL2MLYpLc2Jf9y63sW6xOl/ +2Q1yaWdodE5vZGVIYXNoAvVsE2Ij9jmnSgmT3EdGyfmKq7iDWF212RY/GH7EKBoK +Mbuu6ISJd8WwBzFyMc2S9jC2KS3NiX/cut7FusTpf9kFVHhQdHIEAgAJd2l0bmVz +c1R4AAAAAQR0eGlkAAUBAvVsE2Ij9jmnSgmT3EdGyfmKq7iDWF212RY/GH7EKBoK +o4JC88vX0dChEtqN4WAvVtT4bw7ExHbFwGhZTEsEZVY= -----END STRICT TYPE LIB----- diff --git a/stl/BPCore@0.1.0.stl b/stl/BPCore@0.1.0.stl index e675de47624f8cce83aaed53c4ac5e9bb968c7b3..0b0e965a07417a9a1561ddeb3915a4a246822ea6 100644 GIT binary patch delta 339 zcmca0GeLHP1v8`KWJ_jg4&T(0jQkWf=E;m)Zj*gkwI^i?VZ41B&wV(?Svpic(9!Of-8!CRed3Fe*%*%_fCv$6vM* z6-8u&LW)vTahda%4Q!6Mh*M5xUP^FkVopd!Knc(VU_Y@;UdT0N@;eS5F<~V6%oHSP r-O1*hlO@DmD++QllQT=uOqe{MYnr$isw7N1P);AHxqY)Kw=^>VaIkN6 delta 290 zcmbOrdqHM{1v8`cWJ_l0$s5^=CZA#Ul9h4HOU}qI@=Yzu&PjF3$xqG>Nh~NzEeR;f z&rgG@(wcmgML|XyStVH7A5~!|E1Gd&Md-$LvVx71mO?fzq$o8N#k4t-^Vt=EPMyFG za_SyIKBt__yp-V7#GH_dfRZ9MmdOXXbSH1*DCXrwlF6Lh$YC(~9asD0cbq)DJgyZ5 hIho0sB_M5+_j7F%5=0gO8w3>A2O5*Uxs+R)836vEYg+&S diff --git a/stl/BPCore@0.1.0.sty b/stl/BPCore@0.1.0.sty index e1e9b848..40b5d085 100644 --- a/stl/BPCore@0.1.0.sty +++ b/stl/BPCore@0.1.0.sty @@ -1,5 +1,5 @@ {- - Id: urn:ubideco:stl:JAeer3PsTTQRrGttsnPXJKdBTJqQwQ5ZwWHiABEDoCyd#simple-lava-lady + Id: urn:ubideco:stl:BhYxQht7Lv4Cu2s1HEjEo243nDA5oFactqiM8g9y3X5c#bagel-symbol-puma Name: BPCore Version: 0.1.0 Description: Bitcoin client-side-validation library @@ -37,48 +37,48 @@ import urn:ubideco:stl:HX2UBak8vPsTokug1DGMDvTpzns3xUdwZ7QJdyt4qBA9#speed-atlant --- urn:ubideco:semid:DKrqpWEpc5VW6WCjptkrQEYXFz1aMm3GXASDa3hH9kL6#wonder-road-crash -data AnchorMerkleBlockOpretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:39tJUEphvfMzQ5VoxgQUHdMWhav6TfZWbZCe5SU5mhM4#field-fortune-welcome +data AnchorMerkleBlockOpretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleBlock {- urn:ubideco:semid:EEbVZBjaYQWCQA7uRBe8hFkxV6U1uvpH2dT4PafmJ1ko#proxy-catalog-byte -} , dbcProof OpretProof --- urn:ubideco:semid:9JLeCN19dqXVcuMpubi1WVKEtC7CBcBCrWo9rAWKhBPK#reform-amigo-blast -data AnchorMerkleBlockTapretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:4Hz3b1tpksFaJuen2SNEV3P26amN49cUHKLisoF5Pppi#equal-alias-amber +data AnchorMerkleBlockTapretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleBlock {- urn:ubideco:semid:EEbVZBjaYQWCQA7uRBe8hFkxV6U1uvpH2dT4PafmJ1ko#proxy-catalog-byte -} , dbcProof TapretProof --- urn:ubideco:semid:GQuyLeS6kXYHxD5xnKMEnCV2AdzRBoGcT4yBKtXPLsCr#planet-opus-cantina -data AnchorMerkleProofOpretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:Q2tJZ48ViwaEnh2apU3jQTC99osnZyXSeFRHxaNcmCk#urban-caviar-domingo +data AnchorMerkleProofOpretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleProof {- urn:ubideco:semid:4E7NDL8Nm1EXtcenS9idAx1LAXvTu2wRdYsxT8Q2hgRC#carol-alamo-denver -} , dbcProof OpretProof --- urn:ubideco:semid:62Fuf8WYXdnukc8NXWm4vCTMqTeGfiy7JVQkWGxnwbEL#sardine-lorenzo-spend -data AnchorMerkleProofTapretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:9tKbE1NfmoacBbEvjFKy4Ror9KChY73mMmGj2FuYUsGN#rodent-cupid-disney +data AnchorMerkleProofTapretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleProof {- urn:ubideco:semid:4E7NDL8Nm1EXtcenS9idAx1LAXvTu2wRdYsxT8Q2hgRC#carol-alamo-denver -} , dbcProof TapretProof --- urn:ubideco:semid:6c1iMr3bcnR5Ae7ZbvWYZq1JkFtBL4noj6yJWURDyWje#critic-dolby-norway -data AnchorMerkleTreeOpretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:FgPESXsidcQVZy1yxbcLkT6PF82TMAzpeGrHZ2knbJN1#broken-round-brush +data AnchorMerkleTreeOpretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleTree {- urn:ubideco:semid:EhTy77DCCxuuKR1ixPLPRna1yc8LjDREYyxCcfdkQGo8#puzzle-quick-madrid -} , dbcProof OpretProof --- urn:ubideco:semid:BCsYvKdYApTXrXEeUyAAUHxqvNqbGikgsHv5F8ns9mrm#george-domingo-guide -data AnchorMerkleTreeTapretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:G32aVSGaBqjpLmPjrySL2PYKx39gHGWo7SJLXrwU5gNM#marco-samba-sonic +data AnchorMerkleTreeTapretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleTree {- urn:ubideco:semid:EhTy77DCCxuuKR1ixPLPRna1yc8LjDREYyxCcfdkQGo8#puzzle-quick-madrid -} , dbcProof TapretProof --- urn:ubideco:semid:8Tsxfmx9QLZGAMSJ6bgiMyhBvEdUipK2yNMhnnf4gHTP#explore-aspect-ranger -data BlindSealTxPtr :: method Method +-- urn:ubideco:semid:DHLkHbt2RLepBaygRZo4emc9vrcVW6e5m8AZFimr9Paw#nevada-nepal-music +data BlindSealTxPtrMethod :: method Method , txid TxPtr , vout Bitcoin.Vout {- urn:ubideco:semid:3HHRtSJW5fnGkdVW1EVDH7B97Y79WhwvKyyfsaBkuQkk#chrome-robin-gallop -} , blinding U64 --- urn:ubideco:semid:7t5ZVb1xKgQLQYJ3ubrginXkucdWnCyNKuFcsrHF482i#prepare-pluto-cactus -data BlindSealTxid :: method Method +-- urn:ubideco:semid:3v44qnj7gwSyWufXNAHovwqn2vb1P14mX7wkLoAdAPC4#cockpit-door-vertigo +data BlindSealTxidMethod :: method Method , txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , vout Bitcoin.Vout {- urn:ubideco:semid:3HHRtSJW5fnGkdVW1EVDH7B97Y79WhwvKyyfsaBkuQkk#chrome-robin-gallop -} , blinding U64 --- urn:ubideco:semid:Cx5JvbZGztYoTiCQPH1QvVHsFJynJ1za7ss7kGwdYZUM#fidel-boris-sunday -data ExplicitSeal :: method Method - , txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} - , vout Bitcoin.Vout {- urn:ubideco:semid:3HHRtSJW5fnGkdVW1EVDH7B97Y79WhwvKyyfsaBkuQkk#chrome-robin-gallop -} --- urn:ubideco:semid:J3RzHp689A6jBj6mLDvwe6xQqvThjxxucy9akuGoi9b4#british-aloha-mimosa -data ExplicitSealTxPtr :: method Method +-- urn:ubideco:semid:7tDuKtb36DdG5cJVc3xZxs9RWm6GNviiiL5taXM8sCbF#pamela-nominal-club +data ExplicitSealTxPtrMethod :: method Method , txid TxPtr , vout Bitcoin.Vout {- urn:ubideco:semid:3HHRtSJW5fnGkdVW1EVDH7B97Y79WhwvKyyfsaBkuQkk#chrome-robin-gallop -} +-- urn:ubideco:semid:G7vdeRsicMes7SP4XNkiHKjyzoVkUtkq5Pv1TBDMVDQq#aspirin-sector-hydro +data ExplicitSealTxidMethod :: method Method + , txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} + , vout Bitcoin.Vout {- urn:ubideco:semid:3HHRtSJW5fnGkdVW1EVDH7B97Y79WhwvKyyfsaBkuQkk#chrome-robin-gallop -} -- urn:ubideco:semid:49Mf3pFa3gZNQXJarv9nKCMrZ3NFn2ME9Q3dCAsXhpAe#trilogy-tahiti-valid data Method :: opretFirst:0 | tapretFirst:1 From e30a05fae8774d722da70673d7428aee07410abc Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 14:17:05 +0100 Subject: [PATCH 09/13] provide generic default method for DBCs and seals --- dbc/src/anchor.rs | 4 +- dbc/src/proof.rs | 2 +- seals/src/txout/blind.rs | 2 +- seals/src/txout/explicit.rs | 4 +- seals/src/txout/seal.rs | 2 +- seals/src/txout/witness.rs | 4 +- src/stl.rs | 2 +- stl/BPCore@0.1.0.sta | 117 ++++++++++++++++++------------------ stl/BPCore@0.1.0.stl | Bin 3728 -> 3668 bytes stl/BPCore@0.1.0.sty | 42 ++++++------- 10 files changed, 89 insertions(+), 90 deletions(-) diff --git a/dbc/src/anchor.rs b/dbc/src/anchor.rs index 2acc062d..119a7cd9 100644 --- a/dbc/src/anchor.rs +++ b/dbc/src/anchor.rs @@ -31,7 +31,7 @@ use bc::{Tx, Txid}; use commit_verify::mpc::{self, Message, ProtocolId}; use strict_encoding::{StrictDumb, StrictEncode}; -use crate::{DbcMethod, LIB_NAME_BPCORE}; +use crate::{DbcMethod, Method, LIB_NAME_BPCORE}; mod dbc { pub use crate::Proof; @@ -68,7 +68,7 @@ pub enum VerifyError { derive(Serialize, Deserialize), serde(crate = "serde_crate", rename_all = "camelCase") )] -pub struct Anchor, M: DbcMethod> { +pub struct Anchor, M: DbcMethod = Method> { /// Transaction containing deterministic bitcoin commitment. pub txid: Txid, diff --git a/dbc/src/proof.rs b/dbc/src/proof.rs index 28e73ec6..2128b869 100644 --- a/dbc/src/proof.rs +++ b/dbc/src/proof.rs @@ -85,7 +85,7 @@ impl FromStr for Method { } /// Deterministic bitcoin commitment proof types. -pub trait Proof: +pub trait Proof: Clone + Eq + Debug + CommitEncode + StrictSerialize + StrictDeserialize + StrictDumb { /// Verification error. diff --git a/seals/src/txout/blind.rs b/seals/src/txout/blind.rs index e9c18885..4a29bfd5 100644 --- a/seals/src/txout/blind.rs +++ b/seals/src/txout/blind.rs @@ -51,7 +51,7 @@ pub type SingleBlindSeal = BlindSeal; #[derive(CommitEncode)] #[commit_encode(conceal, strategy = strict)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "serde_crate"))] -pub struct BlindSeal { +pub struct BlindSeal { /// Commitment to the specific seal close method [`CloseMethod`] which must /// be used to close this seal. pub method: M, diff --git a/seals/src/txout/explicit.rs b/seals/src/txout/explicit.rs index 18b0607f..1b9b9540 100644 --- a/seals/src/txout/explicit.rs +++ b/seals/src/txout/explicit.rs @@ -29,7 +29,7 @@ use bc::{Outpoint, Txid, Vout}; use dbc::MethodParseError; use crate::txout::seal::{SealTxid, TxPtr}; -use crate::txout::{TxoSeal, WitnessVoutError}; +use crate::txout::{CloseMethod, TxoSeal, WitnessVoutError}; use crate::SealCloseMethod; /// Revealed seal definition which may point to a witness transactions and does @@ -42,7 +42,7 @@ use crate::SealCloseMethod; #[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 { +pub struct ExplicitSeal { /// Commitment to the specific seal close method [`CloseMethod`] which must /// be used to close this seal. pub method: M, diff --git a/seals/src/txout/seal.rs b/seals/src/txout/seal.rs index 6453e349..c618884d 100644 --- a/seals/src/txout/seal.rs +++ b/seals/src/txout/seal.rs @@ -33,7 +33,7 @@ use crate::SealCloseMethod; pub type CloseMethod = dbc::Method; /// Methods common for all transaction-output based seal types. -pub trait TxoSeal { +pub trait TxoSeal { /// Returns method which must be used for seal closing. fn method(&self) -> M; diff --git a/seals/src/txout/witness.rs b/seals/src/txout/witness.rs index 459471de..060b4a43 100644 --- a/seals/src/txout/witness.rs +++ b/seals/src/txout/witness.rs @@ -23,7 +23,7 @@ use std::marker::PhantomData; use bc::{Tx, Txid}; use commit_verify::mpc; -use dbc::{Anchor, DbcMethod}; +use dbc::{Anchor, DbcMethod, Method}; use single_use_seals::SealWitness; use strict_encoding::StrictDumb; @@ -32,7 +32,7 @@ use crate::SealCloseMethod; /// Witness of a bitcoin-based seal being closed. Includes both transaction and /// extra-transaction data. -pub struct Witness, M: DbcMethod> { +pub struct Witness, M: DbcMethod = Method> { /// Witness transaction: transaction which contains commitment to the /// message over which the seal is closed. pub tx: Tx, diff --git a/src/stl.rs b/src/stl.rs index f6694fec..f465b7c6 100644 --- a/src/stl.rs +++ b/src/stl.rs @@ -32,7 +32,7 @@ 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 = - "urn:ubideco:stl:BhYxQht7Lv4Cu2s1HEjEo243nDA5oFactqiM8g9y3X5c#bagel-symbol-puma"; + "urn:ubideco:stl:8wHziC7Bxa3BwctUh6EVBanosrvRHecCTPUjkZT4btNd#ruby-heaven-madrid"; fn _bp_core_stl() -> Result { LibBuilder::new(libname!(LIB_NAME_BPCORE), tiny_bset! { diff --git a/stl/BPCore@0.1.0.sta b/stl/BPCore@0.1.0.sta index 3975eb76..ad6cbad6 100644 --- a/stl/BPCore@0.1.0.sta +++ b/stl/BPCore@0.1.0.sta @@ -1,5 +1,5 @@ -----BEGIN STRICT TYPE LIB----- -Id: urn:ubideco:stl:BhYxQht7Lv4Cu2s1HEjEo243nDA5oFactqiM8g9y3X5c +Id: urn:ubideco:stl:8wHziC7Bxa3BwctUh6EVBanosrvRHecCTPUjkZT4btNd Name: BPCore Dependencies: urn:ubideco:stl:ZtHaBzu9ojbDahaGKEXe5v9DfSDxLERbLkEB23R6Q6V, @@ -23,67 +23,66 @@ zwgGoQTN4EhrE+EM/BiDQ7DXCFRyZWVOb2RlVY03B/hFhlOA7sxBVSTopJlgUdOU gkPxlPfxkVcj6eYKTWVya2xlTm9kZcSjey0sUm61SVrV2YoViLxzSewBWsX1CXan Ve6cuw9UC01lcmtsZUJsb2Nry4WnixKlN0z/+yP1y7+ZtmRLKZWGfXEXiSI1Wfx7 i1cKTWVya2xlVHJlZQNTdGQBACLk4JbpvX1chvXh3113AWr+Occ82TSFUJRAiYyo -o3leAlU1EgAhQW5jaG9yTWVya2xlQmxvY2tPcHJldFByb29mTWV0aG9kBgMEdHhp -ZAL1bBNiI/Y5p0oJk9xHRsn5iqu4g1hdtdkWPxh+xCgaCqOCQvPL19HQoRLajeFg -L1bU+G8OxMR2xcBoWUxLBGVWCG1wY1Byb29mAghskyk/Vmjs2d+dQHUI16EzIxZE -QVYCiy6sCb/l341CxKN7LSxSbrVJWtXZihWIvHNJ7AFaxfUJdqdV7py7D1QIZGJj -UHJvb2YBR07PXNDoTD546vs8PljsuFnNdzezZ2QEah4TSps4O5ciQW5jaG9yTWVy -a2xlQmxvY2tUYXByZXRQcm9vZk1ldGhvZAYDBHR4aWQC9WwTYiP2OadKCZPcR0bJ -+YqruINYXbXZFj8YfsQoGgqjgkLzy9fR0KES2o3hYC9W1PhvDsTEdsXAaFlMSwRl -VghtcGNQcm9vZgIIbJMpP1Zo7NnfnUB1CNehMyMWREFWAosurAm/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P07FFNmxjWeA2gqr6y0mC/03LaPAeqRdOZ9N +AgtyaWdodEJyYW5jaAAFAQE4P2IucVPSyCGRPMt3HZ89ZN928ihVWS34RkOUFk1t +BQ9UYXByZXRQYXRoUHJvb2YGAgtwYXJ0bmVyTm9kZQAEAgAEbm9uZQAAAAEEc29t +ZQAFAQEBfAddAEBLFpWYGxfDYS3GuOquDX9wWWKSFnVa5RmTEQVub25jZQAAAQtU +YXByZXRQcm9vZgYCCXBhdGhQcm9vZgETxFNSZie7RCWMO2f0zMJ+/vzkJ7fPXg/9 +gY8vfnvYfAppbnRlcm5hbFBrAvVsE2Ij9jmnSgmT3EdGyfmKq7iDWF212RY/GH7E +KBoKqYWEd1OeaPuwv+7HmiHEV0PBVPj6vT+Y4NORPee3N3gRVGFwcmV0UmlnaHRC +cmFuY2gGAgxsZWZ0Tm9kZUhhc2gC9WwTYiP2OadKCZPcR0bJ+YqruINYXbXZFj8Y +fsQoGgoxu67ohIl3xbAHMXIxzZL2MLYpLc2Jf9y63sW6xOl/2Q1yaWdodE5vZGVI +YXNoAvVsE2Ij9jmnSgmT3EdGyfmKq7iDWF212RY/GH7EKBoKMbuu6ISJd8WwBzFy +Mc2S9jC2KS3NiX/cut7FusTpf9kFVHhQdHIEAgAJd2l0bmVzc1R4AAAAAQR0eGlk +AAUBAvVsE2Ij9jmnSgmT3EdGyfmKq7iDWF212RY/GH7EKBoKo4JC88vX0dChEtqN +4WAvVtT4bw7ExHbFwGhZTEsEZVY= -----END STRICT TYPE LIB----- diff --git a/stl/BPCore@0.1.0.stl b/stl/BPCore@0.1.0.stl index 0b0e965a07417a9a1561ddeb3915a4a246822ea6..7ed02cd7664b624556292436a3a0d6498d2dee7f 100644 GIT binary patch delta 293 zcmbOrdqrl01v8`cWJ_l0$s5^=CZA#Ul9h4HOU}qI@=Yzu&PjF3$xqG>Nh~NzEeR;f z&rgG@(wcmgML|XyStVH7A5~!|E1Gd&Md-$LvVx71mO?fzq$o8N#k4t-^Vt=EPMyFG za_SyIKBt__yp-V7#GH_dfRZ9MmdOXXbSH1*DCXrwlF6Lh$YC(~9asD0cbq&zg02+> hIho0sC2(z%_jBn3HKhv(ph{&<7UVM6{Ell8GXOr{Y-Rue delta 311 zcmca2GeLHP1v8`KWJ_jgHs92ejQo_z_gIT2&u7t^{DE14QE9RuiwvrS7f|&p79`bk zCNE@FP*!rxOU}qI@=Yzu&Pfd@%Fj;=Nh~NzEdev(ChuWXm^_{=iLloXK- z2q{WU#iqY#@_%+OaS^AS%)FG~)Wn>SihvTJogjC!u}r?lIc4%Y4jwUKB>Bt~Bx&8r p=A4ry#9b>2ax#-MOVCW1e1~(IxEQJ=Ogm6cAE>!~vn97QGXSRtas>bY diff --git a/stl/BPCore@0.1.0.sty b/stl/BPCore@0.1.0.sty index 40b5d085..98254051 100644 --- a/stl/BPCore@0.1.0.sty +++ b/stl/BPCore@0.1.0.sty @@ -1,5 +1,5 @@ {- - Id: urn:ubideco:stl:BhYxQht7Lv4Cu2s1HEjEo243nDA5oFactqiM8g9y3X5c#bagel-symbol-puma + Id: urn:ubideco:stl:8wHziC7Bxa3BwctUh6EVBanosrvRHecCTPUjkZT4btNd#ruby-heaven-madrid Name: BPCore Version: 0.1.0 Description: Bitcoin client-side-validation library @@ -37,46 +37,46 @@ import urn:ubideco:stl:HX2UBak8vPsTokug1DGMDvTpzns3xUdwZ7QJdyt4qBA9#speed-atlant --- urn:ubideco:semid:39tJUEphvfMzQ5VoxgQUHdMWhav6TfZWbZCe5SU5mhM4#field-fortune-welcome -data AnchorMerkleBlockOpretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:DKrqpWEpc5VW6WCjptkrQEYXFz1aMm3GXASDa3hH9kL6#wonder-road-crash +data AnchorMerkleBlockOpretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleBlock {- urn:ubideco:semid:EEbVZBjaYQWCQA7uRBe8hFkxV6U1uvpH2dT4PafmJ1ko#proxy-catalog-byte -} , dbcProof OpretProof --- urn:ubideco:semid:4Hz3b1tpksFaJuen2SNEV3P26amN49cUHKLisoF5Pppi#equal-alias-amber -data AnchorMerkleBlockTapretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:9JLeCN19dqXVcuMpubi1WVKEtC7CBcBCrWo9rAWKhBPK#reform-amigo-blast +data AnchorMerkleBlockTapretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleBlock {- urn:ubideco:semid:EEbVZBjaYQWCQA7uRBe8hFkxV6U1uvpH2dT4PafmJ1ko#proxy-catalog-byte -} , dbcProof TapretProof --- urn:ubideco:semid:Q2tJZ48ViwaEnh2apU3jQTC99osnZyXSeFRHxaNcmCk#urban-caviar-domingo -data AnchorMerkleProofOpretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:GQuyLeS6kXYHxD5xnKMEnCV2AdzRBoGcT4yBKtXPLsCr#planet-opus-cantina +data AnchorMerkleProofOpretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleProof {- urn:ubideco:semid:4E7NDL8Nm1EXtcenS9idAx1LAXvTu2wRdYsxT8Q2hgRC#carol-alamo-denver -} , dbcProof OpretProof --- urn:ubideco:semid:9tKbE1NfmoacBbEvjFKy4Ror9KChY73mMmGj2FuYUsGN#rodent-cupid-disney -data AnchorMerkleProofTapretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:62Fuf8WYXdnukc8NXWm4vCTMqTeGfiy7JVQkWGxnwbEL#sardine-lorenzo-spend +data AnchorMerkleProofTapretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleProof {- urn:ubideco:semid:4E7NDL8Nm1EXtcenS9idAx1LAXvTu2wRdYsxT8Q2hgRC#carol-alamo-denver -} , dbcProof TapretProof --- urn:ubideco:semid:FgPESXsidcQVZy1yxbcLkT6PF82TMAzpeGrHZ2knbJN1#broken-round-brush -data AnchorMerkleTreeOpretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:6c1iMr3bcnR5Ae7ZbvWYZq1JkFtBL4noj6yJWURDyWje#critic-dolby-norway +data AnchorMerkleTreeOpretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleTree {- urn:ubideco:semid:EhTy77DCCxuuKR1ixPLPRna1yc8LjDREYyxCcfdkQGo8#puzzle-quick-madrid -} , dbcProof OpretProof --- urn:ubideco:semid:G32aVSGaBqjpLmPjrySL2PYKx39gHGWo7SJLXrwU5gNM#marco-samba-sonic -data AnchorMerkleTreeTapretProofMethod :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} +-- urn:ubideco:semid:BCsYvKdYApTXrXEeUyAAUHxqvNqbGikgsHv5F8ns9mrm#george-domingo-guide +data AnchorMerkleTreeTapretProof :: txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , mpcProof CommitVerify.MerkleTree {- urn:ubideco:semid:EhTy77DCCxuuKR1ixPLPRna1yc8LjDREYyxCcfdkQGo8#puzzle-quick-madrid -} , dbcProof TapretProof --- urn:ubideco:semid:DHLkHbt2RLepBaygRZo4emc9vrcVW6e5m8AZFimr9Paw#nevada-nepal-music -data BlindSealTxPtrMethod :: method Method +-- urn:ubideco:semid:8Tsxfmx9QLZGAMSJ6bgiMyhBvEdUipK2yNMhnnf4gHTP#explore-aspect-ranger +data BlindSealTxPtr :: method Method , txid TxPtr , vout Bitcoin.Vout {- urn:ubideco:semid:3HHRtSJW5fnGkdVW1EVDH7B97Y79WhwvKyyfsaBkuQkk#chrome-robin-gallop -} , blinding U64 --- urn:ubideco:semid:3v44qnj7gwSyWufXNAHovwqn2vb1P14mX7wkLoAdAPC4#cockpit-door-vertigo -data BlindSealTxidMethod :: method Method +-- urn:ubideco:semid:7t5ZVb1xKgQLQYJ3ubrginXkucdWnCyNKuFcsrHF482i#prepare-pluto-cactus +data BlindSealTxid :: method Method , txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , vout Bitcoin.Vout {- urn:ubideco:semid:3HHRtSJW5fnGkdVW1EVDH7B97Y79WhwvKyyfsaBkuQkk#chrome-robin-gallop -} , blinding U64 --- urn:ubideco:semid:7tDuKtb36DdG5cJVc3xZxs9RWm6GNviiiL5taXM8sCbF#pamela-nominal-club -data ExplicitSealTxPtrMethod :: method Method +-- urn:ubideco:semid:J3RzHp689A6jBj6mLDvwe6xQqvThjxxucy9akuGoi9b4#british-aloha-mimosa +data ExplicitSealTxPtr :: method Method , txid TxPtr , vout Bitcoin.Vout {- urn:ubideco:semid:3HHRtSJW5fnGkdVW1EVDH7B97Y79WhwvKyyfsaBkuQkk#chrome-robin-gallop -} --- urn:ubideco:semid:G7vdeRsicMes7SP4XNkiHKjyzoVkUtkq5Pv1TBDMVDQq#aspirin-sector-hydro -data ExplicitSealTxidMethod :: method Method +-- urn:ubideco:semid:2FntXjC5uPaUYZewpkJPRyJyS19BmiCS3XVaitYDqtoR#think-convert-temple +data ExplicitSealTxid :: method Method , txid Bitcoin.Txid {- urn:ubideco:semid:C1GfCrG7AXu2sFhRBspd7KpJK2YgyTkVy6pty5rZynRs#cowboy-diego-betty -} , vout Bitcoin.Vout {- urn:ubideco:semid:3HHRtSJW5fnGkdVW1EVDH7B97Y79WhwvKyyfsaBkuQkk#chrome-robin-gallop -} -- urn:ubideco:semid:49Mf3pFa3gZNQXJarv9nKCMrZ3NFn2ME9Q3dCAsXhpAe#trilogy-tahiti-valid From f116b5f7cbf29e4879d427ee397df66791940462 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 19:59:18 +0100 Subject: [PATCH 10/13] seals: return Display and FromStr impl for SecretSeal --- seals/src/secret.rs | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/seals/src/secret.rs b/seals/src/secret.rs index ceb6bbd4..7be3a511 100644 --- a/seals/src/secret.rs +++ b/seals/src/secret.rs @@ -19,7 +19,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -use amplify::Bytes32; +use std::fmt::{self, Display, Formatter}; +use std::str::FromStr; + +use amplify::{Bytes32, Wrapper}; +use baid58::{Baid58ParseError, Chunking, FromBaid58, ToBaid58, CHUNKING_32CHECKSUM}; /// Confidential version of transaction outpoint-based single-use-seal #[derive(Wrapper, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, From)] @@ -38,3 +42,42 @@ pub struct SecretSeal( #[from([u8; 32])] Bytes32, ); + +impl ToBaid58<32> for SecretSeal { + const HRI: &'static str = "utxob"; + const CHUNKING: Option = CHUNKING_32CHECKSUM; + fn to_baid58_payload(&self) -> [u8; 32] { self.0.into_inner() } + fn to_baid58_string(&self) -> String { self.to_string() } +} +impl FromBaid58<32> for SecretSeal {} +impl FromStr for SecretSeal { + type Err = Baid58ParseError; + fn from_str(s: &str) -> Result { + SecretSeal::from_baid58_maybe_chunked_str(s, ':', ' ') + } +} +impl Display for SecretSeal { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + if f.alternate() { + write!(f, "{::^}", self.to_baid58()) + } else { + write!(f, "{::^.3}", self.to_baid58()) + } + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn secret_seal_baid58() { + let baid58 = "utxob:2eFrirU-RjqLnqR74-AKRfdnc9M-DpvSRjmZG-mFPrw7nvu-Te1wy83"; + let seal: SecretSeal = baid58.parse().unwrap(); + assert_eq!(baid58, seal.to_string()); + assert_eq!(baid58.replace('-', ""), format!("{seal:#}")); + assert_eq!(seal.to_string(), seal.to_baid58_string()); + let reconstructed = SecretSeal::from_str(&baid58.replace('-', "")).unwrap(); + assert_eq!(reconstructed, seal); + } +} From cbc896d075772a7b4eb620cd8c76cae86ff331c1 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 29 Dec 2023 20:23:49 +0100 Subject: [PATCH 11/13] seals: refactor conceal procedure --- seals/src/secret.rs | 10 ++++++++++ seals/src/txout/blind.rs | 14 +++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/seals/src/secret.rs b/seals/src/secret.rs index 7be3a511..710d1228 100644 --- a/seals/src/secret.rs +++ b/seals/src/secret.rs @@ -24,6 +24,9 @@ use std::str::FromStr; use amplify::{Bytes32, Wrapper}; use baid58::{Baid58ParseError, Chunking, FromBaid58, ToBaid58, CHUNKING_32CHECKSUM}; +use commit_verify::{CommitmentId, Conceal}; + +use crate::txout::{BlindSeal, SealTxid}; /// Confidential version of transaction outpoint-based single-use-seal #[derive(Wrapper, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, From)] @@ -43,6 +46,13 @@ pub struct SecretSeal( Bytes32, ); +impl Conceal for BlindSeal { + type Concealed = SecretSeal; + + #[inline] + fn conceal(&self) -> Self::Concealed { self.commitment_id() } +} + impl ToBaid58<32> for SecretSeal { const HRI: &'static str = "utxob"; const CHUNKING: Option = CHUNKING_32CHECKSUM; diff --git a/seals/src/txout/blind.rs b/seals/src/txout/blind.rs index 4a29bfd5..3c0e45e4 100644 --- a/seals/src/txout/blind.rs +++ b/seals/src/txout/blind.rs @@ -27,13 +27,14 @@ use std::str::FromStr; use amplify::hex; use bc::{Outpoint, Txid, Vout}; +use commit_verify::{CommitStrategy, CommitmentId}; use dbc::MethodParseError; use rand::{thread_rng, RngCore}; use strict_encoding::{StrictDecode, StrictDumb, StrictEncode}; use super::{CloseMethod, WitnessVoutError}; use crate::txout::{SealTxid, TxPtr, TxoSeal}; -use crate::SealCloseMethod; +use crate::{SealCloseMethod, SecretSeal}; /// Seal type which can be blinded and chained with other seals. pub type ChainBlindSeal = BlindSeal; @@ -48,8 +49,6 @@ pub type SingleBlindSeal = BlindSeal; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)] #[strict_type(lib = dbc::LIB_NAME_BPCORE)] -#[derive(CommitEncode)] -#[commit_encode(conceal, strategy = strict)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate = "serde_crate"))] pub struct BlindSeal { /// Commitment to the specific seal close method [`CloseMethod`] which must @@ -73,6 +72,15 @@ pub struct BlindSeal { pub blinding: u64, } +impl CommitStrategy for BlindSeal { + type Strategy = commit_verify::strategies::Strict; +} + +impl CommitmentId for BlindSeal { + const TAG: [u8; 32] = *b"urn:lnpbp:bp:seal:blind#29122023"; + type Id = SecretSeal; +} + impl TryFrom<&BlindSeal> for Outpoint { type Error = WitnessVoutError; From 1d7b50834dc40d84b093ede000de9ad38a9e0996 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sat, 30 Dec 2023 01:14:18 +0100 Subject: [PATCH 12/13] core: fix feature gates for strict encoding --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 28be4949..45e54db1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,7 +50,6 @@ pub extern crate seals; #[cfg(feature = "stl")] #[macro_use] extern crate amplify; -#[cfg(feature = "stl")] #[macro_use] extern crate strict_encoding; #[cfg(feature = "serde")] From 4c46acd04acfc45b25ef02a443fce6771d52c32d Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sat, 30 Dec 2023 08:08:27 +0100 Subject: [PATCH 13/13] release v0.11.0-beta.3 --- Cargo.lock | 26 +++++++++++++++----------- Cargo.toml | 16 ++++++---------- consensus/src/coding.rs | 3 +-- consensus/src/segwit.rs | 4 +--- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 316a6abc..49c8f18e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "bp-core" -version = "0.11.0-beta.2" +version = "0.11.0-beta.3" dependencies = [ "amplify", "bp-consensus", @@ -197,7 +197,7 @@ dependencies = [ [[package]] name = "bp-dbc" -version = "0.11.0-beta.2" +version = "0.11.0-beta.3" dependencies = [ "amplify", "base85", @@ -210,7 +210,7 @@ dependencies = [ [[package]] name = "bp-seals" -version = "0.11.0-beta.2" +version = "0.11.0-beta.3" dependencies = [ "amplify", "baid58", @@ -267,7 +267,8 @@ dependencies = [ [[package]] name = "commit_encoding_derive" version = "0.10.0" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#2d3a0a2981409c493067edfc94338088884b1aa7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00033f14d67c4169d588f085ea2faeb7b610cf03a74d42ea09eeba31abef2047" dependencies = [ "amplify", "amplify_syn", @@ -278,8 +279,9 @@ dependencies = [ [[package]] name = "commit_verify" -version = "0.11.0-beta.2" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#2d3a0a2981409c493067edfc94338088884b1aa7" +version = "0.11.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e001679b9be6a5df24facdae179e6ba1cffb503c875d691eac024db8d0f8d1" dependencies = [ "amplify", "commit_encoding_derive", @@ -654,17 +656,18 @@ dependencies = [ [[package]] name = "single_use_seals" -version = "0.11.0-beta.2" +version = "0.11.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c30647a1342641c45ca7c1dcd5ae7db16533b86744e827c84cfed875db2de3fe" +checksum = "1b14ebe6be1e12070208a6f2ceb49f946d835b1f7dfb809a4db025de8f5ffe0a" dependencies = [ "amplify_derive", ] [[package]] name = "strict_encoding" -version = "2.6.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=phantom#2123237a512bbe28e8e419e7d4f899dfedfa758c" +version = "2.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa76decc8ac190a56ba7857c023b69ed52b781ed974c5a181eac62cdbfc99521" dependencies = [ "amplify", "half", @@ -674,7 +677,8 @@ dependencies = [ [[package]] name = "strict_encoding_derive" version = "2.0.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=phantom#2123237a512bbe28e8e419e7d4f899dfedfa758c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37064ec285e2a633465eb525c8698eea51373dee889fe310e0d32df8343e7f4f" dependencies = [ "amplify_syn", "heck", diff --git a/Cargo.toml b/Cargo.toml index 82978110..336674b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ default-members = [ ] [workspace.package] -version = "0.11.0-beta.2" +version = "0.11.0-beta.3" authors = ["Dr Maxim Orlovsky "] homepage = "https://github.com/BP-WG" repository = "https://github.com/BP-WG/bp-core" @@ -23,13 +23,13 @@ license = "Apache-2.0" [workspace.dependencies] amplify = "4.5.0" -strict_encoding = "2.6.1" +strict_encoding = ">=2.6.2" strict_types = "1.6.3" -commit_verify = "0.11.0-beta.2" -single_use_seals = "0.11.0-beta.2" +commit_verify = "0.11.0-beta.3" +single_use_seals = "0.11.0-beta.3" bp-consensus = { version = "0.11.0-beta.3", path = "consensus" } -bp-dbc = { version = "0.11.0-beta.2", path = "./dbc" } -bp-seals = { version = "0.11.0-beta.2", path = "./seals" } +bp-dbc = { version = "0.11.0-beta.3", path = "./dbc" } +bp-seals = { version = "0.11.0-beta.3", path = "./seals" } secp256k1 = { version = "0.28.0", features = ["global-context"] } serde_crate = { package = "serde", version = "1", features = ["derive"] } @@ -81,7 +81,3 @@ stl = ["strict_types", "strict_types/base64", "bp-consensus/stl", "commit_verify [package.metadata.docs.rs] features = [ "all" ] - -[patch.crates-io] -strict_encoding = { git = "https://github.com/strict-types/strict-encoding", branch = "phantom" } -commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.11" } diff --git a/consensus/src/coding.rs b/consensus/src/coding.rs index 93f2a7e7..32290e87 100644 --- a/consensus/src/coding.rs +++ b/consensus/src/coding.rs @@ -146,8 +146,7 @@ mod _serde { }) } else { let bytes = Vec::::deserialize(deserializer)?; - Self::try_from(bytes) - .map_err(|_| D::Error::custom("invalid script length exceeding 4GB")) + Ok(Self::from(bytes)) } } } diff --git a/consensus/src/segwit.rs b/consensus/src/segwit.rs index 64853c7a..a6469da6 100644 --- a/consensus/src/segwit.rs +++ b/consensus/src/segwit.rs @@ -394,9 +394,7 @@ impl Witness { } pub fn from_consensus_stack(witness: impl IntoIterator>) -> Witness { - let iter = witness.into_iter().map(|vec| { - ByteStr::try_from(vec).expect("witness stack element length exceeds 2^32 bytes") - }); + let iter = witness.into_iter().map(ByteStr::from); let stack = VarIntArray::try_from_iter(iter).expect("witness stack size exceeds 2^32 elements"); Witness(stack)