diff --git a/rust/cardano-blockchain-types/Cargo.toml b/rust/cardano-blockchain-types/Cargo.toml index 606801e59ee..60db45fc7dd 100644 --- a/rust/cardano-blockchain-types/Cargo.toml +++ b/rust/cardano-blockchain-types/Cargo.toml @@ -18,7 +18,7 @@ crate-type = ["cdylib", "rlib"] workspace = true [dependencies] -catalyst-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.6" } +catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" } cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" } ouroboros = "0.18.4" @@ -35,7 +35,6 @@ num-traits = "0.2.19" ed25519-dalek = "2.1.1" serde = "1.0.210" num-bigint = "0.4.6" -serde_json = "1.0.134" displaydoc = "0.2.5" thiserror = "2.0.11" diff --git a/rust/cardano-blockchain-types/src/metadata/cip36/mod.rs b/rust/cardano-blockchain-types/src/metadata/cip36/mod.rs index 340ca7df9f2..fd9ce92b837 100644 --- a/rust/cardano-blockchain-types/src/metadata/cip36/mod.rs +++ b/rust/cardano-blockchain-types/src/metadata/cip36/mod.rs @@ -51,7 +51,7 @@ impl fmt::Display for Cip36 { ) -> fmt::Result { write!( f, - "Cip36 {{ network: {network}, slot: {slot:?}, txn_idx: {txn_idx:?}, is_catalyst_strict: {is_catalyst_strict}, key_registration: {key_registration:?}, registration_witness: {registration_witness:?}, validation: {{ signature: {is_valid_signature}, payment_address_network: {is_valid_payment_address_network}, voting_keys: {is_valid_voting_keys}, purpose: {is_valid_purpose} }}, err_report: {err_report} }}", + "Cip36 {{ network: {network}, slot: {slot:?}, txn_idx: {txn_idx:?}, is_catalyst_strict: {is_catalyst_strict}, key_registration: {key_registration:?}, registration_witness: {registration_witness:?}, validation: {{ signature: {is_valid_signature}, payment_address_network: {is_valid_payment_address_network}, voting_keys: {is_valid_voting_keys}, purpose: {is_valid_purpose} }}, problematic: {is_problematic} }}", key_registration = self.key_registration, registration_witness = self.registration_witness, network = self.network, @@ -62,34 +62,7 @@ impl fmt::Display for Cip36 { is_valid_payment_address_network = self.is_valid_payment_address_network, is_valid_voting_keys = self.is_valid_voting_keys, is_valid_purpose = self.is_valid_purpose, - err_report = serde_json::to_string(&self.err_report) - .unwrap_or_else(|_| String::from("Failed to serialize ProblemReport")) - ) - } -} - -/// CIP-36 Catalyst registration error -#[allow(dead_code, clippy::module_name_repetitions)] -#[derive(Debug)] -pub struct Cip36Error { - /// The decoding error that make the code not able to process. - error: anyhow::Error, - /// The problem report that contains the errors found during decoding and validation. - report: ProblemReport, -} - -impl fmt::Display for Cip36Error { - fn fmt( - &self, - fmt: &mut fmt::Formatter<'_>, - ) -> fmt::Result { - let report_json = serde_json::to_string(&self.report) - .unwrap_or_else(|_| String::from("Failed to serialize ProblemReport")); - - write!( - fmt, - "Cip36Error {{ error: {}, report: {} }}", - self.error, report_json + is_problematic = self.err_report.is_problematic(), ) } } @@ -118,7 +91,7 @@ impl Cip36 { block: &MultiEraBlock, txn_idx: TxnIndex, is_catalyst_strict: bool, - ) -> Result, Cip36Error> { + ) -> anyhow::Result> { // Record of errors found during decoding and validation let mut err_report = ProblemReport::new("CIP36 Registration Decoding and Validation"); @@ -148,12 +121,7 @@ impl Cip36 { metadata }, Err(e) => { - return Err(Cip36Error { - error: anyhow::anyhow!(format!( - "Failed to construct CIP-36 key registration, {e}" - )), - report: err_report, - }); + anyhow::bail!("Failed to construct CIP-36 key registration, {e}"); }, }; @@ -161,12 +129,7 @@ impl Cip36 { match Cip36RegistrationWitness::decode(&mut registration_witness, &mut err_report) { Ok(metadata) => metadata, Err(e) => { - return Err(Cip36Error { - error: anyhow::anyhow!(format!( - "Failed to construct CIP-36 registration witness {e}" - )), - report: err_report, - }); + anyhow::bail!("Failed to construct CIP-36 registration witness {e}"); }, }; @@ -210,7 +173,7 @@ impl Cip36 { pub fn cip36_from_block( block: &MultiEraBlock, is_catalyst_strict: bool, - ) -> Option>> { + ) -> Option>> { let mut cip36_map = HashMap::new(); for (txn_idx, _tx) in block.decode().txs().iter().enumerate() { diff --git a/rust/cardano-chain-follower/Cargo.toml b/rust/cardano-chain-follower/Cargo.toml index d005f615f96..5cdcc615f92 100644 --- a/rust/cardano-chain-follower/Cargo.toml +++ b/rust/cardano-chain-follower/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cardano-chain-follower" -version = "0.0.16" +version = "0.0.17" edition.workspace = true authors.workspace = true homepage.workspace = true @@ -17,7 +17,7 @@ mithril-client = { version = "=0.12.2", default-features = false, features = [ ] } cardano-blockchain-types = { version = "0.0.7", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types/v0.0.7" } -catalyst-types = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.8" } +catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" } thiserror = "1.0.69" tokio = { version = "1.45.0", features = [ diff --git a/rust/rbac-registration/Cargo.toml b/rust/rbac-registration/Cargo.toml index 36c91c2875a..359f2f8506a 100644 --- a/rust/rbac-registration/Cargo.toml +++ b/rust/rbac-registration/Cargo.toml @@ -2,7 +2,7 @@ name = "rbac-registration" description = "Role Based Access Control Registration" keywords = ["cardano", "catalyst", "rbac registration"] -version = "0.0.12" +version = "0.0.13" authors = [ "Arissara Chotivichit " ] @@ -35,4 +35,4 @@ thiserror = "2.0.11" c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "c509-certificate-v0.0.3" } cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" } cardano-blockchain-types = { version = "0.0.7", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types/v0.0.7" } -catalyst-types = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.8" } +catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" } diff --git a/rust/signed_doc/Cargo.toml b/rust/signed_doc/Cargo.toml index c36aaf535b2..70cf1ae3ae9 100644 --- a/rust/signed_doc/Cargo.toml +++ b/rust/signed_doc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "catalyst-signed-doc" -version = "0.0.8" +version = "0.0.9" edition.workspace = true authors.workspace = true homepage.workspace = true @@ -11,7 +11,7 @@ license.workspace = true workspace = true [dependencies] -catalyst-types = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.8" } +catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" } cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" } catalyst-signed-doc-macro = { version = "0.0.1", path = "../catalyst-signed-doc-macro" } diff --git a/rust/signed_doc/src/lib.rs b/rust/signed_doc/src/lib.rs index 16343d5df63..1e247fbb9a4 100644 --- a/rust/signed_doc/src/lib.rs +++ b/rust/signed_doc/src/lib.rs @@ -30,7 +30,7 @@ pub use metadata::{ use minicbor::{decode, encode, Decode, Decoder, Encode}; pub use signature::{CatalystId, Signatures}; -use crate::{builder::SignaturesBuilder, metadata::SupportedLabel}; +use crate::{builder::SignaturesBuilder, metadata::SupportedLabel, signature::Signature}; /// `COSE_Sign` object CBOR tag const COSE_SIGN_CBOR_TAG: minicbor::data::Tag = minicbor::data::Tag::new(98); @@ -69,8 +69,8 @@ impl Display for CatalystSignedDocument { if self.inner.signatures.is_empty() { writeln!(f, " This document is unsigned.")?; } else { - for kid in &self.kids() { - writeln!(f, " Signature Key ID: {kid}")?; + for kid in &self.authors() { + writeln!(f, " Author ID: {kid}")?; } } Ok(()) @@ -161,23 +161,14 @@ impl CatalystSignedDocument { &self.inner.signatures } - /// Return a list of Document's Catalyst IDs. - #[must_use] - pub fn kids(&self) -> Vec { - self.inner - .signatures - .iter() - .map(|s| s.kid().clone()) - .collect() - } - - /// Return a list of Document's author IDs (short form of Catalyst IDs). + /// Return a list of Document's Signer's Catalyst IDs, #[must_use] pub fn authors(&self) -> Vec { self.inner .signatures .iter() - .map(|s| s.kid().as_short_id()) + .map(Signature::kid) + .cloned() .collect() } diff --git a/rust/signed_doc/src/validator/rules/ownership/mod.rs b/rust/signed_doc/src/validator/rules/ownership/mod.rs index 95cda06583e..904d782b6cc 100644 --- a/rust/signed_doc/src/validator/rules/ownership/mod.rs +++ b/rust/signed_doc/src/validator/rules/ownership/mod.rs @@ -11,7 +11,6 @@ use catalyst_signed_doc_spec::{ signers::update::{Update, UpdatersType}, DocSpec, }; -use catalyst_types::catalyst_id::CatalystId; use crate::{providers::CatalystSignedDocumentProvider, CatalystSignedDocument}; @@ -105,13 +104,7 @@ impl DocumentOwnershipRule { "A latest version of the document must exist if a first version exists" ))?; - allowed_authors.extend( - last_doc - .doc_meta() - .collaborators() - .iter() - .map(CatalystId::as_short_id), - ); + allowed_authors.extend(last_doc.doc_meta().collaborators().iter().cloned()); } }, Self::RefFieldBased => { @@ -141,13 +134,7 @@ impl DocumentOwnershipRule { "A latest version of the document must exist if a first version exists" ))?; - allowed_authors.extend( - last_doc - .doc_meta() - .collaborators() - .iter() - .map(CatalystId::as_short_id), - ); + allowed_authors.extend(last_doc.doc_meta().collaborators().iter().cloned()); }, } diff --git a/rust/signed_doc/src/validator/rules/signature_kid.rs b/rust/signed_doc/src/validator/rules/signature_kid.rs index fa0d2a58398..c940cbb5aec 100644 --- a/rust/signed_doc/src/validator/rules/signature_kid.rs +++ b/rust/signed_doc/src/validator/rules/signature_kid.rs @@ -56,7 +56,7 @@ impl SignatureKidRule { &self, doc: &CatalystSignedDocument, ) -> anyhow::Result { - let contains_exp_role = doc.kids().iter().enumerate().all(|(i, kid)| { + let contains_exp_role = doc.authors().iter().enumerate().all(|(i, kid)| { let (role_index, _) = kid.role_and_rotation(); let res = self.allowed_roles.contains(&role_index); if !res { diff --git a/rust/signed_doc/tests/common/mod.rs b/rust/signed_doc/tests/common/mod.rs index e309e43695e..c0028429a06 100644 --- a/rust/signed_doc/tests/common/mod.rs +++ b/rust/signed_doc/tests/common/mod.rs @@ -33,7 +33,7 @@ pub fn get_doc_kid_and_sk( doc: &CatalystSignedDocument, i: usize, ) -> anyhow::Result<(ed25519_dalek::SigningKey, CatalystId)> { - let doc_kids = doc.kids(); + let doc_kids = doc.authors(); let kid = doc_kids .get(i) .ok_or(anyhow::anyhow!("does not have a kid at index '{i}'"))?; diff --git a/rust/signed_doc/tests/decoding.rs b/rust/signed_doc/tests/decoding.rs index 2d68d070d43..2fdcf52ce2a 100644 --- a/rust/signed_doc/tests/decoding.rs +++ b/rust/signed_doc/tests/decoding.rs @@ -583,7 +583,7 @@ fn signed_doc_with_minimal_metadata_fields_case() -> TestCase { anyhow::ensure!( doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)? ); - anyhow::ensure!(doc.kids().len() == 1); + anyhow::ensure!(doc.authors().len() == 1); anyhow::ensure!(!doc.is_deprecated()?); Ok(()) } @@ -673,7 +673,7 @@ fn signed_doc_with_complete_metadata_fields_case() -> TestCase { anyhow::ensure!(doc.doc_meta().reply() == Some(&refs)); anyhow::ensure!(doc.doc_content_type() == Some(ContentType::Json)); anyhow::ensure!(doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)?); - anyhow::ensure!(doc.kids().len() == 1); + anyhow::ensure!(doc.authors().len() == 1); anyhow::ensure!(!doc.is_deprecated()?); Ok(()) } @@ -1138,7 +1138,7 @@ fn signed_doc_with_non_strict_deterministic_decoding_wrong_order() -> TestCase { anyhow::ensure!( doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)? ); - anyhow::ensure!(doc.kids().len() == 1); + anyhow::ensure!(doc.authors().len() == 1); Ok(()) } })), @@ -1197,7 +1197,7 @@ fn signed_doc_with_non_supported_metadata_invalid() -> TestCase { anyhow::ensure!( doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)? ); - anyhow::ensure!(doc.kids().len() == 0); + anyhow::ensure!(doc.authors().len() == 0); Ok(()) } })), @@ -1265,7 +1265,7 @@ fn signed_doc_with_kid_in_id_form_invalid() -> TestCase { anyhow::ensure!( doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)? ); - anyhow::ensure!(doc.kids().len() == 1); + anyhow::ensure!(doc.authors().len() == 1); Ok(()) } })),