Skip to content
Open
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
8 changes: 4 additions & 4 deletions .github/workflows/umbral-pre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
rust:
- 1.57.0 # MSRV
- 1.60.0 # MSRV
- stable
target:
- wasm32-unknown-unknown
Expand All @@ -47,7 +47,7 @@ jobs:
strategy:
matrix:
rust:
- 1.57.0 # MSRV
- 1.60.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
Expand All @@ -67,7 +67,7 @@ jobs:
strategy:
matrix:
rust:
- 1.57.0 # MSRV
- 1.60.0 # MSRV
- stable
steps:
- uses: actions/checkout@v2
Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions umbral-pre/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ 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"]
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 = []

Expand Down
4 changes: 2 additions & 2 deletions umbral-pre/src/capsule_frag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions umbral-pre/src/key_frag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions umbral-pre/src/serde_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
12 changes: 6 additions & 6 deletions umbral-pre/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<[u8]>, rmp_serde::encode::Error> {
rmp_serde::to_vec(self).map(|v| v.into_boxed_slice())
fn to_bytes(&self) -> Result<Box<[u8]>, 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<Self, rmp_serde::decode::Error> {
rmp_serde::from_slice(bytes)
fn from_bytes(bytes: &'de [u8]) -> Result<Self, picky_asn1_der::Asn1DerError> {
picky_asn1_der::from_bytes(bytes)
}
}