Skip to content

Commit 07d7935

Browse files
committed
wip
1 parent cf4b8ec commit 07d7935

File tree

6 files changed

+16
-38
lines changed

6 files changed

+16
-38
lines changed

rust/signed_doc/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "catalyst-signed-doc"
3-
version = "0.0.8"
3+
version = "0.0.9"
44
edition.workspace = true
55
authors.workspace = true
66
homepage.workspace = true
@@ -11,7 +11,7 @@ license.workspace = true
1111
workspace = true
1212

1313
[dependencies]
14-
catalyst-types = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.8" }
14+
catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" }
1515
cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" }
1616

1717
catalyst-signed-doc-macro = { version = "0.0.1", path = "../catalyst-signed-doc-macro" }

rust/signed_doc/src/lib.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ impl Display for CatalystSignedDocument {
6969
if self.inner.signatures.is_empty() {
7070
writeln!(f, " This document is unsigned.")?;
7171
} else {
72-
for kid in &self.kids() {
73-
writeln!(f, " Signature Key ID: {kid}")?;
72+
for kid in &self.authors() {
73+
writeln!(f, " Author ID: {kid}")?;
7474
}
7575
}
7676
Ok(())
@@ -161,23 +161,14 @@ impl CatalystSignedDocument {
161161
&self.inner.signatures
162162
}
163163

164-
/// Return a list of Document's Catalyst IDs.
165-
#[must_use]
166-
pub fn kids(&self) -> Vec<CatalystId> {
167-
self.inner
168-
.signatures
169-
.iter()
170-
.map(|s| s.kid().clone())
171-
.collect()
172-
}
173-
174-
/// Return a list of Document's author IDs (short form of Catalyst IDs).
164+
/// Return a list of Document's Signer's Catalyst IDs,
175165
#[must_use]
176166
pub fn authors(&self) -> Vec<CatalystId> {
177167
self.inner
178168
.signatures
179169
.iter()
180-
.map(|s| s.kid().as_short_id())
170+
.map(|s| s.kid())
171+
.cloned()
181172
.collect()
182173
}
183174

rust/signed_doc/src/validator/rules/ownership/mod.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use catalyst_signed_doc_spec::{
1111
signers::update::{Update, UpdatersType},
1212
DocSpec,
1313
};
14-
use catalyst_types::catalyst_id::CatalystId;
1514

1615
use crate::{providers::CatalystSignedDocumentProvider, CatalystSignedDocument};
1716

@@ -105,13 +104,7 @@ impl DocumentOwnershipRule {
105104
"A latest version of the document must exist if a first version exists"
106105
))?;
107106

108-
allowed_authors.extend(
109-
last_doc
110-
.doc_meta()
111-
.collaborators()
112-
.iter()
113-
.map(CatalystId::as_short_id),
114-
);
107+
allowed_authors.extend(last_doc.doc_meta().collaborators().iter().cloned());
115108
}
116109
},
117110
Self::RefFieldBased => {
@@ -141,13 +134,7 @@ impl DocumentOwnershipRule {
141134
"A latest version of the document must exist if a first version exists"
142135
))?;
143136

144-
allowed_authors.extend(
145-
last_doc
146-
.doc_meta()
147-
.collaborators()
148-
.iter()
149-
.map(CatalystId::as_short_id),
150-
);
137+
allowed_authors.extend(last_doc.doc_meta().collaborators().iter().cloned());
151138
},
152139
}
153140

rust/signed_doc/src/validator/rules/signature_kid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl SignatureKidRule {
5656
&self,
5757
doc: &CatalystSignedDocument,
5858
) -> anyhow::Result<bool> {
59-
let contains_exp_role = doc.kids().iter().enumerate().all(|(i, kid)| {
59+
let contains_exp_role = doc.authors().iter().enumerate().all(|(i, kid)| {
6060
let (role_index, _) = kid.role_and_rotation();
6161
let res = self.allowed_roles.contains(&role_index);
6262
if !res {

rust/signed_doc/tests/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn get_doc_kid_and_sk(
3333
doc: &CatalystSignedDocument,
3434
i: usize,
3535
) -> anyhow::Result<(ed25519_dalek::SigningKey, CatalystId)> {
36-
let doc_kids = doc.kids();
36+
let doc_kids = doc.authors();
3737
let kid = doc_kids
3838
.get(i)
3939
.ok_or(anyhow::anyhow!("does not have a kid at index '{i}'"))?;

rust/signed_doc/tests/decoding.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ fn signed_doc_with_minimal_metadata_fields_case() -> TestCase {
583583
anyhow::ensure!(
584584
doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)?
585585
);
586-
anyhow::ensure!(doc.kids().len() == 1);
586+
anyhow::ensure!(doc.authors().len() == 1);
587587
anyhow::ensure!(!doc.is_deprecated()?);
588588
Ok(())
589589
}
@@ -673,7 +673,7 @@ fn signed_doc_with_complete_metadata_fields_case() -> TestCase {
673673
anyhow::ensure!(doc.doc_meta().reply() == Some(&refs));
674674
anyhow::ensure!(doc.doc_content_type() == Some(ContentType::Json));
675675
anyhow::ensure!(doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)?);
676-
anyhow::ensure!(doc.kids().len() == 1);
676+
anyhow::ensure!(doc.authors().len() == 1);
677677
anyhow::ensure!(!doc.is_deprecated()?);
678678
Ok(())
679679
}
@@ -1138,7 +1138,7 @@ fn signed_doc_with_non_strict_deterministic_decoding_wrong_order() -> TestCase {
11381138
anyhow::ensure!(
11391139
doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)?
11401140
);
1141-
anyhow::ensure!(doc.kids().len() == 1);
1141+
anyhow::ensure!(doc.authors().len() == 1);
11421142
Ok(())
11431143
}
11441144
})),
@@ -1197,7 +1197,7 @@ fn signed_doc_with_non_supported_metadata_invalid() -> TestCase {
11971197
anyhow::ensure!(
11981198
doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)?
11991199
);
1200-
anyhow::ensure!(doc.kids().len() == 0);
1200+
anyhow::ensure!(doc.authors().len() == 0);
12011201
Ok(())
12021202
}
12031203
})),
@@ -1265,7 +1265,7 @@ fn signed_doc_with_kid_in_id_form_invalid() -> TestCase {
12651265
anyhow::ensure!(
12661266
doc.encoded_content() == serde_json::to_vec(&serde_json::Value::Null)?
12671267
);
1268-
anyhow::ensure!(doc.kids().len() == 1);
1268+
anyhow::ensure!(doc.authors().len() == 1);
12691269
Ok(())
12701270
}
12711271
})),

0 commit comments

Comments
 (0)