Skip to content

Commit 6bf6274

Browse files
committed
fix(rust/signed-doc): update KID to use catalyst-id type
1 parent ba6eb18 commit 6bf6274

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

rust/signed_doc/examples/mk_signed_doc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
path::PathBuf,
99
};
1010

11-
use catalyst_signed_doc::{Builder, CatalystSignedDocument, KidUri, Metadata};
11+
use catalyst_signed_doc::{Builder, CatalystSignedDocument, IdUri, Metadata};
1212
use clap::Parser;
1313
use ed25519_dalek::pkcs8::{DecodePrivateKey, DecodePublicKey};
1414

@@ -39,7 +39,7 @@ enum Cli {
3939
/// Path to the secret key in PEM format
4040
sk: PathBuf,
4141
/// Signer kid
42-
kid: KidUri,
42+
kid: IdUri,
4343
},
4444
/// Inspects Catalyst Signed Document
4545
Inspect {
@@ -59,7 +59,7 @@ enum Cli {
5959
/// Path to the verifying key in PEM format
6060
pk: PathBuf,
6161
/// Signer kid
62-
kid: KidUri,
62+
kid: IdUri,
6363
},
6464
}
6565

rust/signed_doc/src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Catalyst Signed Document Builder.
2-
use catalyst_types::kid_uri::KidUri;
2+
use catalyst_types::id_uri::IdUri;
33
use ed25519_dalek::{ed25519::signature::Signer, SecretKey};
44

55
use crate::{CatalystSignedDocument, Content, InnerCatalystSignedDocument, Metadata, Signatures};
@@ -50,7 +50,7 @@ impl Builder {
5050
/// Fails if a `CatalystSignedDocument` cannot be created due to missing metadata or
5151
/// content, due to malformed data, or when the signed document cannot be
5252
/// converted into `coset::CoseSign`.
53-
pub fn add_signature(self, sk: SecretKey, kid: KidUri) -> anyhow::Result<Self> {
53+
pub fn add_signature(self, sk: SecretKey, kid: IdUri) -> anyhow::Result<Self> {
5454
let cose_sign = self
5555
.clone()
5656
.build()

rust/signed_doc/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use ed25519_dalek::VerifyingKey;
2121
use error::CatalystSignedDocError;
2222
pub use metadata::{DocumentRef, ExtraFields, Metadata, UuidV4, UuidV7};
2323
pub use minicbor::{decode, encode, Decode, Decoder, Encode};
24-
pub use signature::{KidUri, Signatures};
24+
pub use signature::{IdUri, Signatures};
2525
use utils::context::DecodeSignDocCtx;
2626

2727
/// Inner type that holds the Catalyst Signed Document with parsing errors.
@@ -114,7 +114,7 @@ impl CatalystSignedDocument {
114114
/// Returns a report of verification failures and the source error.
115115
#[allow(clippy::indexing_slicing)]
116116
pub fn verify<P>(&self, pk_getter: P) -> Result<(), CatalystSignedDocError>
117-
where P: Fn(&KidUri) -> VerifyingKey {
117+
where P: Fn(&IdUri) -> VerifyingKey {
118118
let error_report = ProblemReport::new("Catalyst Signed Document Verification");
119119

120120
match self.as_cose_sign() {
@@ -386,11 +386,11 @@ mod tests {
386386
let pk = sk.verifying_key();
387387

388388
let kid_str = format!(
389-
"kid.catalyst-rbac://cardano/{}/0/0",
389+
"id.catalyst://cardano/{}/0/0",
390390
base64_url::encode(pk.as_bytes())
391391
);
392392

393-
let kid = KidUri::from_str(&kid_str).unwrap();
393+
let kid = IdUri::from_str(&kid_str).unwrap();
394394
let (_, _, metadata) = test_metadata().unwrap();
395395
let signed_doc = Builder::new()
396396
.with_decoded_content(content)

rust/signed_doc/src/signature/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
//! Catalyst Signed Document COSE Signature information.
22
33
use anyhow::bail;
4-
pub use catalyst_types::kid_uri::KidUri;
4+
pub use catalyst_types::id_uri::IdUri;
55
use catalyst_types::problem_report::ProblemReport;
66
use coset::CoseSignature;
77

88
/// Catalyst Signed Document COSE Signature.
99
#[derive(Debug, Clone)]
1010
pub struct Signature {
1111
/// Key ID
12-
kid: KidUri,
12+
kid: IdUri,
1313
/// COSE Signature
1414
signature: CoseSignature,
1515
}
@@ -27,7 +27,7 @@ impl Signatures {
2727

2828
/// List of signature Key IDs.
2929
#[must_use]
30-
pub fn kids(&self) -> Vec<KidUri> {
30+
pub fn kids(&self) -> Vec<IdUri> {
3131
self.0.iter().map(|sig| sig.kid.clone()).collect()
3232
}
3333

@@ -38,7 +38,7 @@ impl Signatures {
3838
}
3939

4040
/// Add a new signature
41-
pub fn push(&mut self, kid: KidUri, signature: CoseSignature) {
41+
pub fn push(&mut self, kid: IdUri, signature: CoseSignature) {
4242
self.0.push(Signature { kid, signature });
4343
}
4444

@@ -65,14 +65,14 @@ impl Signatures {
6565
.cloned()
6666
.enumerate()
6767
.for_each(|(idx, signature)| {
68-
match KidUri::try_from(signature.protected.header.key_id.as_ref()) {
68+
match IdUri::try_from(signature.protected.header.key_id.as_ref()) {
6969
Ok(kid) => signatures.push(Signature { kid, signature }),
7070
Err(e) => {
7171
error_report.conversion_error(
7272
&format!("COSE signature protected header key ID at id {idx}"),
7373
&format!("{:?}", &signature.protected.header.key_id),
7474
&format!("{e:?}"),
75-
"Converting COSE signature header key ID to KidUri",
75+
"Converting COSE signature header key ID to IdUri",
7676
);
7777
},
7878
}

0 commit comments

Comments
 (0)