diff --git a/Cargo.lock b/Cargo.lock index 5dca1c91..e286cd63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,13 +4,13 @@ version = 4 [[package]] name = "aes" -version = "0.8.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +checksum = "f8eb277bec05f56a0e0591f155a484cbd0f4f07ff2905051a48c72f004f7ed58" dependencies = [ - "cfg-if", "cipher", - "cpufeatures 0.2.17", + "cpubits", + "cpufeatures", "zeroize", ] @@ -52,21 +52,12 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "base58ck" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6a87a8367e7a4248c8dfd783c37ef492bca1307cd4b21b4cfad9cfd15bf060" -dependencies = [ - "bitcoin-internals 0.5.0", - "bitcoin_hashes 0.20.0", -] - -[[package]] -name = "bitcoin-consensus-encoding" -version = "0.1.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d7ca3dc8ff835693ad73bf1596240c06f974a31eeb3f611aaedf855f1f2725" +checksum = "df540278d807651653f9b6f21e18903d790d7769eadfbc0dc4df0a141260318f" dependencies = [ - "bitcoin-internals 0.5.0", + "bitcoin-internals 0.6.0", + "bitcoin_hashes", ] [[package]] @@ -104,10 +95,10 @@ version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82e12cb1814d037edbd667554c2c0e6b067db72c83ee935b645a6b5829aca908" dependencies = [ - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "bitcoin-internals 0.6.0", "bitcoin-units", - "bitcoin_hashes 1.2.0", + "bitcoin_hashes", "hex-conservative 1.3.0", "serde", ] @@ -118,29 +109,18 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ae6dcb008158c2bdbe698470280439844be5f640310e4f5d6ef0a0209e066c2" dependencies = [ - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "bitcoin-internals 0.5.0", "serde", ] -[[package]] -name = "bitcoin_hashes" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a45c2b41c457a9a9e4670422fcbdf109afb3b22bc920b4045e8bdfd788a3d" -dependencies = [ - "bitcoin-consensus-encoding 0.1.0", - "bitcoin-internals 0.5.0", - "hex-conservative 0.3.2", -] - [[package]] name = "bitcoin_hashes" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5304e53726dbe5f93141535e102ed97b5bf4714fbecefdda8f9fb98d7fdaff0e" dependencies = [ - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "bitcoin-internals 0.6.0", "hex-conservative 1.3.0", "serde", @@ -152,15 +132,6 @@ version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - [[package]] name = "block-buffer" version = "0.12.1" @@ -269,11 +240,11 @@ dependencies = [ [[package]] name = "cipher" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" dependencies = [ - "crypto-common 0.1.6", + "crypto-common", "inout", ] @@ -340,13 +311,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] -name = "cpufeatures" -version = "0.2.17" +name = "cpubits" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" [[package]] name = "cpufeatures" @@ -388,16 +356,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - [[package]] name = "crypto-common" version = "0.2.2" @@ -415,9 +373,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23" dependencies = [ "cfg-if", - "cpufeatures 0.3.1", + "cpufeatures", "curve25519-dalek-derive", - "digest 0.11.3", + "digest", "fiat-crypto", "rand_core", "rustc_version", @@ -440,7 +398,7 @@ dependencies = [ name = "dash-dev" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "built", "cfg-if", "chrono", @@ -467,12 +425,11 @@ dependencies = [ name = "dash-num" version = "0.1.0-beta" dependencies = [ - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "dash-dev", "dash-types", "divan", "hex-conservative 1.3.0", - "hex-literal", "rstest", "serde", ] @@ -481,7 +438,7 @@ dependencies = [ name = "dash-p2p-core" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "bitcoin-internals 0.6.0", "cfg-if", "dash-dev", @@ -500,14 +457,14 @@ dependencies = [ name = "dash-params" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "bitcoin-primitives", "bitcoin-units", "dash-num", "dash-primitives", "dash-script", "dash-types", - "hex-literal", + "hex-conservative 1.3.0", "rstest", ] @@ -517,8 +474,8 @@ version = "0.1.0-beta" dependencies = [ "aes", "base58ck", - "bitcoin-consensus-encoding 1.2.0", - "bitcoin_hashes 1.2.0", + "bitcoin-consensus-encoding", + "bitcoin_hashes", "blst", "cfg-if", "dash-dev", @@ -534,7 +491,7 @@ dependencies = [ "rstest", "secp256k1", "serde", - "sha2 0.10.9", + "sha2", "subtle", "zeroize", ] @@ -545,7 +502,7 @@ version = "0.0.0" dependencies = [ "dash-dev", "divan", - "hex-literal", + "hex-conservative 1.3.0", "rstest", ] @@ -553,11 +510,11 @@ dependencies = [ name = "dash-primitives" version = "0.0.0" dependencies = [ - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "bitcoin-internals 0.6.0", "bitcoin-primitives", "bitcoin-units", - "bitcoin_hashes 1.2.0", + "bitcoin_hashes", "cfg-if", "dash-dev", "dash-num", @@ -566,7 +523,6 @@ dependencies = [ "dash-script", "dash-types", "hex-conservative 1.3.0", - "hex-literal", "libm", "rstest", "serde", @@ -577,7 +533,7 @@ name = "dash-script" version = "0.0.0" dependencies = [ "base58ck", - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "dash-num", "dash-pkc", "dash-types", @@ -591,9 +547,9 @@ name = "dash-types" version = "0.1.0-beta" dependencies = [ "base58ck", - "bitcoin-consensus-encoding 1.2.0", + "bitcoin-consensus-encoding", "bitcoin-primitives", - "bitcoin_hashes 1.2.0", + "bitcoin_hashes", "cfg-if", "ciborium", "dash-types-marker", @@ -613,24 +569,14 @@ dependencies = [ "xxhash-rust", ] -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "crypto-common 0.1.6", -] - [[package]] name = "digest" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.12.1", - "crypto-common 0.2.2", + "block-buffer", + "crypto-common", ] [[package]] @@ -687,7 +633,7 @@ dependencies = [ "curve25519-dalek", "ed25519", "rand_core", - "sha2 0.11.0", + "sha2", "signature", "subtle", "zeroize", @@ -800,16 +746,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.14.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "getrandom" version = "0.4.3" @@ -899,12 +835,6 @@ dependencies = [ "arrayvec", ] -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - [[package]] name = "hybrid-array" version = "0.4.15" @@ -1100,11 +1030,11 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.4" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" dependencies = [ - "generic-array", + "hybrid-array", ] [[package]] @@ -1553,17 +1483,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha2" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" -dependencies = [ - "cfg-if", - "cpufeatures 0.2.17", - "digest 0.10.7", -] - [[package]] name = "sha2" version = "0.11.0" @@ -1571,8 +1490,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" dependencies = [ "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", + "cpufeatures", + "digest", ] [[package]] @@ -1814,12 +1733,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - [[package]] name = "wasm-bindgen" version = "0.2.126" diff --git a/Cargo.toml b/Cargo.toml index e1f064b4..162981ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,14 +14,17 @@ members = [ resolver = "3" [workspace.dependencies] -base58ck = { version = "0.4.0", default-features = false } +base58ck = { version = "0.5.0", default-features = false } bitcoin_hashes = { version = "1.2.0", default-features = false } bitcoin-consensus-encoding = { version = "1.2.0", default-features = false } bitcoin-internals = { version = "0.6.0", default-features = false } bitcoin-primitives = { version = "0.103.0", default-features = false } bitcoin-units = { version = "0.5.0", default-features = false } +divan = "0.1" hex-conservative = { version = "1.3", default-features = false } rand_core = { version = "0.10.1", default-features = false } +rstest = "0.25" +serde = { version = "1", default-features = false } subtle = { version = "2.6.1", default-features = false } zeroize = { version = "1.9.0", default-features = false } diff --git a/deny.toml b/deny.toml index e2f148e3..48a924c7 100644 --- a/deny.toml +++ b/deny.toml @@ -5,6 +5,9 @@ all-features = true yanked = "deny" [bans] +deny = [ + { crate = "hex-literal", reason = "use `hex_conservative` instead" }, +] multiple-versions = "warn" [licenses] diff --git a/maint/codeql/rust/policy.model.yml b/maint/codeql/rust/policy.model.yml index 6712761d..6bea1976 100644 --- a/maint/codeql/rust/policy.model.yml +++ b/maint/codeql/rust/policy.model.yml @@ -35,7 +35,7 @@ extensions: # Crate-level re-exports a macro expands into, kept out of the public API - ["", "__private", "", ""] # Emits types relying on traits defined by a dependency, part of public API - - ["dash-num", "", "dash_types", "Numeric"] + - ["dash-num", "__deps", "dash_types", ""] # Emits types relying on types or traits defined by a dependency, part of public API - ["dash-pkc", "__deps", "blst", ""] - ["dash-pkc", "__deps", "dash_num", ""] @@ -55,4 +55,4 @@ extensions: # Sub-crate isolation demands re-exports, part of public API - ["dash-types", "", "dash_types_marker", ""] # Emits types relying on types or traits defined by a dependency, part of public API - - ["dash-types", "", "zeroize", ""] + - ["dash-types", "__deps", "zeroize", ""] diff --git a/maint/lint/lint_cargo.py b/maint/lint/lint_cargo.py index 6db3988a..ada9c227 100755 --- a/maint/lint/lint_cargo.py +++ b/maint/lint/lint_cargo.py @@ -78,17 +78,17 @@ def shorten(out: str, err: str) -> None: ) -def _check_yanked(repo_root: Path) -> int | None: - """Fail on a yanked release, or None when cargo-deny is absent.""" +def _check_deny(repo_root: Path) -> int | None: + """Fail on a yanked or banned crate, or None when cargo-deny is absent.""" try: deny_bin = require_bin("cargo-deny") except FileNotFoundError as e: - print(f"{e}, skipping the yanked check", file=sys.stderr) + print(f"{e}, skipping the yanked and banned check", file=sys.stderr) return None - print("checking yanked: every crate the graph resolves") + print("checking yanked and banned: every crate the graph resolves") result = subprocess.run( # noqa: S603 - [deny_bin, "check", "advisories"], + [deny_bin, "check", "--hide-inclusion-graph", "advisories", "bans"], capture_output=True, check=False, cwd=str(repo_root), @@ -101,7 +101,7 @@ def _check_yanked(repo_root: Path) -> int | None: def main() -> int: args = declare_verbs( - "Validate the crate graph against yanked releases.", + "Validate the crate graph against yanked releases and banned crates.", { "check": "report every fault, changing nothing", "apply": f"also rewrite TOML this branch changed vs {DEFAULT_BASE}", @@ -114,7 +114,7 @@ def main() -> int: verdicts: list[int | None] = [ _check_format(repo_root, fix=fix, only=only), - _check_yanked(repo_root), + _check_deny(repo_root), ] ran = [v for v in verdicts if v is not None] if not ran: diff --git a/pkgs/dev/Cargo.toml b/pkgs/dev/Cargo.toml index b8854fe0..ed20b4e8 100644 --- a/pkgs/dev/Cargo.toml +++ b/pkgs/dev/Cargo.toml @@ -82,7 +82,7 @@ clap = { version = "4", default-features = false, features = [ indicatif = { version = "0.18", default-features = false, optional = true } json5 = { version = "0.4", optional = true } rayon = { version = "1", optional = true } -serde = { version = "1", default-features = false, features = [ +serde = { workspace = true, features = [ "derive", "alloc", ], optional = true } diff --git a/pkgs/dev/src/bin/bsdk_util/bspcheck.rs b/pkgs/dev/src/bin/bsdk_util/bspcheck.rs index af5a7552..cfd5d480 100644 --- a/pkgs/dev/src/bin/bsdk_util/bspcheck.rs +++ b/pkgs/dev/src/bin/bsdk_util/bspcheck.rs @@ -11,7 +11,8 @@ use crate::policy; use crate::Application; use dash_primitives::{Block, BlockHash, BlockInvalid}; -use dash_types::codec::{BaseCodec, Checkable, DecodeError}; +use dash_types::codec::{BaseCodec, DecodeError}; +use dash_types::Checkable; use indicatif::{ProgressBar, ProgressStyle}; use rayon::prelude::*; diff --git a/pkgs/dev/src/lambda.rs b/pkgs/dev/src/lambda.rs index cae024e7..ea1e0b7a 100644 --- a/pkgs/dev/src/lambda.rs +++ b/pkgs/dev/src/lambda.rs @@ -10,7 +10,8 @@ use crate::prelude::*; use bitcoin_consensus_encoding::{decode_from_slice, encode_to_vec, Decode, Decoder, Encode}; use dash_primitives::{Transaction, TxHash}; -use dash_types::codec::{BaseCodec, Checkable, Hashable}; +use dash_types::codec::BaseCodec; +use dash_types::{Checkable, Hashable}; use core::fmt::{Debug, Display}; diff --git a/pkgs/num/CHANGELOG.md b/pkgs/num/CHANGELOG.md index 376994fe..36550597 100644 --- a/pkgs/num/CHANGELOG.md +++ b/pkgs/num/CHANGELOG.md @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Removed - `ParseHexError` has moved to `dash-types` as `dash_types::ParseHexError`. +- The `dash_types::Numeric` re-export in favour of a wholesale crate re-export. `dash_num::Numeric` imports must switch + to `dash_num::__deps::dash_types::Numeric` or depend on `dash-types` directly. ## [0.1.0-beta] - 2026-09-14 diff --git a/pkgs/num/Cargo.toml b/pkgs/num/Cargo.toml index 1f3391b8..bd90bf6d 100644 --- a/pkgs/num/Cargo.toml +++ b/pkgs/num/Cargo.toml @@ -49,17 +49,16 @@ serde = [ bitcoin-consensus-encoding = { workspace = true, optional = true } dash-types = { version = "0.1.0-beta", path = "../types", default-features = false } hex-conservative = { workspace = true } -serde = { version = "1", default-features = false, features = [ +serde = { workspace = true, features = [ "derive", "alloc", ], optional = true } [dev-dependencies] dash-dev = { path = "../dev", features = ["full"] } -divan = "0.1" -hex-literal = "0.4" -rstest = "0.25" -serde = { version = "1", features = ["derive"] } +divan = { workspace = true } +rstest = { workspace = true } +serde = { workspace = true, features = ["derive", "std"] } [[test]] name = "hash" diff --git a/pkgs/num/src/arith256.rs b/pkgs/num/src/arith256.rs index 198f6a58..398ffa52 100644 --- a/pkgs/num/src/arith256.rs +++ b/pkgs/num/src/arith256.rs @@ -108,7 +108,7 @@ impl Arith256 { /// Construct from big-endian bytes (consensus display order). /// - /// This is the natural byte order produced by `hex_literal::hex!()` when + /// This is the natural byte order produced by `hex_conservative::hex!()` when /// given a consensus hex value. Internally the value is stored /// little-endian, so this reverses the input before decoding. /// diff --git a/pkgs/num/src/hash.rs b/pkgs/num/src/hash.rs index 078bb753..b0b7ff3b 100644 --- a/pkgs/num/src/hash.rs +++ b/pkgs/num/src/hash.rs @@ -87,7 +87,7 @@ impl HashBlob { /// Construct from big-endian bytes (consensus display order). /// - /// This is the natural byte order produced by `hex_literal::hex!()` when + /// This is the natural byte order produced by `hex_conservative::hex!()` when /// given a block hash or other consensus hex value. Internally the bytes /// are stored little-endian, so this reverses the input. #[inline] diff --git a/pkgs/num/src/lib.rs b/pkgs/num/src/lib.rs index 0f75d3e2..932ec2e2 100644 --- a/pkgs/num/src/lib.rs +++ b/pkgs/num/src/lib.rs @@ -20,18 +20,18 @@ mod compact; mod hash; mod util; +#[doc(hidden)] +pub mod __deps { + pub use dash_types; +} #[doc(hidden)] pub mod __private { #[cfg(feature = "codec")] pub use bitcoin_consensus_encoding; - pub use dash_types; #[cfg(feature = "serde")] pub use serde; } -pub use crate::arith256::Arith256; -pub use crate::compact::{CompactTarget, DecodedTarget}; -pub use crate::hash::{Hash160, Hash256, HashBlob}; - -// TODO(kwvg): move to mod __deps with crate-level export -pub use dash_types::Numeric; +pub use arith256::Arith256; +pub use compact::{CompactTarget, DecodedTarget}; +pub use hash::{Hash160, Hash256, HashBlob}; diff --git a/pkgs/num/src/util.rs b/pkgs/num/src/util.rs index ea5fbfe9..9e92f8c9 100644 --- a/pkgs/num/src/util.rs +++ b/pkgs/num/src/util.rs @@ -50,20 +50,20 @@ macro_rules! make_hash { // The codec half, split out for gating with `cfg_codec!`. (@codec $len:literal, $name:ident) => { $crate::cfg_codec! { - impl $crate::__private::dash_types::codec::BaseCodec for $name { + impl $crate::__deps::dash_types::codec::BaseCodec for $name { fn decode( data: &mut &[u8], - ) -> Result { - $crate::__private::dash_types::codec::take::<$len>(data) - .map(::from_lendian) + ) -> Result { + $crate::__deps::dash_types::codec::take::<$len>(data) + .map(::from_lendian) } - fn encode(&self, buf: &mut impl $crate::__private::dash_types::codec::EncodeBuf) { + fn encode(&self, buf: &mut impl $crate::__deps::dash_types::codec::EncodeBuf) { buf.extend_from_slice(self.as_bytes()); } } - $crate::__private::dash_types::impl_type!($name); + $crate::__deps::dash_types::impl_type!($name); } }; ( @@ -75,7 +75,7 @@ macro_rules! make_hash { $(#[$attr])* #[derive( Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, - $crate::__private::dash_types::type_id::TypeId, + $crate::__deps::dash_types::type_id::TypeId, )] pub struct $name($crate::HashBlob<$len>); } else { @@ -118,17 +118,17 @@ macro_rules! make_hash { /// Parse from a big-endian hex string. #[inline] - pub fn from_hex(s: &str) -> Result { + pub fn from_hex(s: &str) -> Result { <$crate::HashBlob<$len>>::from_hex(s).map(Self) } } - impl $crate::__private::dash_types::Numeric for $name { + impl $crate::__deps::dash_types::Numeric for $name { type Base = $crate::HashBlob<$len>; type Bytes = [u8; $len]; - const ZERO: Self = Self(<$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::ZERO); + const ZERO: Self = Self(<$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::ZERO); #[inline] fn from_base(v: $crate::HashBlob<$len>) -> Self { @@ -142,28 +142,28 @@ macro_rules! make_hash { #[inline] fn from_lendian(bytes: [u8; $len]) -> Self { - Self(<$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::from_lendian(bytes)) + Self(<$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::from_lendian(bytes)) } #[inline] fn to_lendian(&self) -> [u8; $len] { - <$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::to_lendian(&self.0) + <$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::to_lendian(&self.0) } #[inline] fn from_bendian(bytes: [u8; $len]) -> Self { - Self(<$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::from_bendian(bytes)) + Self(<$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::from_bendian(bytes)) } #[inline] fn to_bendian(&self) -> [u8; $len] { - <$crate::HashBlob<$len> as $crate::__private::dash_types::Numeric>::to_bendian(&self.0) + <$crate::HashBlob<$len> as $crate::__deps::dash_types::Numeric>::to_bendian(&self.0) } } impl Default for $name { #[inline] - fn default() -> Self { ::ZERO } + fn default() -> Self { ::ZERO } } impl ::core::fmt::Display for $name { @@ -191,17 +191,17 @@ macro_rules! make_hash { } impl ::core::str::FromStr for $name { - type Err = $crate::__private::dash_types::ParseHexError; + type Err = $crate::__deps::dash_types::ParseHexError; fn from_str(s: &str) -> Result { Self::from_hex(s) } } - $crate::__private::dash_types::type_cvrt!(From<[u8; $len]> for $name, |b| ::from_lendian(*b)); - $crate::__private::dash_types::type_cvrt!(From<$name> for [u8; $len], |h| $crate::__private::dash_types::Numeric::to_lendian(h)); - $crate::__private::dash_types::type_cvrt!(From<$crate::HashBlob<$len>> for $name, |h| Self(*h)); - $crate::__private::dash_types::type_cvrt!(From<$name> for $crate::HashBlob<$len>, |h| h.0); + $crate::__deps::dash_types::type_cvrt!(From<[u8; $len]> for $name, |b| ::from_lendian(*b)); + $crate::__deps::dash_types::type_cvrt!(From<$name> for [u8; $len], |h| $crate::__deps::dash_types::Numeric::to_lendian(h)); + $crate::__deps::dash_types::type_cvrt!(From<$crate::HashBlob<$len>> for $name, |h| Self(*h)); + $crate::__deps::dash_types::type_cvrt!(From<$name> for $crate::HashBlob<$len>, |h| h.0); impl AsRef<[u8]> for $name { #[inline] diff --git a/pkgs/num/tests/arith.rs b/pkgs/num/tests/arith.rs index 718ce86b..d855c102 100644 --- a/pkgs/num/tests/arith.rs +++ b/pkgs/num/tests/arith.rs @@ -10,7 +10,7 @@ use dash_num::{Arith256, Hash256}; use dash_types::Numeric; -use hex_literal::hex; +use hex_conservative::hex; use rstest::*; use core::str::FromStr; diff --git a/pkgs/num/tests/hash.rs b/pkgs/num/tests/hash.rs index c43ac0a9..00789c31 100644 --- a/pkgs/num/tests/hash.rs +++ b/pkgs/num/tests/hash.rs @@ -10,7 +10,7 @@ use dash_num::{Hash160, Hash256}; use dash_types::{Numeric, ParseHexError}; -use hex_literal::hex; +use hex_conservative::hex; use rstest::*; use core::str::FromStr; diff --git a/pkgs/num/tests/serde.rs b/pkgs/num/tests/serde.rs index e5fce87f..dee56640 100644 --- a/pkgs/num/tests/serde.rs +++ b/pkgs/num/tests/serde.rs @@ -9,7 +9,7 @@ use dash_dev::{assert_cbor_raw, assert_json_rt, from_json, json_rejects, to_json}; use dash_num::{Arith256, CompactTarget, Hash160, Hash256}; use dash_types::Numeric; -use hex_literal::hex; +use hex_conservative::hex; #[test] fn hash256_json_roundtrip() { diff --git a/pkgs/p2p_core/Cargo.toml b/pkgs/p2p_core/Cargo.toml index bdf69975..96ce260b 100644 --- a/pkgs/p2p_core/Cargo.toml +++ b/pkgs/p2p_core/Cargo.toml @@ -39,7 +39,7 @@ dash-primitives = { version = "0.0.0", path = "../primitives" } dash-types = { version = "0.1.0-beta", path = "../types", default-features = false, features = [ "codec", ] } -serde = { version = "1", default-features = false, features = [ +serde = { workspace = true, features = [ "alloc", "derive", ], optional = true } @@ -47,7 +47,7 @@ serde = { version = "1", default-features = false, features = [ [dev-dependencies] dash-dev = { version = "0.0.0", path = "../dev", features = ["full"] } hex-conservative = { workspace = true, features = ["std"] } -rstest = "0.25" +rstest = { workspace = true } [lints] workspace = true diff --git a/pkgs/p2p_core/src/msg/headers2.rs b/pkgs/p2p_core/src/msg/headers2.rs index 3d7cc8f3..c519821d 100644 --- a/pkgs/p2p_core/src/msg/headers2.rs +++ b/pkgs/p2p_core/src/msg/headers2.rs @@ -11,9 +11,9 @@ use crate::prelude::*; use crate::version::ProtocolVersion; use dash_primitives::{hash_impl, BlockHash, BlockHeader, MerkleRoot}; -use dash_types::codec::{BaseCodec, DecodeError, EncodeBuf, Hashable}; +use dash_types::codec::{BaseCodec, DecodeError, EncodeBuf}; use dash_types::type_id::{TypeId, Unencodable}; -use dash_types::CompactSize; +use dash_types::{CompactSize, Hashable}; /// Maximum headers per message. const MAX_HEADERS: usize = 2_000; diff --git a/pkgs/params/Cargo.toml b/pkgs/params/Cargo.toml index 9461bedf..3dc8ba48 100644 --- a/pkgs/params/Cargo.toml +++ b/pkgs/params/Cargo.toml @@ -23,12 +23,11 @@ dash-script = { version = "0.0.0", path = "../script" } dash-types = { version = "0.1.0-beta", path = "../types", default-features = false, features = [ "codec", ] } -hex-literal = "0.4" +hex-conservative = { workspace = true } [dev-dependencies] bitcoin-consensus-encoding = { workspace = true, features = ["alloc"] } -hex-literal = "0.4" -rstest = "0.25" +rstest = { workspace = true } [lints] workspace = true diff --git a/pkgs/params/src/mainnet.rs b/pkgs/params/src/mainnet.rs index d8f591eb..8fb94c9b 100644 --- a/pkgs/params/src/mainnet.rs +++ b/pkgs/params/src/mainnet.rs @@ -13,7 +13,7 @@ use bitcoin_primitives::script::{ScriptPubKeyBuf, ScriptSigBuf}; use dash_num::{Arith256, Hash256}; use dash_primitives::{Block, BlockHash, BlockHeader, MerkleRoot, OutPoint, Transaction, TxHash, TxIn, TxOut, TxType}; use dash_script::AddrParams; -use hex_literal::hex; +use hex_conservative::hex; /// Returns the mainnet genesis block. pub fn genesis() -> Block { @@ -26,12 +26,12 @@ pub fn genesis() -> Block { index: 0xFFFF_FFFF, }, script_sig: ScriptSigBuf::from_bytes( - hex!( - "04ffff001d01044c5957697265642030392f4a616e2f323031342054686520" - "4772616e64204578706572696d656e7420476f6573204c6976653a204f7665" - "7273746f636b2e636f6d204973204e6f7720416363657074696e6720426974" + hex!(concat!( + "04ffff001d01044c5957697265642030392f4a616e2f323031342054686520", + "4772616e64204578706572696d656e7420476f6573204c6976653a204f7665", + "7273746f636b2e636f6d204973204e6f7720416363657074696e6720426974", "636f696e73" - ) + )) .to_vec(), ), sequence: 0xFFFF_FFFF, @@ -39,11 +39,11 @@ pub fn genesis() -> Block { outputs: vec![TxOut { value: bitcoin_units::Amount::from_btc_u16(50), script_pubkey: ScriptPubKeyBuf::from_bytes( - hex!( - "41040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4" - "d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070" + hex!(concat!( + "41040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4", + "d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070", "ac7b03a9ac" - ) + )) .to_vec(), ), }], diff --git a/pkgs/params/src/regtest.rs b/pkgs/params/src/regtest.rs index 9921295e..72075447 100644 --- a/pkgs/params/src/regtest.rs +++ b/pkgs/params/src/regtest.rs @@ -14,7 +14,7 @@ use dash_num::{Arith256, Hash256}; use dash_primitives::{Block, BlockHash, BlockHeader, MerkleRoot, OutPoint, Transaction, TxHash, TxIn, TxOut, TxType}; use dash_script::AddrParams; use dash_types::Numeric; -use hex_literal::hex; +use hex_conservative::hex; /// Returns the regtest genesis block. pub fn genesis() -> Block { @@ -27,12 +27,12 @@ pub fn genesis() -> Block { index: 0xFFFF_FFFF, }, script_sig: ScriptSigBuf::from_bytes( - hex!( - "04ffff001d01044c5957697265642030392f4a616e2f323031342054686520" - "4772616e64204578706572696d656e7420476f6573204c6976653a204f7665" - "7273746f636b2e636f6d204973204e6f7720416363657074696e6720426974" + hex!(concat!( + "04ffff001d01044c5957697265642030392f4a616e2f323031342054686520", + "4772616e64204578706572696d656e7420476f6573204c6976653a204f7665", + "7273746f636b2e636f6d204973204e6f7720416363657074696e6720426974", "636f696e73" - ) + )) .to_vec(), ), sequence: 0xFFFF_FFFF, @@ -40,11 +40,11 @@ pub fn genesis() -> Block { outputs: vec![TxOut { value: bitcoin_units::Amount::from_btc_u16(50), script_pubkey: ScriptPubKeyBuf::from_bytes( - hex!( - "41040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4" - "d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070" + hex!(concat!( + "41040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4", + "d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070", "ac7b03a9ac" - ) + )) .to_vec(), ), }], diff --git a/pkgs/params/src/test3.rs b/pkgs/params/src/test3.rs index aa3d509f..36ec9ae0 100644 --- a/pkgs/params/src/test3.rs +++ b/pkgs/params/src/test3.rs @@ -14,7 +14,7 @@ use dash_num::{Arith256, Hash256}; use dash_primitives::{Block, BlockHash, BlockHeader, MerkleRoot, OutPoint, Transaction, TxHash, TxIn, TxOut, TxType}; use dash_script::AddrParams; use dash_types::Numeric; -use hex_literal::hex; +use hex_conservative::hex; /// Returns the testnet genesis block. pub fn genesis() -> Block { @@ -27,12 +27,12 @@ pub fn genesis() -> Block { index: 0xFFFF_FFFF, }, script_sig: ScriptSigBuf::from_bytes( - hex!( - "04ffff001d01044c5957697265642030392f4a616e2f323031342054686520" - "4772616e64204578706572696d656e7420476f6573204c6976653a204f7665" - "7273746f636b2e636f6d204973204e6f7720416363657074696e6720426974" + hex!(concat!( + "04ffff001d01044c5957697265642030392f4a616e2f323031342054686520", + "4772616e64204578706572696d656e7420476f6573204c6976653a204f7665", + "7273746f636b2e636f6d204973204e6f7720416363657074696e6720426974", "636f696e73" - ) + )) .to_vec(), ), sequence: 0xFFFF_FFFF, @@ -40,11 +40,11 @@ pub fn genesis() -> Block { outputs: vec![TxOut { value: bitcoin_units::Amount::from_btc_u16(50), script_pubkey: ScriptPubKeyBuf::from_bytes( - hex!( - "41040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4" - "d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070" + hex!(concat!( + "41040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4", + "d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070", "ac7b03a9ac" - ) + )) .to_vec(), ), }], diff --git a/pkgs/params/tests/genesis_valid.rs b/pkgs/params/tests/genesis_valid.rs index fe2c643e..222e18ec 100644 --- a/pkgs/params/tests/genesis_valid.rs +++ b/pkgs/params/tests/genesis_valid.rs @@ -9,7 +9,7 @@ use dash_params::{ChainParams, Network}; use dash_primitives::{Block, BlockHash, MerkleRoot}; use dash_types::{Hashable, Numeric}; -use hex_literal::hex; +use hex_conservative::hex; use rstest::rstest; #[rstest] diff --git a/pkgs/pkc/Cargo.toml b/pkgs/pkc/Cargo.toml index 71d8bad8..8f1739e7 100644 --- a/pkgs/pkc/Cargo.toml +++ b/pkgs/pkc/Cargo.toml @@ -23,7 +23,7 @@ repository.workspace = true rust-version.workspace = true [dependencies] -aes = { version = "0.8", default-features = false, features = [ +aes = { version = "0.9", default-features = false, features = [ "zeroize", ], optional = true } base58ck = { workspace = true, optional = true, features = ["alloc"] } @@ -48,23 +48,23 @@ secp256k1 = { version = "0.33.1", default-features = false, features = [ "alloc", "recovery", ], optional = true } -serde = { version = "1", default-features = false, features = [ +serde = { workspace = true, features = [ "alloc", "derive", ], optional = true } -sha2 = { version = "0.10", default-features = false, optional = true } +sha2 = { version = "0.11", default-features = false, optional = true } subtle = { workspace = true } zeroize = { workspace = true, features = ["alloc", "derive"] } [dev-dependencies] bitcoin-consensus-encoding = { workspace = true, features = ["alloc"] } dash-dev = { path = "../dev", features = ["full"] } -divan = "0.1" +divan = { workspace = true } getrandom = { version = "0.4", features = ["sys_rng"] } hex-conservative = { workspace = true, features = ["std"] } rand_core = { workspace = true } -rstest = "0.25" -serde = { version = "1", features = ["derive"] } +rstest = { workspace = true } +serde = { workspace = true, features = ["derive", "std"] } [features] default = ["codec"] diff --git a/pkgs/pkc/src/aes_cbc.rs b/pkgs/pkc/src/aes_cbc.rs index dd9f89f2..7a2db5c0 100644 --- a/pkgs/pkc/src/aes_cbc.rs +++ b/pkgs/pkc/src/aes_cbc.rs @@ -8,7 +8,7 @@ use crate::prelude::*; -use aes::cipher::{BlockDecrypt, BlockEncrypt, KeyInit}; +use aes::cipher::{BlockCipherDecrypt, BlockCipherEncrypt, KeyInit}; use aes::Aes256; use zeroize::{Zeroize, Zeroizing}; diff --git a/pkgs/pkc/src/ecdsa/public_hash.rs b/pkgs/pkc/src/ecdsa/public_hash.rs index 4e33961e..cdf4becf 100644 --- a/pkgs/pkc/src/ecdsa/public_hash.rs +++ b/pkgs/pkc/src/ecdsa/public_hash.rs @@ -10,7 +10,7 @@ use crate::prelude::*; #[cfg(feature = "codec")] -use base58ck::encode_check; +use base58ck::Base58CkString; use dash_num::make_hash; #[cfg(feature = "codec")] use dash_types::codec::{BaseCodec, EncodeBuf}; @@ -29,6 +29,6 @@ impl EcdsaPkHash { let mut buf = ArrayBuf::<21>::new(); buf.push(prefix); self.encode(&mut buf); - encode_check(&buf.into_array()) + String::from(Base58CkString::encode_unbounded(&buf.into_array()).as_str()) } } diff --git a/pkgs/pkc/src/ecdsa/public_ops.rs b/pkgs/pkc/src/ecdsa/public_ops.rs index 5136e2fa..2ff38e99 100644 --- a/pkgs/pkc/src/ecdsa/public_ops.rs +++ b/pkgs/pkc/src/ecdsa/public_ops.rs @@ -288,7 +288,8 @@ mod tests { use dash_dev::{arr_from_hex, Corpus}; #[cfg(feature = "serde")] use dash_dev::{assert_cbor_raw, assert_json_rt}; - use dash_types::codec::{BaseCodec, Hashable}; + use dash_types::codec::BaseCodec; + use dash_types::Hashable; use rstest::*; use serde::Deserialize; diff --git a/pkgs/pkc/src/ecdsa/secret_bytes.rs b/pkgs/pkc/src/ecdsa/secret_bytes.rs index 4277a87b..e2d3f898 100644 --- a/pkgs/pkc/src/ecdsa/secret_bytes.rs +++ b/pkgs/pkc/src/ecdsa/secret_bytes.rs @@ -11,7 +11,7 @@ use super::Compression; use crate::prelude::*; #[cfg(feature = "codec")] -use base58ck::{decode_check, encode_check}; +use base58ck::{decode_check, Base58CkString}; use dash_types::derive_sbytes; use subtle::ConstantTimeEq; use zeroize::{Zeroize, Zeroizing}; @@ -88,12 +88,14 @@ impl EcdsaSkBytes { let mut buf = Zeroizing::new([0u8; 34]); buf[0] = prefix; buf[1..33].copy_from_slice(&self.inner); - if self.compressed { + let len = if self.compressed { buf[33] = 0x01; - Some(Zeroizing::new(encode_check(&buf[..34]))) + 34 } else { - Some(Zeroizing::new(encode_check(&buf[..33]))) - } + 33 + }; + let wif = Base58CkString::encode_unbounded(&buf[..len]); + Some(Zeroizing::new(String::from(wif.as_str()))) } } @@ -166,24 +168,35 @@ mod tests { assert!(zero.to_wif(0x80).is_none()); } + fn encode_check(data: &[u8]) -> String { + String::from(base58ck::Base58CkString::encode_unbounded(data).as_str()) + } + /// A well-formed WIF carrying the zero scalar, assembled by hand because /// `to_wif` refuses to emit one; `from_wif` must still reject it. fn wif_zero_key() -> String { let mut payload = [0u8; 34]; payload[0] = 0x80; payload[33] = 0x01; - base58ck::encode_check(&payload) + encode_check(&payload) } fn wif_bad_checksum() -> String { let sk = EcdsaSkBytes::from_bytes([0x22u8; ECDSA_SK_LEN], Compression::Compressed); - let mut raw = base58ck::decode(&sk.to_wif(0x80).unwrap()).unwrap(); - *raw.last_mut().unwrap() ^= 0xff; - base58ck::encode(&raw) + let mut wif = String::from(sk.to_wif(0x80).unwrap().as_str()); + let good = base58ck::decode(&wif).unwrap(); + // Swapping the last digit disturbs the low bytes, where the checksum lives + let last = wif.pop().unwrap(); + wif.push(if last == '1' { '2' } else { '1' }); + let bad = base58ck::decode(&wif).unwrap(); + assert_eq!(bad.len(), good.len()); + assert_eq!(bad[..34], good[..34], "payload intact"); + assert_ne!(bad[34..], good[34..], "checksum altered"); + wif } fn wif_wrong_length() -> String { - base58ck::encode_check(&[0x80u8; 32]) + encode_check(&[0x80u8; 32]) } fn wif_bad_compression_byte() -> String { @@ -191,7 +204,7 @@ mod tests { payload[0] = 0x80; payload[1..33].copy_from_slice(&[0x44u8; ECDSA_SK_LEN]); payload[33] = 0x02; - base58ck::encode_check(&payload) + encode_check(&payload) } #[rstest] diff --git a/pkgs/pow/Cargo.toml b/pkgs/pow/Cargo.toml index 78d1d06f..e0ec224f 100644 --- a/pkgs/pow/Cargo.toml +++ b/pkgs/pow/Cargo.toml @@ -18,9 +18,9 @@ simd = [] [dev-dependencies] dash-dev = { version = "0.0.0", path = "../dev", features = ["full"] } -divan = "0.1" -hex-literal = "0.4" -rstest = "0.25" +divan = { workspace = true } +hex-conservative = { workspace = true } +rstest = { workspace = true } [[test]] name = "blake" diff --git a/pkgs/pow/tests/chain.rs b/pkgs/pow/tests/chain.rs index 9c097da2..81ad1e9f 100644 --- a/pkgs/pow/tests/chain.rs +++ b/pkgs/pow/tests/chain.rs @@ -7,18 +7,12 @@ //! Proof of work chained hash tests. use dash_pow::hash; -use hex_literal::hex; +use hex_conservative::hex; use rstest::rstest; #[rstest] -#[case::empty( - &[], - hex!("51b57220908357 6ea221c27e62b4e220 63257571ccb6cc3d c3cd17eb67584eba"), -)] -#[case::single_zero( - &[0u8], - hex!("ad4015a105988678 1a796efe2326c9e6 beb07bcf847f4897 e0f8a3fa24004024"), -)] +#[case::empty(&[], hex!("51b572209083576ea221c27e62b4e22063257571ccb6cc3dc3cd17eb67584eba"))] +#[case::single_zero(&[0u8], hex!("ad4015a1059886781a796efe2326c9e6beb07bcf847f4897e0f8a3fa24004024"))] fn known_hash(#[case] input: &[u8], #[case] expected: [u8; 32]) { let got = hash(input); assert_eq!(got, expected); diff --git a/pkgs/primitives/Cargo.toml b/pkgs/primitives/Cargo.toml index 5a8960fa..1b6a7e05 100644 --- a/pkgs/primitives/Cargo.toml +++ b/pkgs/primitives/Cargo.toml @@ -55,16 +55,15 @@ hex-conservative = { workspace = true, features = [ "alloc", ] } libm = { version = "0.2", default-features = false } -serde = { version = "1", default-features = false, features = [ +serde = { workspace = true, features = [ "alloc", "derive", ], optional = true } [dev-dependencies] dash-dev = { version = "0.0.0", path = "../dev", features = ["full"] } -hex-literal = "0.4" -rstest = "0.25" -serde = { version = "1", features = ["derive"] } +rstest = { workspace = true } +serde = { workspace = true, features = ["derive", "std"] } [lints] workspace = true diff --git a/pkgs/primitives/src/block.rs b/pkgs/primitives/src/block.rs index 0adfc55e..d3c810d8 100644 --- a/pkgs/primitives/src/block.rs +++ b/pkgs/primitives/src/block.rs @@ -13,9 +13,9 @@ use crate::{codec_base, codec_type, hash_impl}; use bitcoin_hashes::sha256d; use dash_num::{make_hash, Arith256, CompactTarget, Hash256}; use dash_pow::hash as pow_hash; -use dash_types::codec::{BaseCodec, Checkable, Hashable}; +use dash_types::codec::BaseCodec; use dash_types::type_id::{TypeId, Unencodable}; -use dash_types::{ArrayBuf, Numeric}; +use dash_types::{ArrayBuf, Checkable, Hashable, Numeric}; use core::fmt; diff --git a/pkgs/primitives/src/codec.rs b/pkgs/primitives/src/codec.rs index 15509707..77e28674 100644 --- a/pkgs/primitives/src/codec.rs +++ b/pkgs/primitives/src/codec.rs @@ -16,7 +16,7 @@ pub const MAX_SPTX_PAYLOAD_SIZE: usize = 10_240; #[macro_export] macro_rules! hash_impl { ($($ty:ty),* $(,)?) => { $( - impl $crate::__private::dash_types::codec::Hashable for $ty { + impl $crate::__private::dash_types::Hashable for $ty { type Hash = $crate::__private::dash_num::Hash256; fn hash(&self) -> Self::Hash { diff --git a/pkgs/primitives/src/gov.rs b/pkgs/primitives/src/gov.rs index c2615ed7..6d3020d3 100644 --- a/pkgs/primitives/src/gov.rs +++ b/pkgs/primitives/src/gov.rs @@ -13,9 +13,9 @@ use crate::{codec_base, hash_impl, TxHash}; use bitcoin_hashes::sha256d; use bitcoin_units::Amount; use dash_num::Hash256; -use dash_types::codec::{BaseCodec, Checkable, Hashable}; +use dash_types::codec::BaseCodec; use dash_types::type_id::{TypeId, Unencodable}; -use dash_types::{enum_map, impl_num, ArrayBuf, Numeric}; +use dash_types::{enum_map, impl_num, ArrayBuf, Checkable, Hashable, Numeric}; use hex_conservative::DisplayHex; use core::fmt; diff --git a/pkgs/primitives/src/payload/assetlock.rs b/pkgs/primitives/src/payload/assetlock.rs index c9fbf125..682baf2e 100644 --- a/pkgs/primitives/src/payload/assetlock.rs +++ b/pkgs/primitives/src/payload/assetlock.rs @@ -11,8 +11,8 @@ use crate::prelude::*; use crate::transaction::TxOut; use dash_script::Recipient; -use dash_types::codec::Checkable; use dash_types::type_id::{TypeId, Unencodable}; +use dash_types::Checkable; use core::fmt; diff --git a/pkgs/primitives/src/payload/assetunlock.rs b/pkgs/primitives/src/payload/assetunlock.rs index 377466b1..b2063822 100644 --- a/pkgs/primitives/src/payload/assetunlock.rs +++ b/pkgs/primitives/src/payload/assetunlock.rs @@ -10,8 +10,8 @@ use super::QuorumHash; use crate::codec::codec_payload; use dash_pkc::bls::{BlsScIetf, BlsSigBytes}; -use dash_types::codec::Checkable; use dash_types::type_id::{TypeId, Unencodable}; +use dash_types::Checkable; use core::fmt; diff --git a/pkgs/primitives/src/payload/cbtx.rs b/pkgs/primitives/src/payload/cbtx.rs index a3c23746..a4e72a81 100644 --- a/pkgs/primitives/src/payload/cbtx.rs +++ b/pkgs/primitives/src/payload/cbtx.rs @@ -11,9 +11,9 @@ use crate::{hash_impl, MerkleRoot}; use bitcoin_units::BlockHeight; use dash_pkc::bls::{BlsScIetf, BlsSigBytes}; -use dash_types::codec::{BaseCodec, Checkable, DecodeError, EncodeBuf}; +use dash_types::codec::{BaseCodec, DecodeError, EncodeBuf}; use dash_types::type_id::{TypeId, Unencodable}; -use dash_types::{CompactSize, Numeric}; +use dash_types::{Checkable, CompactSize, Numeric}; use core::fmt; diff --git a/pkgs/primitives/src/payload/mnhftx.rs b/pkgs/primitives/src/payload/mnhftx.rs index d7cb33b4..7717e6c5 100644 --- a/pkgs/primitives/src/payload/mnhftx.rs +++ b/pkgs/primitives/src/payload/mnhftx.rs @@ -10,8 +10,8 @@ use super::QuorumHash; use crate::codec::codec_payload; use dash_pkc::bls::{BlsScIetf, BlsSigBytes}; -use dash_types::codec::Checkable; use dash_types::type_id::{TypeId, Unencodable}; +use dash_types::Checkable; use core::fmt; diff --git a/pkgs/primitives/src/payload/mod.rs b/pkgs/primitives/src/payload/mod.rs index 0a968110..a2780c70 100644 --- a/pkgs/primitives/src/payload/mod.rs +++ b/pkgs/primitives/src/payload/mod.rs @@ -24,9 +24,8 @@ use crate::prelude::*; use crate::types::{NIError, NIPurpose, NITrait, NetInfoV2}; use dash_num::make_hash; -use dash_types::codec::Checkable; use dash_types::type_id::{TypeId, Unencodable}; -use dash_types::{enum_map, impl_num}; +use dash_types::{enum_map, impl_num, Checkable}; use core::fmt; diff --git a/pkgs/primitives/src/payload/proregtx.rs b/pkgs/primitives/src/payload/proregtx.rs index 1c8b14ed..d0394fa3 100644 --- a/pkgs/primitives/src/payload/proregtx.rs +++ b/pkgs/primitives/src/payload/proregtx.rs @@ -19,9 +19,9 @@ use crate::{hash_impl, TxHash}; use bitcoin_primitives::script::ScriptPubKeyBuf; use dash_pkc::bls::{BlsPkBytes, BlsScIetf}; use dash_script::{PubKeyHash, Recipient}; -use dash_types::codec::{BaseCodec, Checkable, DecodeError, EncodeBuf}; +use dash_types::codec::{BaseCodec, DecodeError, EncodeBuf}; use dash_types::type_id::TypeId; -use dash_types::Numeric; +use dash_types::{Checkable, Numeric}; use core::fmt; diff --git a/pkgs/primitives/src/payload/proupregtx.rs b/pkgs/primitives/src/payload/proupregtx.rs index 3f5326ee..4533edd7 100644 --- a/pkgs/primitives/src/payload/proupregtx.rs +++ b/pkgs/primitives/src/payload/proupregtx.rs @@ -14,8 +14,8 @@ use crate::TxHash; use bitcoin_primitives::script::ScriptPubKeyBuf; use dash_pkc::bls::{BlsPkBytes, BlsScIetf}; use dash_script::{PubKeyHash, Recipient}; -use dash_types::codec::Checkable; use dash_types::type_id::TypeId; +use dash_types::Checkable; use core::fmt; diff --git a/pkgs/primitives/src/payload/prouprevtx.rs b/pkgs/primitives/src/payload/prouprevtx.rs index ca699763..9d8dce16 100644 --- a/pkgs/primitives/src/payload/prouprevtx.rs +++ b/pkgs/primitives/src/payload/prouprevtx.rs @@ -12,8 +12,8 @@ use crate::support::RevocationReason; use crate::TxHash; use dash_pkc::bls::{BlsScIetf, BlsSigBytes}; -use dash_types::codec::Checkable; use dash_types::type_id::TypeId; +use dash_types::Checkable; use core::fmt; diff --git a/pkgs/primitives/src/payload/proupservtx.rs b/pkgs/primitives/src/payload/proupservtx.rs index 2951abfb..49eb0794 100644 --- a/pkgs/primitives/src/payload/proupservtx.rs +++ b/pkgs/primitives/src/payload/proupservtx.rs @@ -15,8 +15,8 @@ use crate::{hash_impl, TxHash}; use bitcoin_primitives::script::ScriptPubKeyBuf; use dash_pkc::bls::{BlsScIetf, BlsSigBytes}; -use dash_types::codec::{BaseCodec, Checkable, DecodeError, EncodeBuf}; -use dash_types::{type_id::TypeId, Numeric}; +use dash_types::codec::{BaseCodec, DecodeError, EncodeBuf}; +use dash_types::{type_id::TypeId, Checkable, Numeric}; use core::fmt; diff --git a/pkgs/primitives/src/payload/quorum.rs b/pkgs/primitives/src/payload/quorum.rs index 1ca90323..05c93383 100644 --- a/pkgs/primitives/src/payload/quorum.rs +++ b/pkgs/primitives/src/payload/quorum.rs @@ -13,9 +13,9 @@ use crate::support::{DynBitset, LlmqType}; use dash_num::make_hash; use dash_pkc::bls::{BlsPkBytes, BlsScIetf, BlsSigBytes}; -use dash_types::codec::{BaseCodec, Checkable, DecodeError, EncodeBuf}; +use dash_types::codec::{BaseCodec, DecodeError, EncodeBuf}; use dash_types::type_id::{TypeId, Unencodable}; -use dash_types::Numeric; +use dash_types::{Checkable, Numeric}; use core::fmt; diff --git a/pkgs/primitives/src/transaction.rs b/pkgs/primitives/src/transaction.rs index 12ce31c2..02fa3d25 100644 --- a/pkgs/primitives/src/transaction.rs +++ b/pkgs/primitives/src/transaction.rs @@ -15,9 +15,9 @@ use bitcoin_hashes::sha256d; use bitcoin_primitives::script::{ScriptPubKeyBuf, ScriptSigBuf}; use bitcoin_units::Amount; use dash_num::make_hash; -use dash_types::codec::{self, BaseCodec, Checkable, DecodeError, EncodeBuf, Hashable}; +use dash_types::codec::{self, BaseCodec, DecodeError, EncodeBuf}; use dash_types::type_id::{TypeId, Unencodable}; -use dash_types::{impl_type, CompactSize, Numeric}; +use dash_types::{impl_type, Checkable, CompactSize, Hashable, Numeric}; use core::fmt; diff --git a/pkgs/primitives/src/types/addrv1.rs b/pkgs/primitives/src/types/addrv1.rs index ac34f8d7..5d28fa85 100644 --- a/pkgs/primitives/src/types/addrv1.rs +++ b/pkgs/primitives/src/types/addrv1.rs @@ -10,9 +10,9 @@ use super::addrv2::{AddrV2, ServiceV2}; use super::netaddr::{NetAddr, NetAddrError, NetworkType}; use crate::hash_impl; -use dash_types::codec::{self, BaseCodec, Checkable, DecodeError, EncodeBuf}; +use dash_types::codec::{self, BaseCodec, DecodeError, EncodeBuf}; use dash_types::type_id::TypeId; -use dash_types::{impl_bytes, impl_type, type_cvrt}; +use dash_types::{impl_bytes, impl_type, type_cvrt, Checkable}; use core::fmt; use core::net::{Ipv4Addr, Ipv6Addr}; @@ -303,7 +303,7 @@ mod tests { use super::*; use crate::prelude::*; - use hex_literal::hex; + use hex_conservative::hex; use rstest::rstest; #[rstest] diff --git a/pkgs/primitives/src/types/addrv2.rs b/pkgs/primitives/src/types/addrv2.rs index e9720422..2d79b505 100644 --- a/pkgs/primitives/src/types/addrv2.rs +++ b/pkgs/primitives/src/types/addrv2.rs @@ -13,8 +13,8 @@ use crate::hash_impl; use crate::prelude::*; use bitcoin_hashes::sha3_256; -use dash_types::codec::{self, BaseCodec, Checkable, DecodeError, EncodeBuf}; -use dash_types::{impl_type, type_cvrt, type_id::TypeId, CompactSize, Numeric}; +use dash_types::codec::{self, BaseCodec, DecodeError, EncodeBuf}; +use dash_types::{impl_type, type_cvrt, type_id::TypeId, Checkable, CompactSize, Numeric}; use core::fmt; use core::net::{Ipv4Addr, Ipv6Addr}; @@ -398,7 +398,7 @@ impl FromStr for ServiceV2 { mod tests { use super::*; - use hex_literal::hex; + use hex_conservative::hex; use rstest::rstest; #[rstest] diff --git a/pkgs/primitives/src/types/netinfo.rs b/pkgs/primitives/src/types/netinfo.rs index d5ef0aaf..27730abf 100644 --- a/pkgs/primitives/src/types/netinfo.rs +++ b/pkgs/primitives/src/types/netinfo.rs @@ -11,10 +11,10 @@ use super::{AddrV2, NetAddrError, ServiceV1, ServiceV2}; use crate::hash_impl; use crate::prelude::*; -use dash_types::codec::{self, BaseCodec, Checkable, DecodeError, EncodeBuf}; +use dash_types::codec::{self, BaseCodec, DecodeError, EncodeBuf}; use dash_types::type_id::{TypeId, Unencodable}; use dash_types::Numeric; -use dash_types::{enum_map, impl_num, impl_type, CompactSize}; +use dash_types::{enum_map, impl_num, impl_type, Checkable, CompactSize}; use core::fmt; @@ -619,38 +619,39 @@ mod tests { use super::*; use crate::types::{AddrV1, AddrV2}; - use dash_types::codec::{BaseCodec, Checkable}; - use hex_literal::hex; + use dash_types::codec::BaseCodec; + use dash_types::Checkable; + use hex_conservative::hex; use rstest::rstest; #[rstest] #[case::ipv4( - &hex!( - "01" // entry_type=Service - "01" // network=ipv4 - "04" // addr_len=4 - "01020304" // addr 1.2.3.4 - "270f" // port=9999 - ), + &hex!(concat!( + "01", // entry_type=Service + "01", // network=ipv4 + "04", // addr_len=4 + "01020304", // addr 1.2.3.4 + "270f", // port=9999 + )), NIEntry::Service(ServiceV2 { addr: AddrV2::Ipv4([1, 2, 3, 4]), port: 9999 }), )] #[case::ipv6( - &hex!( - "01" // entry_type=Service - "02" // network=ipv6 - "10" // addr_len=16 - "00000000000000000000000000000001" // addr ::1 - "270f" // port=9999 - ), + &hex!(concat!( + "01", // entry_type=Service + "02", // network=ipv6 + "10", // addr_len=16 + "00000000000000000000000000000001", // addr ::1 + "270f", // port=9999 + )), NIEntry::Service(ServiceV2 { addr: AddrV2::Ipv6([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]), port: 9999 }), )] #[case::domain( - &hex!( - "02" // entry_type=Domain - "0b" // name_len=11 - "6578616d706c652e636f6d" // "example.com" - "01bb" // port=443 - ), + &hex!(concat!( + "02", // entry_type=Domain + "0b", // name_len=11 + "6578616d706c652e636f6d", // "example.com" + "01bb", // port=443 + )), NIEntry::Domain { name: b"example.com".to_vec(), port: 443 }, )] fn nientry_roundtrip(#[case] wire: &[u8], #[case] expected: NIEntry) { @@ -669,15 +670,15 @@ mod tests { #[rstest] #[case::single_ipv4( - &hex!( - "01" // version=1 - "01" // purpose_count=1 - "00" // purpose=CoreP2p - "01" // entry_count=1 - "01" // entry_type=Service - "0104 01020304" // ipv4 1.2.3.4 - "270f" // port=9999 - ), + &hex!(concat!( + "01", // version=1 + "01", // purpose_count=1 + "00", // purpose=CoreP2p + "01", // entry_count=1 + "01", // entry_type=Service + "0104", "01020304", // ipv4 1.2.3.4 + "270f", // port=9999 + )), NetInfoV2 { version: 1, entries: vec![( @@ -690,20 +691,20 @@ mod tests { }, )] #[case::multi_purpose( - &hex!( - "01" // version=1 - "02" // purpose_count=2 - "00" // purpose=CoreP2p - "01" // entry_count=1 - "01" // entry_type=Service - "0104 c0a80001" // ipv4 192.168.0.1 - "238e" // port=9102 - "02" // purpose=PlatformHttps - "01" // entry_count=1 - "02" // entry_type=Domain - "0b6578616d706c652e636f6d" // "example.com" - "01bb" // port=443 - ), + &hex!(concat!( + "01", // version=1 + "02", // purpose_count=2 + "00", // purpose=CoreP2p + "01", // entry_count=1 + "01", // entry_type=Service + "0104", "c0a80001", // ipv4 192.168.0.1 + "238e", // port=9102 + "02", // purpose=PlatformHttps + "01", // entry_count=1 + "02", // entry_type=Domain + "0b6578616d706c652e636f6d", // "example.com" + "01bb", // port=443 + )), NetInfoV2 { version: 1, entries: vec![ diff --git a/pkgs/script/Cargo.toml b/pkgs/script/Cargo.toml index 5b0d41e7..4802e1b6 100644 --- a/pkgs/script/Cargo.toml +++ b/pkgs/script/Cargo.toml @@ -31,14 +31,14 @@ dash-types = { version = "0.1.0-beta", path = "../types", default-features = fal "bitcoin-primitives", "codec", ] } -serde = { version = "1", default-features = false, features = [ +serde = { workspace = true, features = [ "derive", "alloc", ], optional = true } [dev-dependencies] hex-conservative = { workspace = true, features = ["std"] } -rstest = "0.25" +rstest = { workspace = true } [lints] workspace = true diff --git a/pkgs/script/src/addrs.rs b/pkgs/script/src/addrs.rs index 6c69d95c..cd89276e 100644 --- a/pkgs/script/src/addrs.rs +++ b/pkgs/script/src/addrs.rs @@ -12,8 +12,8 @@ use crate::{opcode::Opcode, PubKeyHash, ScriptHash}; use base58ck::decode_check; use dash_num::Hash160; use dash_pkc::ecdsa::EcdsaPkBytes; -use dash_types::codec::{BaseCodec, EncodeBuf, Hashable}; -use dash_types::{type_cvrt, type_id::Unencodable, Numeric}; +use dash_types::codec::{BaseCodec, EncodeBuf}; +use dash_types::{type_cvrt, type_id::Unencodable, Hashable, Numeric}; /// Network address encoding parameters. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Unencodable)] diff --git a/pkgs/types/CHANGELOG.md b/pkgs/types/CHANGELOG.md index 98fd9324..3440a445 100644 --- a/pkgs/types/CHANGELOG.md +++ b/pkgs/types/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), Callers of `impl_bytes!` without `derive_bytes!` must now write the conversion manually. - As a result, both `make_bytes!` and `make_sbytes!` carry it with `nocodec` tag and without the `codec` feature and callers that wrote the conversion manually for those configurations must drop it. +- The `zeroize` export is moved from the crate root to `__deps`. Callers must switch to `dash_types::__deps::zeroize`. - Types using `derive_bytes!` that implemented `From<&[u8; N]>`, `TryFrom<&[u8]>`, `FromStr`, `LowerHex` or `UpperHex` manually must drop those implementations, as `derive_bytes!` now emits them. - `serialize::hex` writes raw bytes for machine-readable formats instead of emitting a hex-encoded string. @@ -31,6 +32,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - `serialize::str_u64` writes a native `u64` to machine-readable formats. `str_u64` is a workaround for number-precision limitations in JSON and is now contained only for human-readable formats. +### Removed + +- The `codec::Checkable` and `codec::Hashable` compatibility aliases in favour of exports from the crate root. + ### Fixed - `serialize::utf8_lossy`'s serializer and deserializer arms were not in sync, writing valid UTF-8 as a string for diff --git a/pkgs/types/Cargo.toml b/pkgs/types/Cargo.toml index 02dc0610..c9ca54d0 100644 --- a/pkgs/types/Cargo.toml +++ b/pkgs/types/Cargo.toml @@ -61,7 +61,7 @@ cfg-if = "1" dash-types-marker = { version = "0.1.0-beta", path = "marker", optional = true } hex-conservative = { workspace = true } subtle = { workspace = true } -serde = { version = "1", default-features = false, features = [ +serde = { workspace = true, features = [ "derive", "alloc", ], optional = true } @@ -69,8 +69,8 @@ zeroize = { workspace = true } [dev-dependencies] ciborium = "0.2" -rstest = "0.25" -serde = { version = "1", features = ["derive"] } +rstest = { workspace = true } +serde = { workspace = true, features = ["derive", "std"] } [lints] workspace = true diff --git a/pkgs/types/src/adapters.rs b/pkgs/types/src/adapters.rs index 26089efd..96b8c04a 100644 --- a/pkgs/types/src/adapters.rs +++ b/pkgs/types/src/adapters.rs @@ -27,14 +27,14 @@ macro_rules! adapt_codec { #[cfg(feature = "bitcoin-primitives")] pub mod bitcoin_primitives { - use crate::codec::{BaseCodec, EncodeBuf, Hashable}; - use crate::make_bytes; + use crate::codec::{BaseCodec, EncodeBuf}; use crate::prelude::*; use crate::secret::ArrayBuf; + use crate::{make_bytes, Hashable}; // nosemgrep: macro-no-bare-foreign-crate use ::bitcoin_primitives::script::{ScriptBuf, ScriptHashableTag}; - use base58ck::encode_check; + use base58ck::Base58CkString; use bitcoin_hashes::{ripemd160, sha256}; adapt_codec!(, ScriptBuf); @@ -55,7 +55,7 @@ pub mod bitcoin_primitives { let mut buf = ArrayBuf::<21>::new(); buf.push(prefix); self.encode(&mut buf); - encode_check(&buf.into_array()) + String::from(Base58CkString::encode_unbounded(&buf.into_array()).as_str()) } } diff --git a/pkgs/types/src/codec.rs b/pkgs/types/src/codec.rs index f68d2dd5..3cbe0426 100644 --- a/pkgs/types/src/codec.rs +++ b/pkgs/types/src/codec.rs @@ -8,14 +8,11 @@ use crate::prelude::*; use crate::type_id::TypeId; -use crate::CompactSize; +use crate::{CompactSize, Hashable}; use core::convert::Infallible; use core::fmt; -// TODO(kwvg): remove compatibility alias -pub use crate::traits::{Checkable, Hashable}; // nosemgrep: use-pub-roots-only - /// Maximum bytes to pre-allocate per batch when deserializing vectors. const MAX_VECTOR_ALLOCATE: usize = 5_000_000; diff --git a/pkgs/types/src/entity.rs b/pkgs/types/src/entity.rs index 725b3a05..c6beec97 100644 --- a/pkgs/types/src/entity.rs +++ b/pkgs/types/src/entity.rs @@ -509,11 +509,11 @@ macro_rules! dlgt_codec { } } - impl<$($impl_generics)*> $crate::codec::Hashable for $ops { + impl<$($impl_generics)*> $crate::Hashable for $ops { type Hash = $hash; fn hash(&self) -> $hash { - $crate::codec::Hashable::hash(&<$bytes as ::core::convert::From<&Self>>::from(self)) + $crate::Hashable::hash(&<$bytes as ::core::convert::From<&Self>>::from(self)) } } }; diff --git a/pkgs/types/src/lib.rs b/pkgs/types/src/lib.rs index 2f7db5e0..d2eea4de 100644 --- a/pkgs/types/src/lib.rs +++ b/pkgs/types/src/lib.rs @@ -22,16 +22,17 @@ mod prelude; mod secret; mod traits; +#[doc(hidden)] +pub mod __deps { + pub use zeroize; +} #[cfg(feature = "serde")] pub mod serialize; -pub use crate::hex::ParseHexError; -pub use crate::macros::qtypestr; -pub use crate::numeric::Numeric; -pub use crate::traits::{Checkable, Hashable}; - -// TODO(kwvg): move to mod __deps -pub use zeroize; +pub use hex::ParseHexError; +pub use macros::qtypestr; +pub use numeric::Numeric; +pub use traits::{Checkable, Hashable}; cfg_if::cfg_if! { if #[cfg(feature = "codec")] { diff --git a/pkgs/types/src/secret.rs b/pkgs/types/src/secret.rs index bffe45a9..17bddeee 100644 --- a/pkgs/types/src/secret.rs +++ b/pkgs/types/src/secret.rs @@ -338,11 +338,11 @@ macro_rules! derive_sbytes { (@parse [$($g:tt)*] $ty:ty, $n:expr) => { impl<$($g)*> ::core::ops::Drop for $ty { fn drop(&mut self) { - ::zeroize(self); + ::zeroize(self); } } - impl<$($g)*> $crate::zeroize::ZeroizeOnDrop for $ty {} + impl<$($g)*> $crate::__deps::zeroize::ZeroizeOnDrop for $ty {} impl<$($g)*> $ty { /// Returns `true` when every byte is zero. @@ -404,8 +404,8 @@ macro_rules! make_sbytes { $crate::make_bytes!(@accessors [$($g)*] $name $(<$($param),+>)?, $n, { /// Copies out the inner byte array. - pub fn to_bytes(&self) -> $crate::zeroize::Zeroizing<[u8; $n]> { - $crate::zeroize::Zeroizing::new(self.inner) + pub fn to_bytes(&self) -> $crate::__deps::zeroize::Zeroizing<[u8; $n]> { + $crate::__deps::zeroize::Zeroizing::new(self.inner) } }); @@ -415,9 +415,9 @@ macro_rules! make_sbytes { } } - impl<$($g)*> $crate::zeroize::Zeroize for $name $(<$($param),+>)? { + impl<$($g)*> $crate::__deps::zeroize::Zeroize for $name $(<$($param),+>)? { fn zeroize(&mut self) { - $crate::zeroize::Zeroize::zeroize(&mut self.inner); + $crate::__deps::zeroize::Zeroize::zeroize(&mut self.inner); } }