Skip to content

Commit c7760c1

Browse files
committed
fix(rust/signed-doc): use tagged cbor for uuid types
1 parent d0a1b28 commit c7760c1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

rust/signed_doc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license.workspace = true
1111
workspace = true
1212

1313
[dependencies]
14-
catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250114-02" }
14+
catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250116-01" }
1515
anyhow = "1.0.95"
1616
serde = { version = "1.0.217", features = ["derive"] }
1717
serde_json = "1.0.134"

rust/signed_doc/src/metadata/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod document_version;
1111

1212
pub use additional_fields::AdditionalFields;
1313
use anyhow::anyhow;
14-
pub use catalyst_types::uuid::{V4 as UuidV4, V7 as UuidV7};
14+
pub use catalyst_types::uuid::{CborContext, V4 as UuidV4, V7 as UuidV7};
1515
pub use content_encoding::ContentEncoding;
1616
pub use content_type::ContentType;
1717
use coset::CborSerializable;
@@ -221,23 +221,26 @@ fn cose_protected_header_find(
221221
}
222222

223223
/// Convert from `minicbor` into `coset::cbor::Value`.
224-
pub(crate) fn encode_cbor_value<T: minicbor::encode::Encode<()>>(
224+
pub(crate) fn encode_cbor_value<T: minicbor::encode::Encode<CborContext>>(
225225
value: T,
226226
) -> anyhow::Result<coset::cbor::Value> {
227227
let mut cbor_bytes = Vec::new();
228-
minicbor::encode(value, &mut cbor_bytes)
228+
minicbor::encode_with(value, &mut cbor_bytes, &mut CborContext::Tagged)
229229
.map_err(|e| anyhow::anyhow!("Unable to encode CBOR value, err: {e}"))?;
230230
coset::cbor::Value::from_slice(&cbor_bytes)
231231
.map_err(|e| anyhow::anyhow!("Invalid CBOR value, err: {e}"))
232232
}
233233

234234
/// Convert `coset::cbor::Value` into `UuidV4`.
235-
pub(crate) fn decode_cbor_uuid<T: for<'a> minicbor::decode::Decode<'a, ()> + From<uuid::Uuid>>(
235+
pub(crate) fn decode_cbor_uuid<
236+
T: for<'a> minicbor::decode::Decode<'a, CborContext> + From<uuid::Uuid>,
237+
>(
236238
value: coset::cbor::Value,
237239
) -> anyhow::Result<T> {
238240
match value.to_vec() {
239241
Ok(cbor_value) => {
240-
minicbor::decode(&cbor_value).map_err(|e| anyhow!("Invalid UUID, err: {e}"))
242+
minicbor::decode_with(&cbor_value, &mut CborContext::Tagged)
243+
.map_err(|e| anyhow!("Invalid UUID, err: {e}"))
241244
},
242245
Err(e) => anyhow::bail!("Invalid CBOR value, err: {e}"),
243246
}

0 commit comments

Comments
 (0)