fix: Stop double CBOR encoding of Plutus script used for hashing (#188)

This commit is contained in:
Harper 2022-09-12 20:47:20 +01:00 committed by GitHub
parent bda79061ce
commit e3d9d8f9a3
3 changed files with 34 additions and 5 deletions

View file

@ -69,6 +69,14 @@ macro_rules! common_hasher {
hasher.finalize()
}
#[inline]
pub fn hash_tagged(bytes: &[u8], tag: u8) -> Hash<{ $size / 8 }> {
let mut hasher = Self::new();
hasher.input(&[tag]);
hasher.input(bytes);
hasher.finalize()
}
/// convenient function to directly generate the hash
/// of the given [minicbor::Encode] data object
#[inline]