fix(primitives): Fix native scripts policy id (add missing tag) (#94)
This commit is contained in:
parent
a21d892fcc
commit
a5df52cc15
2 changed files with 9 additions and 1 deletions
|
|
@ -78,6 +78,14 @@ macro_rules! common_hasher {
|
||||||
hasher.finalize()
|
hasher.finalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn hash_tagged_cbor(data: &impl minicbor::Encode, tag: u8) -> Hash<{ $size / 8 }> {
|
||||||
|
let mut hasher = Self::new();
|
||||||
|
hasher.input(&[tag]);
|
||||||
|
let () = minicbor::encode(data, &mut hasher).expect("Infallible");
|
||||||
|
hasher.finalize()
|
||||||
|
}
|
||||||
|
|
||||||
/// consume the [`Hasher`] and returns the computed digest
|
/// consume the [`Hasher`] and returns the computed digest
|
||||||
pub fn finalize(mut self) -> Hash<{ $size / 8 }> {
|
pub fn finalize(mut self) -> Hash<{ $size / 8 }> {
|
||||||
use cryptoxide::digest::Digest as _;
|
use cryptoxide::digest::Digest as _;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub fn hash_plutus_data(data: &PlutusData) -> Hash<32> {
|
||||||
|
|
||||||
impl NativeScript {
|
impl NativeScript {
|
||||||
pub fn to_hash(&self) -> Hash<28> {
|
pub fn to_hash(&self) -> Hash<28> {
|
||||||
Hasher::<224>::hash_cbor(self)
|
Hasher::<224>::hash_tagged_cbor(self, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue