keetanetwork-vote 0.3.0

Vote and VoteStaple model, codec, and signing for Keetanetwork blockchain
docs.rs failed to build keetanetwork-vote-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

Keeta Network Vote and VoteStaple

This crate models a representative's signed commitment that a set of Blocks should be inserted into the ledger and the canonical bundle (VoteStaple) by which those commitments propagate between operators.

Concepts

  • Vote: a DER-encoded certificate-shaped commitment from an issuing representative covering one or more block hashes. Carries an optional fee schedule and a validity window.
  • Vote quote: a non-binding vote whose fees field has quote = true. Used during fee negotiation; cannot be stapled or used to confirm blocks.
  • Possibly expired vote: a vote that has been parsed and signature- verified but whose validity window may have ended. Surfaced for inspection paths that should not commit to inclusion.
  • Vote staple: a zlib-compressed DER bundle of one or more votes together with the blocks they cover. The wire artifact transmitted between operators.

Construction

Use [VoteBuilder] or [VoteQuoteBuilder] to assemble and sign a vote and [VoteStapleBuilder] to bundle votes and blocks into a staple. The builders validate eagerly and surface configuration errors as [VoteError] variants.

Example

use std::sync::Arc;

use keetanetwork_account::GenericAccount;
use keetanetwork_account::doc_utils::create_ed25519_test_keys;
use keetanetwork_block::{AccountRef, BlockTime};
use keetanetwork_vote::{VoteBuilder, VoteError};

# fn main() -> Result<(), VoteError> {
let (_, _, signer) = create_ed25519_test_keys(None);
let issuer: AccountRef = Arc::new(GenericAccount::Ed25519(signer));

let from = BlockTime::from_unix_millis(1_000_000).expect("moment in range");
let to = BlockTime::from_unix_millis(2_000_000).expect("moment in range");

let vote = VoteBuilder::new()
    .serial(1u64)
    .issuer(issuer.clone())
    .validity(from, to)
    .add_block(issuer.to_opening_hash())
    .build_signed(issuer.as_ref())?;

assert!(!vote.as_bytes().is_empty());
# Ok(())
# }

Verification

[Vote::verify] decodes wire bytes, rejects any non-canonical DER, and checks the issuer's signature. [VoteStaple::verify] additionally enforces the staple invariants (canonical ordering, agreed block set, single-issuer constraint, uniform permanence) at a caller-supplied moment.