pub struct CheckpointBody { /* private fields */ }Expand description
C2SP tlog-checkpoint body: origin, tree size, and RFC 6962 root hash.
The origin is validated against note-name rules at construction — the
origin doubles as the signing key name, so lys-emitted checkpoints
sign under the origin and verifiers enforce the binding.
Implementations§
Source§impl CheckpointBody
impl CheckpointBody
Sourcepub fn new(
origin: &str,
tree_size: u64,
root_hash: [u8; 32],
) -> TrustResult<Self>
pub fn new( origin: &str, tree_size: u64, root_hash: [u8; 32], ) -> TrustResult<Self>
Builds a checkpoint body, validating the origin against the note key-name rules.
§Errors
Returns TrustError::CheckpointEncoding if the origin is empty,
contains whitespace, or contains '+'.
Sourcepub fn from_root(origin: &str, root: &RootHash) -> TrustResult<Self>
pub fn from_root(origin: &str, root: &RootHash) -> TrustResult<Self>
Convenience constructor from the existing merkle root type via
RootHash::to_parts.
§Errors
Returns TrustError::CheckpointEncoding if the origin is invalid
(see Self::new).
Sourcepub fn encode(&self) -> String
pub fn encode(&self) -> String
Encodes the body as exactly
"{origin}\n{tree_size}\n{base64_std_padded(root_hash)}\n".
Sourcepub fn parse(text: &str) -> TrustResult<Self>
pub fn parse(text: &str) -> TrustResult<Self>
Strict parse of a body (typically one returned by verify_note).
Line 1: a valid origin per the note key-name rules. Line 2: ASCII
decimal u64, no leading zeros unless the value is "0", no sign,
no whitespace. Line 3: exactly 44 base64 characters decoding
canonically to 32 bytes. Extension lines (non-empty lines after
line 3) are tolerated and discarded, per the C2SP spec; an empty
line anywhere is malformed (bodies cannot contain blank lines — see
super::note::sign_note).
§Errors
Returns TrustError::CheckpointParsing on any violation,
including a body that does not end with '\n'.