Skip to content

Commit bd4561d

Browse files
committed
wip(rust/signed_doc): implement verification method
* verify doc type, id and ver
1 parent 70440b5 commit bd4561d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

rust/signed_doc/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,36 @@ impl CatalystSignedDocument {
117117
where P: Fn(&KidUri) -> VerifyingKey {
118118
let error_report = ProblemReport::new("Catalyst Signed Document Verification");
119119

120+
if !self.doc_type().is_valid() {
121+
error_report.functional_validation(
122+
&format!("{} is invalid UUIDv4", self.doc_type()),
123+
"During Document Type UUID verification",
124+
);
125+
}
126+
127+
let doc_id = self.doc_id();
128+
if !doc_id.is_valid() {
129+
error_report.functional_validation(
130+
&format!("{doc_id} is invalid UUIDv7"),
131+
"During Document ID UUID verification",
132+
);
133+
}
134+
135+
let doc_ver = self.doc_ver();
136+
if !doc_ver.is_valid() {
137+
error_report.functional_validation(
138+
&format!("{doc_ver} is invalid UUIDv7"),
139+
"During Document Version UUID verification",
140+
);
141+
}
142+
143+
if doc_id.is_valid() && doc_ver.is_valid() && doc_ver < doc_id {
144+
error_report.functional_validation(
145+
&format!("Document Version {doc_ver} is smaller than Document Id {doc_id}"),
146+
"During Document Version UUID verification",
147+
);
148+
}
149+
120150
match self.as_cose_sign() {
121151
Ok(cose_sign) => {
122152
let signatures = self.signatures().cose_signatures();

0 commit comments

Comments
 (0)