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: u64Monotonically increasing checkpoint sequence number.
timestamp: TstampUnix timestamp (nanoseconds) when the checkpoint was created.
merkle_root: MerkleHashMerkle root hash of the log at this checkpoint.
log_size: u64Number of entries in the log at this checkpoint.
signature: BlsSigAggregated BLS signature from all signing anchor nodes.
signers: Vec<BlsPubkey>BLS public keys of the anchors that contributed to signature.
Implementations§
Source§impl Checkpoint
impl Checkpoint
Sourcepub fn new(
epoch: u64,
timestamp: Tstamp,
merkle_root: MerkleHash,
log_size: u64,
) -> Result<Self, Error>
pub fn new( epoch: u64, timestamp: Tstamp, merkle_root: MerkleHash, log_size: u64, ) -> Result<Self, Error>
Sourcepub fn sign(&mut self, anchor_kp: &BlsKeypair) -> Result<(), Error>
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).
Sourcepub fn verify(&self, anchor_set: &AnchorSet) -> Result<(), Error>
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.
Sourcepub fn encode(&self) -> Result<Vec<u8>, Error>
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.
Sourcepub fn message(&self) -> Result<Vec<u8>, Error>
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
impl Clone for Checkpoint
Source§fn clone(&self) -> Checkpoint
fn clone(&self) -> Checkpoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more