Skip to content

Commit 900423e

Browse files
committed
consolidated methods
Signed-off-by: Victor Embacher <[email protected]>
1 parent c1eadee commit 900423e

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

src/rekor/models/checkpoint.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::crypto::merkle::{MerkleProofVerifier, Rfc6269Default};
22
use crate::crypto::{CosignVerificationKey, Signature};
33
use crate::errors::SigstoreError;
4-
use crate::errors::SigstoreError::{ConsistencyProofError, UnexpectedError};
4+
use crate::errors::SigstoreError::ConsistencyProofError;
55
use crate::rekor::models::checkpoint::ParseCheckpointError::*;
66
use base64::prelude::BASE64_STANDARD;
77
use base64::Engine;
@@ -158,7 +158,7 @@ impl SignedCheckpoint {
158158
}
159159

160160
/// Checks if the checkpoint and inclusion proof are valid together.
161-
pub(crate) fn valid_consistency_proof(
161+
pub(crate) fn is_valid_for_proof(
162162
&self,
163163
proof_root_hash: &Output<Rfc6269Default>,
164164
proof_tree_size: u64,
@@ -173,18 +173,6 @@ impl SignedCheckpoint {
173173
)
174174
.map_err(ConsistencyProofError)
175175
}
176-
177-
/// Verifies that the checkpoint can be used for an inclusion proof with this root hash.
178-
pub(crate) fn valid_inclusion_proof(
179-
&self,
180-
proof_root_hash: &Output<Rfc6269Default>,
181-
) -> Result<(), SigstoreError> {
182-
Rfc6269Default::verify_match(proof_root_hash, &self.note.hash.into()).map_err(|_| {
183-
UnexpectedError(
184-
"consistency proof root hash does not match checkpoint root hash".to_string(),
185-
)
186-
})
187-
}
188176
}
189177

190178
impl Serialize for SignedCheckpoint {

src/rekor/models/inclusion_proof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl InclusionProof {
8080
let root_hash = hex_to_hash_output(&self.root_hash)?;
8181

8282
// check if the inclusion and checkpoint match
83-
checkpoint.valid_inclusion_proof(&root_hash)?;
83+
checkpoint.is_valid_for_proof(&root_hash, self.tree_size as u64)?;
8484

8585
Rfc6269Default::verify_inclusion(
8686
self.log_index as usize,

src/rekor/models/log_info.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ impl LogInfo {
5959
// verify checkpoint is signed by log
6060
self.signed_tree_head.verify_signature(rekor_key)?;
6161

62-
self.signed_tree_head.valid_consistency_proof(
63-
&hex_to_hash_output(&self.root_hash)?,
64-
self.tree_size as u64,
65-
)?;
62+
self.signed_tree_head
63+
.is_valid_for_proof(&hex_to_hash_output(&self.root_hash)?, self.tree_size as u64)?;
6664
consistency_proof.verify(old_size, old_root, self.tree_size as _)?;
6765
Ok(())
6866
}

0 commit comments

Comments
 (0)