Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(primitives): Fix native scripts policy id (add missing tag) #94

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pallas-crypto/src/hash/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ macro_rules! common_hasher {
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
pub fn finalize(mut self) -> Hash<{ $size / 8 }> {
use cryptoxide::digest::Digest as _;
Expand Down
2 changes: 1 addition & 1 deletion pallas-primitives/src/alonzo/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn hash_plutus_data(data: &PlutusData) -> Hash<32> {

impl NativeScript {
pub fn to_hash(&self) -> Hash<28> {
Hasher::<224>::hash_cbor(self)
Hasher::<224>::hash_tagged_cbor(self, 0)
}
}

Expand Down