use alloc::string::String;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum EncodingError {
#[error("cbor serialisation failed: {0}")]
CborSer(String),
#[error("cbor deserialisation failed: {0}")]
CborDe(String),
#[error("json serialisation failed: {0}")]
JsonSer(#[from] serde_json::Error),
#[error("CBOR float encountered: floats MUST NOT appear in conformant Claims")]
FloatForbidden,
#[error("non-canonical CBOR map key order")]
NonCanonicalMapOrder,
}
#[derive(Debug, Error, PartialEq, Eq)]
pub enum CompositionError {
#[error("conjunction: subjects differ and no linkage proof supplied (C-1)")]
SubjectMismatch,
#[error("conjunction: temporal windows do not intersect (C-3)")]
TemporalDisjoint,
#[error("delegation: scope exceeds parent (D-2)")]
ScopeOverflow,
#[error("delegation: cycle detected — chain rejected per RFC 5280 §6.1.3")]
DelegationCycle,
#[error("aggregation: issuer-diversity violation (G-1)")]
IssuerDuplicate,
#[error("aggregation: at least 2 operands required")]
AggregationTooFew,
#[error("restriction: mask non-monotonic (R-1)")]
MaskNonMonotonic,
#[error("restriction: disclosed ∩ committed ≠ ∅ (M-1)")]
MaskDisjointnessViolation,
#[error("revocation: unauthorised revoker (V-1)")]
UnauthorisedRevoker,
#[error("revocation: source already revoked (sticky)")]
AlreadyRevoked,
#[error("structural invariant violated: {0}")]
Invariant(&'static str),
}
#[derive(Debug, Error)]
pub enum TranscriptError {
#[error("transcript: missing field: {0}")]
Missing(&'static str),
#[error("transcript: encoding failed: {0}")]
Encoding(String),
#[error("transcript: version mismatch: claim has {claim:?}, verifier expects {expected:?}")]
VersionMismatch {
claim: alloc::string::String,
expected: alloc::string::String,
},
}