Skip to main content

Checkpoint

Struct Checkpoint 

Source
pub struct Checkpoint { /* private fields */ }
Expand description

A parsed checkpoint (signed-tree-head body).

Implementations§

Source§

impl Checkpoint

Source

pub fn new(origin: &str, size: u64, root_hash: Hash) -> Result<Self>

Build a checkpoint with no extension lines.

§Errors

Returns Error::MalformedCheckpoint if origin is empty or contains a newline.

Source

pub fn with_extensions( origin: &str, size: u64, root_hash: Hash, extensions: Vec<String>, ) -> Result<Self>

Build a checkpoint with explicit extension lines.

§Errors

Returns Error::MalformedCheckpoint if origin is empty/contains a newline, or any extension line is empty or contains a newline.

Source

pub fn origin(&self) -> &str

The log origin (identity) line.

Source

pub fn size(&self) -> u64

The tree size (number of leaves).

Source

pub fn root_hash(&self) -> &Hash

The RFC 6962 root hash at this tree size.

Source

pub fn extensions(&self) -> &[String]

The opaque extension lines (usually empty).

Source

pub fn parse(text: &str) -> Result<Self>

Parse a checkpoint body (the note text), byte-for-byte per the spec.

§Errors

Returns Error::MalformedCheckpoint for a missing/empty origin, a non-decimal or leading-zero size, a root hash that is not exactly 32 bytes once base64-decoded, fewer than three lines, or an empty extension line.

Source

pub fn marshal(&self) -> String

Serialize the checkpoint body (the note text), ending in a newline.

Source

pub fn from_signed_note(msg: &str, trusted: &[VerifierKey]) -> Result<Self>

Parse and verify a full signed checkpoint, returning the checkpoint body.

The msg is the complete signed note (body + blank line + signature lines). It is verified against trusted (at least one trusted signature — e.g. the log’s Ed25519 key, or a witness co-signature — must verify), then its body is parsed as a checkpoint.

§Errors

Propagates crate::note::SignedNote::parse / verify errors and Checkpoint::parse errors.

Source

pub fn verify_inclusion( &self, leaf_index: u64, leaf_hash: &[u8], proof: &[Vec<u8>], ) -> Result<()>

Verify that leaf_hash is included at leaf_index in the tree committed by this checkpoint, using the Slice-1 RFC 6962/9162 verifier.

§Errors

Propagates crate::proof::verify_inclusion errors (index out of range, wrong proof size, hash-length, or root mismatch).

Source

pub fn verify_consistency( &self, newer: &Checkpoint, proof: &[Vec<u8>], ) -> Result<()>

Verify that this (older) checkpoint is consistent with a newer one — i.e. the newer tree is an append-only extension — using the Slice-1 RFC 6962/9162 consistency verifier. This is the anti-equivocation walk a monitor performs across checkpoints.

§Errors

Propagates crate::proof::verify_consistency errors, including a root mismatch if the proof does not bind both tree heads.

Trait Implementations§

Source§

impl Clone for Checkpoint

Source§

fn clone(&self) -> Checkpoint

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Checkpoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Checkpoint

Source§

impl PartialEq for Checkpoint

Source§

fn eq(&self, other: &Checkpoint) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Checkpoint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.