Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8ba8202
chore: add new line to open pr
bkioshn May 19, 2025
749717e
chore: revert
bkioshn May 19, 2025
bcf8583
feat(rust/signed-doc): add new type `DocType` (#339)
bkioshn May 22, 2025
fa727d0
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy May 26, 2025
60ff5be
feat(rust/signed-doc): Add initial decoding tests for the Catalyst Si…
Mr-Leshiy May 27, 2025
b5f12bb
fix(rust/signed-doc): Apply new `DocType` (#347)
bkioshn May 29, 2025
b3be754
fix(rust/signed-doc): Correct CBOR content type and data validation (…
apskhem May 30, 2025
a421879
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy May 30, 2025
986dfe6
feat(rust/signed-doc): enum map representation for metadata (#359)
Jun 12, 2025
fe82adb
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jun 16, 2025
c0d22c6
feat(rust/signed-doc): Catalyst signed document encoding using minicb…
Mr-Leshiy Jun 17, 2025
3d788f5
feat(rust/cbork): deterministic map decoding helper (#360)
cong-or Jun 18, 2025
dd0a29e
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jun 18, 2025
4ee0dc5
refactor(rust/signed-doc): Cleanup `Builder`, make `raw_bytes` field …
Mr-Leshiy Jun 19, 2025
4bbc8ae
fix(rust/signed-doc): Update doc type (#365)
bkioshn Jun 20, 2025
8d6b5c9
feat(rust/signed-doc): signed doc metadata serde refactoring (#372)
Jun 20, 2025
6a1be0b
fix(rust/signed-doc): Modify the `DocumentRef` structure (#355)
bkioshn Jun 23, 2025
7f2d501
chore(rust/signed-doc): Cleanup Catalyst Signed Document `Builder`, m…
Mr-Leshiy Jun 23, 2025
648ace3
chore(signed-doc): add problem report to doc ref (#378)
bkioshn Jun 23, 2025
11d9ed7
feat(rust/signed-doc): `*_wrong_role` Catalyst Signed Documents integ…
Mr-Leshiy Jun 24, 2025
b658cb4
test(rust/signed-doc): Add a test case for invalid params and aliases…
apskhem Jun 24, 2025
bd68ac2
feat(cat-gateway): tests for minimal valid signed docs (#384)
saibatizoku Jun 25, 2025
e236d9e
test(rust/signed-doc): Add valid alias decoding as `parameters` case …
apskhem Jun 25, 2025
8f23447
feat(rust/signed-doc): Catalyst Signed Documents `minicbor::Decode` …
Mr-Leshiy Jun 25, 2025
de940b9
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jun 26, 2025
cd3ac5e
fix(rust/signed-doc): Fix an issue to using original bytes for signat…
Mr-Leshiy Jun 26, 2025
b629d10
test(rust/signed-doc): Add random header for signed doc decoding test…
apskhem Jun 26, 2025
54294ce
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jun 27, 2025
6ccfbbf
chore(rust/signed-doc): Provided a new `WithCborBytes` type, cleaned …
Mr-Leshiy Jun 30, 2025
4e8a2b1
test(rust/signed-doc): Add test cases for random kid, invalid COSE ta…
apskhem Jun 30, 2025
e98b252
feat(rust/signed-doc): Add new `ContentType` variants: `Cddl` and `Js…
apskhem Jun 30, 2025
f62e7ff
feat(rust/signed-doc): Add tests for minimal and full metadata fields…
saibatizoku Jul 1, 2025
d0414fb
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jul 1, 2025
32ebc59
feat(rust/signed-doc): add test cases for valid doc type and content …
saibatizoku Jul 2, 2025
b861937
feat(rust/signed-doc): Add CBOR deterministic `Map` as a separate str…
Mr-Leshiy Jul 2, 2025
af7fc4b
feat(rust/signed-doc): Added more decoding test cases, cleaned up `De…
Mr-Leshiy Jul 2, 2025
201b858
refactor(rust/signed-doc): Change `collabs` header to `collaborators`…
apskhem Jul 3, 2025
10aa1a8
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jul 3, 2025
0d4c348
feat(rust/signed-doc): Invalid test cases for protected headers (#402)
saibatizoku Jul 3, 2025
cd679dc
feat(rust/signed-doc): Cleanup `DocType`, `DocumentRefs` related test…
Mr-Leshiy Jul 8, 2025
7d9a6bd
feat(rust/cbork): Add deterministically decoding array (#407)
apskhem Jul 9, 2025
673126d
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jul 10, 2025
a8b219d
feat(rust/signed-doc): `Metadata::to_json` method (#410)
Mr-Leshiy Jul 11, 2025
2d4d633
feat(rust/signed-doc): Apply deterministic CBOR decoding from `cbork-…
apskhem Jul 11, 2025
fa817c4
add convinient trait implementations (#423)
Mr-Leshiy Jul 17, 2025
3b54f12
feat(rust/signed-doc): Add a function to convert back `DocType` to de…
apskhem Jul 18, 2025
be2dd66
fix(rust/signed-doc): Properly export map_doc_type, to_deprecated_doc…
apskhem Jul 18, 2025
135fe90
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jul 23, 2025
7f24efa
feat(rust/signed-doc): Revert back to the original `DocType` format (…
Mr-Leshiy Jul 23, 2025
b5d8a6b
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jul 25, 2025
61f930e
feat(rust/signed-doc): Add `Deref` implementation for the `DocType` …
Mr-Leshiy Jul 25, 2025
5687017
revert using `tag` for now
Mr-Leshiy Jul 25, 2025
70c611c
feat(rust/signed-doc): Add a function to check deprecated version bel…
apskhem Jul 28, 2025
f65ed33
feat(rust/signed-doc): Fixing `ParametersRule` validation (#445)
Mr-Leshiy Jul 30, 2025
cb229dc
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jul 31, 2025
365ec32
fix clippy
Mr-Leshiy Jul 31, 2025
741a681
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jul 31, 2025
c32811a
Merge branch 'main' into feat/new-cat-signed-doc
stevenj Jul 31, 2025
d59d76d
Merge branch 'main' into feat/new-cat-signed-doc
Mr-Leshiy Jul 31, 2025
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
1 change: 0 additions & 1 deletion .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ ciphertexts
Coap
codegen
codepoints
collabs
coti
coverallsapp
cpus
Expand Down
4 changes: 2 additions & 2 deletions rust/cardano-blockchain-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ workspace = true
[dependencies]
pallas = { version = "0.33.0" }
# pallas-hardano = { version = "0.33.0" }
cbork-utils = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250724-01" }
catalyst-types = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250724-01" }
cbork-utils = { version = "0.0.1", path = "../cbork-utils" }
catalyst-types = { version = "0.0.4", path = "../catalyst-types" }

ouroboros = "0.18.4"
tracing = "0.1.41"
Expand Down
7 changes: 4 additions & 3 deletions rust/cardano-chain-follower/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ mithril-client = { version = "0.12.2", default-features = false, features = [
"full",
"num-integer-backend",
] }
cardano-blockchain-types = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types-v0.0.5" }
catalyst-types = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250724-01" }

cardano-blockchain-types = { version = "0.0.5", path = "../cardano-blockchain-types" }
catalyst-types = { version = "0.0.4", path = "../catalyst-types" }


thiserror = "1.0.69"
Expand Down Expand Up @@ -64,7 +65,7 @@ test-log = { version = "0.2.16", default-features = false, features = [
"trace",
] }
clap = "4.5.23"
rbac-registration = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250724-01" }
rbac-registration = { version = "0.0.5", path = "../rbac-registration" }

# Note, these features are for support of features exposed by dependencies.
[features]
Expand Down
2 changes: 1 addition & 1 deletion rust/catalyst-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "catalyst-types"
version = "0.0.3"
version = "0.0.4"
edition.workspace = true
license.workspace = true
authors.workspace = true
Expand Down
6 changes: 6 additions & 0 deletions rust/catalyst-types/src/catalyst_id/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ impl TryFrom<&[u8]> for CatalystId {
}
}

impl From<&CatalystId> for Vec<u8> {
fn from(value: &CatalystId) -> Self {
value.to_string().into_bytes()
}
}

#[cfg(test)]
mod tests {
use chrono::{DateTime, Utc};
Expand Down
22 changes: 4 additions & 18 deletions rust/catalyst-types/src/uuid/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! `UUID` types.

pub use uuid::Uuid;
pub use uuid::{uuid, Uuid};
#[allow(clippy::module_name_repetitions)]
pub use uuid_v4::UuidV4;
pub use uuid_v4::{InvalidUuidV4, ParsingError as UuidV4ParsingError, UuidV4};
#[allow(clippy::module_name_repetitions)]
pub use uuid_v7::UuidV7;
pub use uuid_v7::{InvalidUuidV7, ParsingError as UuidV7ParsingError, UuidV7};

mod uuid_v4;
mod uuid_v7;
Expand All @@ -15,21 +15,7 @@ use minicbor::data::Tag;
pub const INVALID_UUID: uuid::Uuid = uuid::Uuid::from_bytes([0x00; 16]);

/// UUID CBOR tag <https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml/>.
#[allow(dead_code)]
const UUID_CBOR_TAG: u64 = 37;

/// Uuid validation errors, which could occur during decoding or converting to
/// `UuidV4` or `UuidV7` types.
#[derive(Debug, Clone, thiserror::Error)]
#[allow(clippy::module_name_repetitions)]
pub enum UuidError {
/// `UUIDv4` invalid error
#[error("'{0}' is not a valid UUIDv4")]
InvalidUuidV4(uuid::Uuid),
/// `UUIDv7` invalid error
#[error("'{0}' is not a valid UUIDv7")]
InvalidUuidV7(uuid::Uuid),
}
pub const UUID_CBOR_TAG: u64 = 37;

/// Context for `CBOR` encoding and decoding
pub enum CborContext {
Expand Down
110 changes: 56 additions & 54 deletions rust/catalyst-types/src/uuid/uuid_v4.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
//! `UUIDv4` Type.
use std::fmt::{Display, Formatter};
use std::{
fmt::{Display, Formatter},
str::FromStr,
};

use minicbor::{Decode, Decoder, Encode};
use uuid::Uuid;

use super::{decode_cbor_uuid, encode_cbor_uuid, CborContext, UuidError, INVALID_UUID};
use super::{decode_cbor_uuid, encode_cbor_uuid, CborContext};

/// Type representing a `UUIDv4`.
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, serde::Serialize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, serde::Serialize)]
pub struct UuidV4(Uuid);

/// `UUIDv4` invalid error
#[derive(Debug, Clone, thiserror::Error)]
#[error("'{0}' is not a valid UUIDv4")]
pub struct InvalidUuidV4(uuid::Uuid);

impl UuidV4 {
/// Version for `UUIDv4`.
const UUID_VERSION_NUMBER: usize = 4;
Expand All @@ -21,28 +29,28 @@ impl UuidV4 {
Self(Uuid::new_v4())
}

/// Generates a zeroed out `UUIDv4` that can never be valid.
#[must_use]
pub fn invalid() -> Self {
Self(INVALID_UUID)
}

/// Check if this is a valid `UUIDv4`.
#[must_use]
pub fn is_valid(&self) -> bool {
is_valid(&self.uuid())
}

/// Returns the `uuid::Uuid` type.
#[must_use]
pub fn uuid(&self) -> Uuid {
self.0
}

/// A const alternative impl of `TryFrom<Uuid>`
///
/// # Errors
/// - `InvalidUuidV4`
pub const fn try_from_uuid(uuid: Uuid) -> Result<Self, InvalidUuidV4> {
if is_valid(&uuid) {
Ok(Self(uuid))
} else {
Err(InvalidUuidV4(uuid))
}
}
}

/// Check if this is a valid `UUIDv4`.
fn is_valid(uuid: &Uuid) -> bool {
uuid != &INVALID_UUID && uuid.get_version_num() == UuidV4::UUID_VERSION_NUMBER
const fn is_valid(uuid: &Uuid) -> bool {
uuid.get_version_num() == UuidV4::UUID_VERSION_NUMBER
}

impl Display for UuidV4 {
Expand All @@ -54,13 +62,7 @@ impl Display for UuidV4 {
impl Decode<'_, CborContext> for UuidV4 {
fn decode(d: &mut Decoder<'_>, ctx: &mut CborContext) -> Result<Self, minicbor::decode::Error> {
let uuid = decode_cbor_uuid(d, ctx)?;
if is_valid(&uuid) {
Ok(Self(uuid))
} else {
Err(minicbor::decode::Error::message(UuidError::InvalidUuidV4(
uuid,
)))
}
Self::try_from_uuid(uuid).map_err(minicbor::decode::Error::message)
}
}

Expand All @@ -74,14 +76,10 @@ impl Encode<CborContext> for UuidV4 {

/// Returns a `UUIDv4` from `uuid::Uuid`.
impl TryFrom<Uuid> for UuidV4 {
type Error = UuidError;
type Error = InvalidUuidV4;

fn try_from(uuid: Uuid) -> Result<Self, Self::Error> {
if is_valid(&uuid) {
Ok(Self(uuid))
} else {
Err(UuidError::InvalidUuidV4(uuid))
}
Self::try_from_uuid(uuid)
}
}

Expand All @@ -98,43 +96,47 @@ impl<'de> serde::Deserialize<'de> for UuidV4 {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: serde::Deserializer<'de> {
let uuid = Uuid::deserialize(deserializer)?;
if is_valid(&uuid) {
Ok(Self(uuid))
} else {
Err(serde::de::Error::custom(UuidError::InvalidUuidV4(uuid)))
}
Self::try_from_uuid(uuid).map_err(serde::de::Error::custom)
}
}

/// `FromStr` invalid error
#[derive(Debug, Clone, thiserror::Error)]
pub enum ParsingError {
/// `UUIDv4` invalid error
#[error(transparent)]
InvalidUuidV4(#[from] InvalidUuidV4),
/// Invalid string conversion
#[error("Invalid string conversion: {0}")]
StringConversion(String),
}

impl FromStr for UuidV4 {
type Err = ParsingError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let uuid = Uuid::parse_str(s).map_err(|_| ParsingError::StringConversion(s.to_string()))?;
Ok(Self::try_from_uuid(uuid)?)
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::uuid::INVALID_UUID;

#[test]
fn test_invalid_uuid() {
let invalid_uuid = UuidV4::invalid();
assert!(!invalid_uuid.is_valid(), "Invalid UUID should not be valid");
assert_eq!(
invalid_uuid.uuid(),
INVALID_UUID,
"Invalid UUID should match INVALID_UUID"
);
}
assert!(UuidV4::try_from(Uuid::now_v7()).is_err());

#[test]
fn test_valid_uuid() {
let valid_uuid = UuidV4::try_from(Uuid::new_v4()).unwrap();
assert!(valid_uuid.is_valid(), "Valid UUID should be valid");

let valid_uuid = UuidV4::new();
assert!(valid_uuid.is_valid(), "Valid UUID should be valid");
}

#[test]
fn test_invalid_version_uuid() {
assert!(
UuidV4::try_from(INVALID_UUID).is_err(),
"Zero UUID should not be valid"
);
}

#[test]
fn test_valid_uuid() {
assert!(UuidV4::try_from(Uuid::new_v4()).is_ok());
}
}
Loading
Loading