Skip to content

Commit 39f7b1c

Browse files
committed
Add compute_protocol_party_id_as_hash to OpCert
1 parent 91f1bda commit 39f7b1c

File tree

1 file changed

+13
-0
lines changed
  • mithril-common/src/crypto_helper/cardano

1 file changed

+13
-0
lines changed

mithril-common/src/crypto_helper/cardano/opcert.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ impl OpCert {
117117
.map_err(|_| OpCertError::PoolAddressEncoding)
118118
}
119119

120+
/// Compute protocol party id as hash
121+
pub fn compute_protocol_party_id_as_hash(&self) -> String {
122+
let mut hasher = Blake2b::<U28>::new();
123+
hasher.update(self.cold_vk.as_bytes());
124+
hex::encode(hasher.finalize())
125+
}
126+
120127
/// Compute the hash of an OpCert
121128
pub fn compute_hash(&self) -> String {
122129
let mut hasher = Sha256::new();
@@ -207,5 +214,11 @@ mod tests {
207214
"pool1mxyec46067n3querj9cxkk0g0zlag93pf3ya9vuyr3wgkq2e6t7".to_string(),
208215
party_id
209216
);
217+
218+
let party_id_as_hash = operational_certificate.compute_protocol_party_id_as_hash();
219+
assert_eq!(
220+
"d9899c574fd7a710732391706b59e878bfd416214c49d2b3841c5c8b".to_string(),
221+
party_id_as_hash
222+
);
210223
}
211224
}

0 commit comments

Comments
 (0)