diff --git a/Cargo.lock b/Cargo.lock index 48730f03f..1c41ba23c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2609,9 +2609,8 @@ dependencies = [ [[package]] name = "nonempty" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e591e719385e6ebaeb5ce5d3887f7d5676fceca6411d1925ccc95745f3d6f7" +version = "0.10.0" +source = "git+https://github.com/nuttycom/nonempty.git?rev=38d37189faecb2a0e3d6adc05aa24e1b93c2483b#38d37189faecb2a0e3d6adc05aa24e1b93c2483b" [[package]] name = "notify" @@ -2789,7 +2788,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "orchard" version = "0.10.0" -source = "git+https://github.com/zcash/orchard.git?rev=f99b6565a78763b58dac792d7492c55067bae680#f99b6565a78763b58dac792d7492c55067bae680" +source = "git+https://github.com/zcash/orchard.git?rev=159966b80e2d956907f853bb24513ff5bef4087d#159966b80e2d956907f853bb24513ff5bef4087d" dependencies = [ "aes", "bitvec", diff --git a/Cargo.toml b/Cargo.toml index 5732ef4dd..fe854c458 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,6 @@ redjubjub = "0.7" sapling = { package = "sapling-crypto", version = "0.3", default-features = false } # - Orchard -nonempty = "0.7" orchard = { version = "0.10", default-features = false } pasta_curves = "0.5" @@ -77,6 +76,7 @@ transparent = { package = "zcash_transparent", version = "0.0", path = "zcash_tr # Boilerplate & missing stdlib getset = "0.1" +nonempty = { version = "0.10", default-features = false } # CSPRNG rand = { version = "0.8", default-features = false } @@ -195,5 +195,6 @@ debug = true unexpected_cfgs = { level = "warn", check-cfg = ['cfg(zcash_unstable, values("zfuture"))'] } [patch.crates-io] -orchard = { git = "https://github.com/zcash/orchard.git", rev = "f99b6565a78763b58dac792d7492c55067bae680" } +nonempty = { git = "https://github.com/nuttycom/nonempty.git", rev = "38d37189faecb2a0e3d6adc05aa24e1b93c2483b" } +orchard = { git = "https://github.com/zcash/orchard.git", rev = "159966b80e2d956907f853bb24513ff5bef4087d" } sapling-crypto = { git = "https://github.com/zcash/sapling-crypto.git", rev = "e47d57f5c9c46f05740328f8ef9601f6d697cf34" } diff --git a/zcash_keys/CHANGELOG.md b/zcash_keys/CHANGELOG.md index b8eaead52..a337c6871 100644 --- a/zcash_keys/CHANGELOG.md +++ b/zcash_keys/CHANGELOG.md @@ -6,6 +6,10 @@ and this library adheres to Rust's notion of ## [Unreleased] +### Added +- `no-std` compatibility (`alloc` is required). A default-enabled `std` feature + flag has been added gating the `std::error::Error` usage. + ### Changed - Migrated to `bech32 0.11`. - The `UnifiedAddressRequest` argument to the following methods is now optional: diff --git a/zcash_keys/Cargo.toml b/zcash_keys/Cargo.toml index 0ab84ba67..6a686d158 100644 --- a/zcash_keys/Cargo.toml +++ b/zcash_keys/Cargo.toml @@ -59,7 +59,7 @@ proptest = { workspace = true, optional = true } # Dependencies used internally: # (Breaking upgrades to these are usually backwards-compatible, but check MSRVs.) # - Documentation -document-features.workspace = true +document-features = { workspace = true, optional = true } # - Encodings byteorder = { workspace = true, optional = true } @@ -76,6 +76,9 @@ zcash_address = { workspace = true, features = ["test-dependencies"] } zcash_primitives = { workspace = true, features = ["test-dependencies"] } [features] +default = ["std"] +std = ["dep:document-features"] + ## Enables use of transparent key parts and addresses transparent-inputs = ["dep:bip32", "zcash_primitives/transparent-inputs"] diff --git a/zcash_keys/src/encoding.rs b/zcash_keys/src/encoding.rs index f4e97d006..f2b154fcd 100644 --- a/zcash_keys/src/encoding.rs +++ b/zcash_keys/src/encoding.rs @@ -76,7 +76,7 @@ impl fmt::Display for Bech32DecodeError { } } -#[cfg(feature = "sapling")] +#[cfg(all(feature = "sapling", feature = "std"))] impl std::error::Error for Bech32DecodeError {} #[cfg(feature = "sapling")] @@ -135,6 +135,7 @@ impl fmt::Display for TransparentCodecError { } } +#[cfg(feature = "std")] impl std::error::Error for TransparentCodecError {} impl AddressCodec

for TransparentAddress { diff --git a/zcash_keys/src/keys.rs b/zcash_keys/src/keys.rs index c83ef32b3..84ee32459 100644 --- a/zcash_keys/src/keys.rs +++ b/zcash_keys/src/keys.rs @@ -113,6 +113,7 @@ impl Display for DerivationError { } } +#[cfg(feature = "std")] impl std::error::Error for DerivationError {} /// A version identifier for the encoding of unified spending keys. @@ -180,6 +181,7 @@ impl core::fmt::Display for DecodingError { } } +#[cfg(feature = "std")] impl std::error::Error for DecodingError {} #[cfg(feature = "unstable")] @@ -547,6 +549,7 @@ impl fmt::Display for AddressGenerationError { } } +#[cfg(feature = "std")] impl std::error::Error for AddressGenerationError {} /// Specification for how a unified address should be generated from a unified viewing key. @@ -1308,7 +1311,6 @@ pub mod testing { #[cfg(test)] mod tests { - use proptest::prelude::proptest; use {zcash_primitives::consensus::MAIN_NETWORK, zip32::AccountId}; diff --git a/zcash_keys/src/lib.rs b/zcash_keys/src/lib.rs index 28c9c98b1..48830ebd0 100644 --- a/zcash_keys/src/lib.rs +++ b/zcash_keys/src/lib.rs @@ -4,7 +4,8 @@ //! and viewing keys and addresses. //! //! ## Feature flags -#![doc = document_features::document_features!()] +#![cfg_attr(feature = "std", doc = "## Feature flags")] +#![cfg_attr(feature = "std", doc = document_features::document_features!())] //! #![no_std] @@ -18,6 +19,7 @@ #[macro_use] extern crate alloc; +#[cfg(feature = "std")] extern crate std; pub mod address;