From 6b6187bd1c281a7e4d3d531cc2a9141b69caa40b Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 9 Apr 2023 16:48:43 +0100 Subject: [PATCH] fix(identity): remove `prost` dependency Pull-Request: #3713. --- Cargo.lock | 24 ------------------------ identity/Cargo.toml | 13 ++++++------- identity/src/error.rs | 6 ++++++ identity/src/lib.rs | 6 ++++++ 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1cffea69..6033abc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2505,7 +2505,6 @@ dependencies = [ "multiaddr", "multihash", "p256 0.12.0", - "prost", "quick-protobuf", "quickcheck-ext", "rand 0.8.5", @@ -3843,29 +3842,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "prost" -version = "0.11.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-derive" -version = "0.11.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "quick-error" version = "1.2.3" diff --git a/identity/Cargo.toml b/identity/Cargo.toml index 3b98eaca..78343849 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -20,8 +20,7 @@ log = "0.4" multiaddr = { version = "0.17.1", optional = true } multihash = { version = "0.17.0", default-features = false, features = ["std"], optional = true } p256 = { version = "0.12", default-features = false, features = ["ecdsa", "std"], optional = true } -prost = { version = "0.11", optional = true } -quick-protobuf = "0.8.1" +quick-protobuf = { version = "0.8.1", optional = true } rand = { version = "0.8", optional = true } sec1 = { version = "0.3.0", features = ["std"], optional = true } # Activate `std` feature until https://github.com/RustCrypto/traits/pull/1131 is released. serde = { version = "1", optional = true, features = ["derive"] } @@ -34,11 +33,11 @@ zeroize = { version = "1.6", optional = true } ring = { version = "0.16.9", features = ["alloc", "std"], default-features = false, optional = true} [features] -secp256k1 = [ "libsecp256k1", "asn1_der", "prost", "rand", "sha2", "zeroize" ] -ecdsa = [ "p256", "prost", "rand", "void", "zeroize", "sec1" ] -rsa = [ "dep:ring", "asn1_der", "prost", "rand", "zeroize" ] -ed25519 = [ "ed25519-dalek", "prost", "rand", "zeroize" ] -peerid = [ "multihash", "multiaddr", "bs58", "rand", "thiserror", "sha2" ] +secp256k1 = [ "dep:libsecp256k1", "dep:asn1_der", "dep:rand", "dep:sha2", "dep:zeroize", "dep:quick-protobuf" ] +ecdsa = [ "dep:p256", "dep:rand", "dep:void", "dep:zeroize", "dep:sec1", "dep:quick-protobuf" ] +rsa = [ "dep:ring", "dep:asn1_der", "dep:rand", "dep:zeroize", "dep:quick-protobuf" ] +ed25519 = [ "dep:ed25519-dalek", "dep:rand", "dep:zeroize", "dep:quick-protobuf" ] +peerid = [ "dep:multihash", "dep:multiaddr", "dep:bs58", "dep:rand", "dep:thiserror", "dep:sha2" ] [dev-dependencies] quickcheck = { package = "quickcheck-ext", path = "../misc/quickcheck-ext" } diff --git a/identity/src/error.rs b/identity/src/error.rs index aa12fa9d..2a46571d 100644 --- a/identity/src/error.rs +++ b/identity/src/error.rs @@ -81,6 +81,12 @@ impl DecodingError { } } + #[cfg(any( + feature = "ecdsa", + feature = "secp256k1", + feature = "ed25519", + feature = "rsa" + ))] pub(crate) fn decoding_unsupported(key_type: &'static str) -> Self { Self { msg: format!("decoding {key_type} key from Protobuf is unsupported"), diff --git a/identity/src/lib.rs b/identity/src/lib.rs index 1f92b904..078a2de2 100644 --- a/identity/src/lib.rs +++ b/identity/src/lib.rs @@ -33,6 +33,12 @@ //! (e.g. [ed25519 binary format](https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.5)). //! All key types have functions to enable conversion to/from their binary representations. +#[cfg(any( + feature = "ecdsa", + feature = "secp256k1", + feature = "ed25519", + feature = "rsa" +))] mod proto { include!("generated/mod.rs"); pub use self::keys_proto::*;