Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zcash_keys: Enable no_std usage. #1661

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ redjubjub = "0.7"
sapling = { package = "sapling-crypto", version = "0.4", default-features = false }

# - Orchard
nonempty = "0.7"
orchard = { version = "0.10.1", default-features = false }
pasta_curves = "0.5"

Expand All @@ -77,6 +76,7 @@ transparent = { package = "zcash_transparent", version = "0.1", path = "zcash_tr

# Boilerplate & missing stdlib
getset = "0.1"
nonempty = { version = "0.11", default-features = false }

# CSPRNG
rand = { version = "0.8", default-features = false }
Expand Down Expand Up @@ -193,3 +193,6 @@ debug = true

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(zcash_unstable, values("zfuture"))'] }

[patch.crates-io]
orchard = { git = "https://github.com/zcash/orchard.git", rev = "cd3e0901ccac2c630dd7fd03eb496d5030c1bbfe" }
4 changes: 4 additions & 0 deletions components/zcash_encoding/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this library adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed
- Migrated to `nonempty 0.11`

## [0.2.2] - 2024-12-13
### Added
- `no-std` support, via a default-enabled `std` feature flag.
Expand Down
3 changes: 3 additions & 0 deletions pczt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ and this library adheres to Rust's notion of

## [Unreleased]

### Changed
- Migrated to `nonempty 0.11`

## [0.1.0] - 2024-12-16
Initial release supporting the PCZT v1 format.
20 changes: 20 additions & 0 deletions supply-chain/audits.toml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,26 @@ who = "Jack Grigg <[email protected]>"
criteria = "safe-to-deploy"
delta = "2.11.2 -> 2.12.0"

[[audits.nonempty]]
who = "Kris Nuttycombe <[email protected]>"
criteria = "safe-to-deploy"
version = "0.11.0"
notes = """
Additional use of `unsafe` to wrap `NonZeroUsize::new_unchecked`; in both cases
the argument to this method is `<Vec length or capacity> + 1`; in general this
is safe with the exception that if an existing `Vec` has length or capacity
`usize::MAX` this could wrap into zero; it would be better to use the safe
operation and then `expect` to generate a panic, rather than risk undefined
behavior.

Additions are:
- no_std support
- sorting
- `nonzero` module (just wrappers
- `serde` support
- `nonempty macro` (trivial, verified safe)
"""

[[audits.num-bigint]]
who = "Daira-Emma Hopwood <[email protected]>"
criteria = "safe-to-deploy"
Expand Down
4 changes: 0 additions & 4 deletions supply-chain/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,6 @@ criteria = "safe-to-deploy"
version = "0.8.3"
criteria = "safe-to-deploy"

[[exemptions.nonempty]]
version = "0.7.0"
criteria = "safe-to-deploy"

[[exemptions.notify]]
version = "6.1.1"
criteria = "safe-to-deploy"
Expand Down
7 changes: 0 additions & 7 deletions supply-chain/imports.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ user-id = 6289
user-login = "str4d"
user-name = "Jack Grigg"

[[publisher.orchard]]
version = "0.10.1"
when = "2024-12-17"
user-id = 169181
user-login = "nuttycom"
user-name = "Kris Nuttycombe"

[[publisher.pczt]]
version = "0.1.0"
when = "2024-12-17"
Expand Down
3 changes: 3 additions & 0 deletions zcash_client_backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this library adheres to Rust's notion of

## [Unreleased]

### Changed
- Migrated to `nonempty 0.11`

## [0.16.0] - 2024-12-16

### Added
Expand Down
3 changes: 3 additions & 0 deletions zcash_client_sqlite/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this library adheres to Rust's notion of

## [Unreleased]

### Changed
- Migrated to `nonempty 0.11`

## [0.14.0] - 2024-12-16

### Added
Expand Down
7 changes: 7 additions & 0 deletions zcash_keys/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ 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 `nonempty 0.11`

## [0.6.0] - 2024-12-16

### Changed
Expand Down
5 changes: 4 additions & 1 deletion zcash_keys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -76,6 +76,9 @@ orchard = { workspace = true, features = ["circuit"] }
zcash_address = { workspace = true, features = ["test-dependencies"] }

[features]
default = ["std"]
std = ["dep:document-features"]

## Enables use of transparent key parts and addresses
transparent-inputs = [
"dep:bip32",
Expand Down
3 changes: 2 additions & 1 deletion zcash_keys/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -135,6 +135,7 @@ impl fmt::Display for TransparentCodecError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for TransparentCodecError {}

impl<P: consensus::Parameters> AddressCodec<P> for TransparentAddress {
Expand Down
4 changes: 3 additions & 1 deletion zcash_keys/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -180,6 +181,7 @@ impl core::fmt::Display for DecodingError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for DecodingError {}

#[cfg(feature = "unstable")]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1308,7 +1311,6 @@ pub mod testing {

#[cfg(test)]
mod tests {

use proptest::prelude::proptest;

use zcash_protocol::consensus::MAIN_NETWORK;
Expand Down
4 changes: 3 additions & 1 deletion zcash_keys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -18,6 +19,7 @@
#[macro_use]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std;

pub mod address;
Expand Down
3 changes: 3 additions & 0 deletions zcash_primitives/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this library adheres to Rust's notion of

## [Unreleased]

### Changed
- Migrated to `nonempty 0.11`

## [0.21.0] - 2024-12-16

### Added
Expand Down
Loading