Skip to main content

Checkpoint

Struct Checkpoint 

Source
pub struct Checkpoint {
    pub epoch: u64,
    pub timestamp: Tstamp,
    pub merkle_root: MerkleHash,
    pub log_size: u64,
    pub signature: BlsSig,
    pub signers: Vec<BlsPubkey>,
}
Expand description

Checkpoint is a BLS-signed snapshot of the Merkle log at a given epoch.

Checkpoint records the Merkle root, log size, and the aggregate BLS signature from anchor nodes that attested to this state. Use Checkpoint::verify to confirm that a quorum of trusted anchors signed the checkpoint before trusting any identity proofs that reference it.

Fields§

§epoch: u64

Monotonically increasing checkpoint sequence number.

§timestamp: Tstamp

Unix timestamp (nanoseconds) when the checkpoint was created.

§merkle_root: MerkleHash

Merkle root hash of the log at this checkpoint.

§log_size: u64

Number of entries in the log at this checkpoint.

§signature: BlsSig

Aggregated BLS signature from all signing anchor nodes.

§signers: Vec<BlsPubkey>

BLS public keys of the anchors that contributed to signature.

Implementations§

Source§

impl Checkpoint

Source

pub fn new( epoch: u64, timestamp: Tstamp, merkle_root: MerkleHash, log_size: u64, ) -> Result<Self, Error>

new creates an unsigned checkpoint for the given log state.

After creation, each anchor in the quorum must call sign to add its BLS signature before the checkpoint can be verified.

§Errors

Returns Err if the C library call fails (e.g. invalid parameters).

Source

pub fn sign(&mut self, anchor_kp: &BlsKeypair) -> Result<(), Error>

sign adds this anchor’s BLS signature to the checkpoint.

Multiple anchors may call sign independently; the resulting signatures are aggregated by the C library. Once enough anchors have signed, verify will succeed against the corresponding AnchorSet.

§Errors

Returns Err if signing fails (e.g. invalid keypair or message).

Source

pub fn verify(&self, anchor_set: &AnchorSet) -> Result<(), Error>

verify checks that a quorum of anchors from anchor_set have signed this checkpoint.

Confirms that the aggregate BLS signature in self.signature is a valid signature by at least anchor_set.threshold() of the registered anchor keys over the canonical checkpoint message (epoch + timestamp + merkle_root + log_size).

§Errors

Returns Err if the signature is invalid, insufficient signers, or a C error occurs.

Source

pub fn encode(&self) -> Result<Vec<u8>, Error>

encode serializes the checkpoint to a byte vector for storage or transmission.

§Errors

Returns Err if serialization fails.

Source

pub fn decode(data: &[u8]) -> Result<Self, Error>

decode deserializes a checkpoint from bytes produced by encode.

§Errors

Returns Err if data is truncated or malformed.

Source

pub fn message(&self) -> Result<Vec<u8>, Error>

message returns the canonical CHECKPOINT_MESSAGE_SIZE-byte byte string that anchors sign.

The message is the concatenation of epoch, timestamp, merkle_root, and log_size, all in big-endian byte order. This is the exact byte string passed to BLS signing.

§Errors

Returns Err if the C library call fails.

Trait Implementations§

Source§

impl Clone for Checkpoint

Source§

fn clone(&self) -> Checkpoint

Returns a duplicate of the value. Read more
1.0.0 · 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

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> 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.