Skip to content

Commit 0897cd6

Browse files
committed
feat(rust/signed-doc): add kids and authors methods for signed documents
1 parent ae94111 commit 0897cd6

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

rust/signed_doc/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,27 @@ Catalyst signed document crate implementation based on this
77

88
## Example
99

10-
Generate a `ed25519` private and public keys
10+
### Generate a `ed25519` private and public keys
1111

1212
```shell
1313
openssl genpkey -algorithm=ED25519 -out=private.pem -outpubkey=public.pem
1414
```
1515

16-
Prepare non-signed document,
16+
### Prepare non-signed document,
1717
`meta.json` file should follow the [`meta.schema.json`](./meta.schema.json).
1818

1919
```shell
2020
cargo run -p catalyst-signed-doc --example mk_signed_doc build signed_doc/doc.json signed_doc/doc.cose signed_doc/meta.json
2121
```
2222

23-
Inspect document
23+
### Sign document
24+
`KID` is a valid Catalyst ID URI.
25+
26+
```shell
27+
cargo run -p catalyst-signed-doc --example mk_signed_doc sign signed_doc/doc.cose signed_doc/meta.json <KID>
28+
```
29+
30+
### Inspect document
2431

2532
```shell
2633
cargo run -p catalyst-signed-doc --example mk_signed_doc inspect signed_doc/doc.cose

rust/signed_doc/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,23 @@ impl CatalystSignedDocument {
107107
&self.inner.signatures
108108
}
109109

110+
/// Return a list of Document's Catalyst IDs.
111+
#[must_use]
112+
pub fn kids(&self) -> Vec<IdUri> {
113+
self.inner.signatures.kids()
114+
}
115+
116+
/// Return a list of Document's author IDs (short form of Catalyst IDs).
117+
#[must_use]
118+
pub fn authors(&self) -> Vec<IdUri> {
119+
self.inner
120+
.signatures
121+
.kids()
122+
.into_iter()
123+
.map(|k| k.as_short_id())
124+
.collect()
125+
}
126+
110127
/// Verify document signatures.
111128
///
112129
/// # Errors

0 commit comments

Comments
 (0)