Skip to content

Commit

Permalink
refactor(add 61284 sig check): verify msg vs pub key
Browse files Browse the repository at this point in the history
ensure payload integrity
  • Loading branch information
cong-or committed Apr 30, 2024
1 parent 6bb69d3 commit c6aa019
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions catalyst-gateway/bin/src/cardano/cip36_registration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ impl Cip36Metadata {
};

if let Some(raw_61284) = raw_61284 {
let _ = validate_signature(raw_61284, registration.clone(), signature).map_err(|err| {
errors_report.push(format!("{err}"));
});
let _ =
validate_signature(&raw_61284, registration.clone(), signature).map_err(|err| {
errors_report.push(format!("{err}"));
});
}

Some(Self {
Expand All @@ -173,7 +174,7 @@ impl Cip36Metadata {
/// - blake2b-256 hashing those bytes
/// - signing the hash with the private key used to generate the stake key
pub fn validate_signature(
raw_61284: Vec<u8>, registration: Option<Registration>, signature: Option<Signature>,
raw_61284: &[u8], registration: Option<Registration>, signature: Option<Signature>,
) -> anyhow::Result<()> {
let hash_bytes = hash(&raw_61284);

Expand Down
1 change: 1 addition & 0 deletions catalyst-gateway/bin/src/cardano/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub type StakeCredentialHash = String;
/// Correct stake credential key in hex
pub type StakeCredentialKey = String;

/// Hash size
pub(crate) const BLAKE_2B_256_HASH_SIZE: usize = 256 / 8;

/// Helper function to generate the `blake2b_256` hash of a byte slice
Expand Down

0 comments on commit c6aa019

Please sign in to comment.