iop_morpheus_proto/data/
claim.rs

1use super::*;
2
3use crate::crypto::{
4    hash::{Content, ContentId},
5    sign::Signable,
6};
7use crate::data::{did::Did, process::ProcessId, schema::MorpheusValue};
8
9pub type ClaimId = ContentId;
10
11#[derive(Clone, Debug, Deserialize, Serialize)]
12pub struct Claim {
13    #[serde(with = "serde_str")]
14    pub subject: Did,
15    pub content: MorpheusValue,
16}
17
18impl Content for Claim {}
19impl Signable for Claim {}
20
21// TODO Eq, PartialEq and maybe PartialOrd for WitnessRequest
22#[derive(Clone, Debug, Deserialize, Serialize)]
23pub struct WitnessRequest {
24    #[serde(with = "serde_str", rename = "processId")]
25    pub process_id: ProcessId,
26    pub claimant: String, // TODO should be an AuthenticationLink on the long term
27    pub claim: Claim,
28    pub evidence: MorpheusValue,
29    #[serde(skip_serializing_if = "Option::is_none", default)]
30    pub nonce: Option<Nonce264>,
31}
32
33impl Content for WitnessRequest {}
34impl Signable for WitnessRequest {}
35
36// TODO Eq, PartialEq and maybe PartialOrd for WitnessStatement
37#[derive(Clone, Debug, Deserialize, Serialize)]
38pub struct WitnessStatement {
39    #[serde(with = "serde_str", rename = "processId")]
40    pub process_id: ProcessId,
41    pub claim: Claim,
42    pub constraints: Constraints,
43    #[serde(skip_serializing_if = "Option::is_none", default)]
44    pub nonce: Option<Nonce264>,
45}
46
47#[derive(Clone, Debug, Deserialize, Serialize)]
48pub struct Constraints {
49    pub after: Option<String>,
50    pub before: Option<String>,
51    pub witness: String, // TODO should be an AuthenticationLink on the long term
52    #[serde(with = "serde_str")]
53    pub authority: Did,
54    pub content: MorpheusValue,
55}
56
57impl Content for WitnessStatement {}
58impl Signable for WitnessStatement {}