1use alloc::string::String;
4use thiserror::Error;
5
6#[derive(Debug, Error)]
8pub enum EncodingError {
9 #[error("cbor serialisation failed: {0}")]
11 CborSer(String),
12
13 #[error("cbor deserialisation failed: {0}")]
15 CborDe(String),
16
17 #[error("json serialisation failed: {0}")]
19 JsonSer(#[from] serde_json::Error),
20
21 #[error("CBOR float encountered: floats MUST NOT appear in conformant Claims")]
23 FloatForbidden,
24
25 #[error("non-canonical CBOR map key order")]
27 NonCanonicalMapOrder,
28}
29
30#[derive(Debug, Error, PartialEq, Eq)]
32pub enum CompositionError {
33 #[error("conjunction: subjects differ and no linkage proof supplied (C-1)")]
35 SubjectMismatch,
36
37 #[error("conjunction: temporal windows do not intersect (C-3)")]
39 TemporalDisjoint,
40
41 #[error("delegation: scope exceeds parent (D-2)")]
43 ScopeOverflow,
44
45 #[error("delegation: cycle detected — chain rejected per RFC 5280 §6.1.3")]
47 DelegationCycle,
48
49 #[error("aggregation: issuer-diversity violation (G-1)")]
51 IssuerDuplicate,
52
53 #[error("aggregation: at least 2 operands required")]
55 AggregationTooFew,
56
57 #[error("restriction: mask non-monotonic (R-1)")]
59 MaskNonMonotonic,
60
61 #[error("restriction: disclosed ∩ committed ≠ ∅ (M-1)")]
63 MaskDisjointnessViolation,
64
65 #[error("revocation: unauthorised revoker (V-1)")]
68 UnauthorisedRevoker,
69
70 #[error("revocation: source already revoked (sticky)")]
72 AlreadyRevoked,
73
74 #[error("structural invariant violated: {0}")]
76 Invariant(&'static str),
77}
78
79#[derive(Debug, Error)]
81pub enum TranscriptError {
82 #[error("transcript: missing field: {0}")]
84 Missing(&'static str),
85
86 #[error("transcript: encoding failed: {0}")]
88 Encoding(String),
89
90 #[error("transcript: version mismatch: claim has {claim:?}, verifier expects {expected:?}")]
93 VersionMismatch {
94 claim: alloc::string::String,
96 expected: alloc::string::String,
98 },
99}