Skip to main content

structured_ltv/
baseline.rs

1//! Composition of source-bound long-term facts over a format's stage reports.
2//!
3//! Each format supplies its own basic stage and material reports through the
4//! traits here. [`timestamped`] joins the whole TSA-path census with every
5//! signature timestamp's static association; [`long_term`] links the X.509 and
6//! credential material reports to the SAME participant census; for each
7//! archive [`archive_material`] joins that archive's reports and [`archives`]
8//! requires one for every original archive. Additional reports never promote
9//! a requested level and no report here is a trust verdict.
10
11use crate::pki::{CounterReceipts, ParticipantRequirements, SignerReceipt};
12use crate::source::{Location, Snapshot};
13use crate::timestamp::TimestampScope;
14
15mod archive;
16mod material;
17mod timed;
18
19pub use archive::{
20    ArchiveCensusError, ArchiveMaterial, ArchiveMaterialResult, Archives, ArchivesResult,
21    archive_material, archives,
22};
23pub use material::{LongTerm, MaterialResult, long_term};
24pub use timed::{
25    SignatureTimeFact, TimeError, TimeResult, Timed, timestamped, timestamped_existence,
26};
27
28/// A format's basic stage: the signer and countersignature receipts it was
29/// built from, and whether every requirement of the format's basic level holds.
30pub trait BasicStage<'path, 'document> {
31    /// Original node identity.
32    type Id: Copy;
33    /// Stable document identity.
34    type Document: Copy;
35    /// Exact document generation.
36    type Generation: Copy;
37    /// The signing-certificate binding receipt.
38    type Signer: SignerReceipt<
39            'path,
40            'document,
41            Id = Self::Id,
42            Document = Self::Document,
43            Generation = Self::Generation,
44        >;
45    /// The complete countersignature census.
46    type Counters: CounterReceipts<
47            'path,
48            'document,
49            Id = Self::Id,
50            Document = Self::Document,
51            Generation = Self::Generation,
52        >;
53
54    /// Same signer receipt the stage checked.
55    fn signer(&self) -> &Self::Signer;
56    /// Same countersignature census the stage checked.
57    fn counters(&self) -> &Self::Counters;
58    /// Every condition of the format's basic level holds.
59    fn all_requirements_met(&self) -> bool;
60}
61
62/// A format's whole-signature X.509 material report.
63pub trait X509Material<'path, 'document> {
64    /// Original node identity.
65    type Id: Copy;
66    /// Stable document identity.
67    type Document: Copy;
68    /// Exact document generation.
69    type Generation: Copy;
70    /// Issuer of the receipts the report was derived from.
71    type Issuer;
72
73    /// The participant census the report was derived from.
74    fn requirements(
75        &self,
76    ) -> &ParticipantRequirements<
77        'path,
78        'document,
79        Self::Id,
80        Self::Document,
81        Self::Generation,
82        Self::Issuer,
83    >;
84    /// Every X.509 presence and placement requirement of the format holds.
85    fn all_x509_requirements_met(&self) -> bool;
86}
87
88/// A format's credential-material report for one validation-data scope.
89pub trait CredentialMaterial {
90    /// Original node identity.
91    type Id: Copy;
92    /// Stable document identity.
93    type Document: Copy;
94    /// Exact document generation.
95    type Generation: Copy;
96    /// The authenticated credential census the report checked.
97    type Credentials;
98
99    /// Whole-signature or preceding-archive scope of the report.
100    fn scope(&self) -> TimestampScope<Self::Id, Self::Document, Self::Generation>;
101    /// Source generation of the authenticated credential census.
102    fn snapshot(&self) -> Snapshot<Self::Document, Self::Generation>;
103    /// Same authenticated credential census, by reference.
104    fn credentials(&self) -> &Self::Credentials;
105    /// Every credential's own format material is present and interpreted.
106    fn all_requirements_met(&self) -> bool;
107}
108
109/// A format's census of one signature's timestamps, in original order.
110pub trait ArchiveCensus {
111    /// Original node identity.
112    type Id: Copy;
113    /// Stable document identity.
114    type Document: Copy;
115    /// Exact document generation.
116    type Generation: Copy;
117
118    /// The signature whose timestamps these are.
119    fn signature(&self) -> Location<Self::Id, Self::Document, Self::Generation>;
120    /// Number of timestamps of every kind.
121    fn timestamps(&self) -> usize;
122    /// The original archive input subject at this ordinal, or `None` for
123    /// another kind of input. Match the format's `Coverage::subject`: a token
124    /// for member-specific inputs, or the property for property-shared input.
125    ///
126    /// # Panics
127    /// When `ordinal` is not below [`Self::timestamps`].
128    fn archive(&self, ordinal: usize) -> Option<Self::Id>;
129}