From acbcb91f1e69f8aab5262fb1859a75ed9d94a43f Mon Sep 17 00:00:00 2001 From: Victor Embacher Date: Thu, 27 Jul 2023 09:35:29 +0200 Subject: [PATCH] changed type name from `SignedCheckpoint` to `Checkpoint` Signed-off-by: Victor Embacher --- src/rekor/models/checkpoint.rs | 16 ++++++++-------- src/rekor/models/inclusion_proof.rs | 6 +++--- src/rekor/models/log_info.rs | 10 +++------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/rekor/models/checkpoint.rs b/src/rekor/models/checkpoint.rs index 09c920fafd..5d57238871 100644 --- a/src/rekor/models/checkpoint.rs +++ b/src/rekor/models/checkpoint.rs @@ -15,7 +15,7 @@ use std::str::FromStr; /// The `note` field stores this data, /// and its authenticity can be verified with the data in `signature`. #[derive(Debug, PartialEq, Clone, Eq)] -pub struct SignedCheckpoint { +pub struct Checkpoint { pub note: CheckpointNote, pub signature: CheckpointSignature, } @@ -67,7 +67,7 @@ pub enum ParseCheckpointError { DecodeError(String), } -impl FromStr for SignedCheckpoint { +impl FromStr for Checkpoint { type Err = ParseCheckpointError; fn from_str(s: &str) -> Result { @@ -82,7 +82,7 @@ impl FromStr for SignedCheckpoint { let signature = signature.parse()?; let note = CheckpointNote::unmarshal(note)?; - Ok(SignedCheckpoint { note, signature }) + Ok(Checkpoint { note, signature }) } } @@ -139,7 +139,7 @@ impl CheckpointNote { } } -impl ToString for SignedCheckpoint { +impl ToString for Checkpoint { fn to_string(&self) -> String { let note = self.note.marshal(); let signature = self.signature.to_string(); @@ -147,7 +147,7 @@ impl ToString for SignedCheckpoint { } } -impl SignedCheckpoint { +impl Checkpoint { /// This method can be used to verify that the checkpoint was issued by the log with the /// public key `rekor_key`. pub fn verify_signature(&self, rekor_key: &CosignVerificationKey) -> Result<(), SigstoreError> { @@ -175,7 +175,7 @@ impl SignedCheckpoint { } } -impl Serialize for SignedCheckpoint { +impl Serialize for Checkpoint { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -184,13 +184,13 @@ impl Serialize for SignedCheckpoint { } } -impl<'de> Deserialize<'de> for SignedCheckpoint { +impl<'de> Deserialize<'de> for Checkpoint { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { ::deserialize(deserializer).and_then(|s| { - SignedCheckpoint::from_str(&s).map_err(|DecodeError(err)| serde::de::Error::custom(err)) + Checkpoint::from_str(&s).map_err(|DecodeError(err)| serde::de::Error::custom(err)) }) } } diff --git a/src/rekor/models/inclusion_proof.rs b/src/rekor/models/inclusion_proof.rs index 09bf753fb4..f0bfd53f39 100644 --- a/src/rekor/models/inclusion_proof.rs +++ b/src/rekor/models/inclusion_proof.rs @@ -14,7 +14,7 @@ use crate::crypto::merkle::{ use crate::crypto::CosignVerificationKey; use crate::errors::SigstoreError; use crate::errors::SigstoreError::{InclusionProofError, UnexpectedError}; -use crate::rekor::models::checkpoint::SignedCheckpoint; +use crate::rekor::models::checkpoint::Checkpoint; use crate::rekor::TreeSize; use serde::{Deserialize, Serialize}; @@ -32,7 +32,7 @@ pub struct InclusionProof { /// A list of hashes required to compute the inclusion proof, sorted in order from leaf to root #[serde(rename = "hashes")] pub hashes: Vec, - pub checkpoint: Option, + pub checkpoint: Option, } impl InclusionProof { @@ -41,7 +41,7 @@ impl InclusionProof { root_hash: String, tree_size: TreeSize, hashes: Vec, - checkpoint: Option, + checkpoint: Option, ) -> InclusionProof { InclusionProof { log_index, diff --git a/src/rekor/models/log_info.rs b/src/rekor/models/log_info.rs index 91587e7660..31f536db3b 100644 --- a/src/rekor/models/log_info.rs +++ b/src/rekor/models/log_info.rs @@ -11,7 +11,7 @@ use crate::crypto::merkle::hex_to_hash_output; use crate::crypto::CosignVerificationKey; use crate::errors::SigstoreError; -use crate::rekor::models::checkpoint::SignedCheckpoint; +use crate::rekor::models::checkpoint::Checkpoint; use crate::rekor::models::ConsistencyProof; use crate::rekor::TreeSize; use serde::{Deserialize, Serialize}; @@ -26,7 +26,7 @@ pub struct LogInfo { pub tree_size: TreeSize, /// The current signed tree head #[serde(rename = "signedTreeHead")] - pub signed_tree_head: SignedCheckpoint, + pub signed_tree_head: Checkpoint, /// The current treeID #[serde(rename = "treeID")] pub tree_id: Option, @@ -35,11 +35,7 @@ pub struct LogInfo { } impl LogInfo { - pub fn new( - root_hash: String, - tree_size: TreeSize, - signed_tree_head: SignedCheckpoint, - ) -> LogInfo { + pub fn new(root_hash: String, tree_size: TreeSize, signed_tree_head: Checkpoint) -> LogInfo { LogInfo { root_hash, tree_size,