Skip to content

Commit

Permalink
changed type name from SignedCheckpoint to Checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Embacher <victor@embacher.xyz>
  • Loading branch information
vembacher committed Jul 27, 2023
1 parent 7b8c63f commit acbcb91
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/rekor/models/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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<Self, Self::Err> {
Expand All @@ -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 })
}
}

Expand Down Expand Up @@ -139,15 +139,15 @@ 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();
format!("{note}\n{signature}")
}
}

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> {
Expand Down Expand Up @@ -175,7 +175,7 @@ impl SignedCheckpoint {
}
}

impl Serialize for SignedCheckpoint {
impl Serialize for Checkpoint {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -184,13 +184,13 @@ impl Serialize for SignedCheckpoint {
}
}

impl<'de> Deserialize<'de> for SignedCheckpoint {
impl<'de> Deserialize<'de> for Checkpoint {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
<String>::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))
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/rekor/models/inclusion_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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<String>,
pub checkpoint: Option<SignedCheckpoint>,
pub checkpoint: Option<Checkpoint>,
}

impl InclusionProof {
Expand All @@ -41,7 +41,7 @@ impl InclusionProof {
root_hash: String,
tree_size: TreeSize,
hashes: Vec<String>,
checkpoint: Option<SignedCheckpoint>,
checkpoint: Option<Checkpoint>,
) -> InclusionProof {
InclusionProof {
log_index,
Expand Down
10 changes: 3 additions & 7 deletions src/rekor/models/log_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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<String>,
Expand All @@ -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,
Expand Down

0 comments on commit acbcb91

Please sign in to comment.