diff --git a/.github/workflows/umbral-pre.yml b/.github/workflows/umbral-pre.yml index 5486840..ea9d063 100644 --- a/.github/workflows/umbral-pre.yml +++ b/.github/workflows/umbral-pre.yml @@ -27,7 +27,7 @@ jobs: strategy: matrix: rust: - - 1.57.0 # MSRV + - 1.60.0 # MSRV - stable target: - wasm32-unknown-unknown @@ -47,7 +47,7 @@ jobs: strategy: matrix: rust: - - 1.57.0 # MSRV + - 1.60.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -67,7 +67,7 @@ jobs: strategy: matrix: rust: - - 1.57.0 # MSRV + - 1.60.0 # MSRV - stable steps: - uses: actions/checkout@v2 @@ -83,7 +83,7 @@ jobs: matrix: include: - target: x86_64-unknown-linux-gnu - rust: 1.57.0 # MSRV + rust: 1.60.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable diff --git a/CHANGELOG.md b/CHANGELOG.md index 912f166..4d01f1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed `VerifiedCapsuleFrag::from_verified_bytes()` and `VerifiedKeyFrag::from_verified_bytes()`. For this behavior, deserialize into `CapsuleFrag` or `KeyFrag` and call `skip_verification()`. ([#110]) - `Capsule` no longer implements `Copy`. ([#110]) - Removed default serialization methods for `PublicKey` and `Signature` in the bindings; use `to_compressed_bytes()`/`to_der_bytes()` instead. ([#110]) +- MSRV bumped to 1.60 to satisfy the dependencies. ([#111]) ### Added - `DefaultSerialize`/`DefaultDeserialize` for Umbral objects (`Caspule`, `(Verified)CapsuleFrag`, `(Verified)KeyFrag`) which uses MessagePack via `serde` (gated by `default-serialization` feature). This is what the serialization methods in the bindings use. ([#110]) +- Use ASN.1 DER instead of MessagePack in the traits above. ([#111]) - `to_compressed_bytes()`/`try_from_compressed_bytes()` for `PublicKey` to give access to non-serde representation (just 33 bytes). These are exposed in the bindings in lieu of the "default" methods (e.g. `__bytes__()` or `toBytes()`). ([#110]) - `to_der_bytes()`/`try_from_der_bytes()` for `Signature` to give access to non-serde representation. These are exposed in the bindings in lieu of the "default" methods (e.g. `__bytes__()` or `toBytes()`). ([#110]) - `SecretKeyFactory::make_secret()` to provide a more straightforward replacement of `SecretKeyFactory::make_secret_key()`->`SecretKey::to_secret_bytes()`. ([#110]) @@ -30,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#105]: https://github.com/nucypher/rust-umbral/pull/105 [#110]: https://github.com/nucypher/rust-umbral/pull/110 +[#111]: https://github.com/nucypher/rust-umbral/pull/111 ## [0.7.0] - 2022-09-30 diff --git a/umbral-pre/Cargo.toml b/umbral-pre/Cargo.toml index 04c1416..797e346 100644 --- a/umbral-pre/Cargo.toml +++ b/umbral-pre/Cargo.toml @@ -36,12 +36,12 @@ typenum = "1.13" # typenum is a 2018-edition crate starting from 1.13 getrandom = { version = "0.2", optional = true, default-features = false, features = ["js"] } subtle = { version = "2.4", default-features = false } zeroize = { version = "1.5", default-features = false, features = ["derive"] } -rmp-serde = { version = "0.15", optional = true } +picky-asn1-der = { version = "0.4", optional = true } [dev-dependencies] criterion = { version = "0.3", features = ["html_reports"] } serde_json = "1" -rmp-serde = "0.15" +picky-asn1-der = "0.4" [features] default = ["default-rng"] @@ -49,7 +49,7 @@ bench-internals = ["default-rng"] bindings-python = ["pyo3", "std", "derive_more", "default-serialization"] bindings-wasm = ["js-sys", "default-serialization", "wasm-bindgen", "derive_more", "wasm-bindgen-derive"] default-rng = ["getrandom", "rand_core/getrandom"] -default-serialization = ["serde-support", "rmp-serde"] +default-serialization = ["serde-support", "picky-asn1-der"] serde-support = ["serde"] std = [] diff --git a/umbral-pre/src/capsule_frag.rs b/umbral-pre/src/capsule_frag.rs index 44fb6ee..68d866d 100644 --- a/umbral-pre/src/capsule_frag.rs +++ b/umbral-pre/src/capsule_frag.rs @@ -325,8 +325,8 @@ mod tests { let cfrag = verified_cfrags[0].clone().unverify(); // Check that the cfrag serializes to the same thing as the verified cfrag - let cfrag_bytes = rmp_serde::to_vec(&cfrag).unwrap(); - let vcfrag_bytes = rmp_serde::to_vec(&verified_cfrags[0]).unwrap(); + let cfrag_bytes = picky_asn1_der::to_vec(&cfrag).unwrap(); + let vcfrag_bytes = picky_asn1_der::to_vec(&verified_cfrags[0]).unwrap(); assert_eq!(vcfrag_bytes, cfrag_bytes); check_serialization_roundtrip(&cfrag); diff --git a/umbral-pre/src/key_frag.rs b/umbral-pre/src/key_frag.rs index a71ca66..cbdcbc3 100644 --- a/umbral-pre/src/key_frag.rs +++ b/umbral-pre/src/key_frag.rs @@ -504,8 +504,8 @@ mod tests { let kfrag = verified_kfrags[0].clone().unverify(); // Check that the kfrag serializes to the same thing as the verified kfrag - let kfrag_bytes = rmp_serde::to_vec(&kfrag).unwrap(); - let vkfrag_bytes = rmp_serde::to_vec(&verified_kfrags[0]).unwrap(); + let kfrag_bytes = picky_asn1_der::to_vec(&kfrag).unwrap(); + let vkfrag_bytes = picky_asn1_der::to_vec(&verified_kfrags[0]).unwrap(); assert_eq!(vkfrag_bytes, kfrag_bytes); check_serialization_roundtrip(&kfrag); diff --git a/umbral-pre/src/serde_bytes.rs b/umbral-pre/src/serde_bytes.rs index 5cca48c..644d630 100644 --- a/umbral-pre/src/serde_bytes.rs +++ b/umbral-pre/src/serde_bytes.rs @@ -243,10 +243,10 @@ pub(crate) mod tests { let deserialized: T = serde_json::from_str(&serialized).unwrap(); assert_eq!(obj, &deserialized); - // Check serialization to MessagePack (binary) + // Check serialization to ASN.1 DER (binary) - let serialized = rmp_serde::to_vec(obj).unwrap(); - let deserialized: T = rmp_serde::from_slice(&serialized).unwrap(); + let serialized = picky_asn1_der::to_vec(obj).unwrap(); + let deserialized: T = picky_asn1_der::from_bytes(&serialized).unwrap(); assert_eq!(obj, &deserialized); } } diff --git a/umbral-pre/src/traits.rs b/umbral-pre/src/traits.rs index 62aaee9..3ec2038 100644 --- a/umbral-pre/src/traits.rs +++ b/umbral-pre/src/traits.rs @@ -50,21 +50,21 @@ pub(crate) fn fmt_public( } /// Default serialization of an object that is used in all the bindings. -/// Uses MessagePack format. +/// Uses ASN.1 DER format. #[cfg(feature = "default-serialization")] pub trait DefaultSerialize: Serialize { /// Serializes this object. - fn to_bytes(&self) -> Result, rmp_serde::encode::Error> { - rmp_serde::to_vec(self).map(|v| v.into_boxed_slice()) + fn to_bytes(&self) -> Result, picky_asn1_der::Asn1DerError> { + picky_asn1_der::to_vec(self).map(|v| v.into_boxed_slice()) } } /// Default deserialization of an object that is used in all the bindings. -/// Uses MessagePack format. +/// Uses ASN.1 DER format. #[cfg(feature = "default-serialization")] pub trait DefaultDeserialize<'de>: Deserialize<'de> { /// Deserializes a bytestring into this object. - fn from_bytes(bytes: &'de [u8]) -> Result { - rmp_serde::from_slice(bytes) + fn from_bytes(bytes: &'de [u8]) -> Result { + picky_asn1_der::from_bytes(bytes) } }