pub struct Checkpoint {
pub origin: String,
pub size: u64,
pub root: Digest,
}Expand description
A commitment to every run sealed so far.
Deliberately shaped like a C2SP tlog-checkpoint:
an origin naming the log, a size, and a root. Using the interoperable shape
rather than a bespoke one means existing verifiers and witness operators
work — and inventing a format here would buy nothing and cost every
integrator.
Serialize because a checkpoint is the artifact that has to leave: it heads
every export and appears in every audit report, and a reader who has to link
this crate to parse it is not the independent party either exists for.
Deserialize because the same reader hands it back — verifying an export
means comparing a rebuilt root against the checkpoint the file carries.
Checkpoint::to_note remains the interoperable text form for a witness or
a ticket; these are for a consumer already reading JSON.
Fields§
§origin: StringWhich log. A deployment-chosen name, so two planes’ checkpoints cannot
be confused for one another. Held to Checkpoint::validate_origin
when read, so a header or file naming a log no witness would accept is
refused here as it would be there.
size: u64How many runs are committed to.
root: DigestThe Merkle root over their sealed digests.
Implementations§
Source§impl Checkpoint
impl Checkpoint
Sourcepub const MAX_ORIGIN_BYTES: usize = 255
pub const MAX_ORIGIN_BYTES: usize = 255
The longest origin C2SP tlog-cosignature admits, in UTF-8 bytes.
Sourcepub fn validate_origin(origin: &str) -> Result<(), StoreError>
pub fn validate_origin(origin: &str) -> Result<(), StoreError>
Whether origin may name a log, by C2SP tlog-cosignature’s rule: a
non-empty UTF-8 string of at most 255 bytes with no Unicode space, no
+ and no control character below U+0020.
One rule for every door an origin arrives at — a store’s name, a note, an export header, a witness lookup — because a log named one way here and refused by a conforming witness is a log whose checkpoints nobody can cosign, and a newline in it is a note that reads back as another.
§Errors
Naming the class and, for a character, which one.
Sourcepub fn to_note(&self) -> String
pub fn to_note(&self) -> String
The C2SP tlog-checkpoint note body: origin, size, base64 root.
A text form matters more than it looks. A checkpoint is the one artifact that has to leave the operator’s control — handed to an auditor, posted to a witness, pasted into a ticket — and an artifact that only exists as a Rust struct cannot do that. Using the interoperable encoding rather than a bespoke one means the thing they hold is checkable by tools this project did not write.
Sourcepub fn is_coherent(&self) -> bool
pub fn is_coherent(&self) -> bool
Whether this checkpoint’s size and root can both be true.
One pair is checkable without holding the log: the empty tree has
exactly one root, so a checkpoint claiming size 0 beside any other root
is describing a log that cannot exist. That matters more than a tidy
invariant because of what a witness does with a first submission — it
has no prior memory to check against, so it records what it is told and
holds every later checkpoint to it. One incoherent size-0 submission
therefore poisons the origin permanently: every honest checkpoint
afterwards fails consistency against a root no log ever had, and is
reported as Forked — an integrity page, forever, from a single
malformed request.
Trait Implementations§
Source§impl Clone for Checkpoint
impl Clone for Checkpoint
Source§impl Debug for Checkpoint
impl Debug for Checkpoint
Source§impl<'de> Deserialize<'de> for Checkpoint
impl<'de> Deserialize<'de> for Checkpoint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Checkpoint
Source§impl PartialEq for Checkpoint
impl PartialEq for Checkpoint
Source§impl Serialize for Checkpoint
impl Serialize for Checkpoint
impl StructuralPartialEq for Checkpoint
Auto Trait Implementations§
impl Freeze for Checkpoint
impl RefUnwindSafe for Checkpoint
impl Send for Checkpoint
impl Sync for Checkpoint
impl Unpin for Checkpoint
impl UnsafeUnpin for Checkpoint
impl UnwindSafe for Checkpoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more