Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ pub struct PublicKey {

impl PublicKey {
/// Verify that `sig` is a valid signature on `data` from this key.
///
/// # Panics
///
/// Panics if the public key bytes are not a valid Ed25519 public key.
pub fn verify_signature(&self, data: impl AsRef<[u8]>, sig: &Signature) -> bool {
let verifier = ed25519_dalek::VerifyingKey::from_bytes(&self.bytes).unwrap();
let signature = ed25519_dalek::Signature::from(&sig.bytes);
Expand Down
8 changes: 4 additions & 4 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use crate::crypto::{Hash, PublicKey, Signature};

#[derive(Debug, Clone, PartialEq)]
/// A signed tree head, as returned by the get-tree-head endpoint.
#[derive(Debug, Clone, PartialEq)]
pub struct SignedTreeHead {
pub size: u64,
pub root_hash: Hash,
Expand All @@ -19,23 +19,23 @@ pub struct WitnessCosignature {
pub cosignature: Signature,
}

#[derive(Debug, Clone, PartialEq)]
/// An inclusion proof, as returned by the get-inclusion-proof endpoint.
#[derive(Debug, Clone, PartialEq)]
pub struct InclusionProof {
pub leaf_index: u64,
pub node_hashes: Vec<Hash>,
}

#[derive(Debug, Clone, PartialEq)]
/// A protoleaf, which is the data submitted to the add-leaf endpoint of a Sigsum log.
#[derive(Debug, Clone, PartialEq)]
pub struct Protoleaf {
pub message: Hash,
pub signature: Signature,
pub public_key: PublicKey,
}

#[derive(Debug, Clone, PartialEq)]
/// A tree leaf, as stored in a sigsum log.
#[derive(Debug, Clone, PartialEq)]
pub struct Leaf {
pub digest: Hash,
pub signature: Signature,
Expand Down
2 changes: 1 addition & 1 deletion src/policy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub enum PolicyError {
#[error("duplicate name")]
DuplicateName(String),

#[error("{0}: no sutch witness")]
#[error("{0}: no such witness")]
UnknownName(String),

#[error("quorum already set")]
Expand Down
2 changes: 1 addition & 1 deletion src/policy/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ mod tests {
);
insta::assert_snapshot!(
parse_policy("quorum foo").unwrap_err(),
@"line 1: invalid quorum rule: foo: no sutch witness",
@"line 1: invalid quorum rule: foo: no such witness",
);
}

Expand Down