From dfa5e3e4a9c1976fe4cb157af116ba083c9e070c Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Tue, 28 Jan 2025 17:59:30 +0100 Subject: [PATCH] feat(rust/cardano-blockchain-types): Add TransactionHash and PubKeyHash types (#186) * Add TransactionHash and PubKeyHash types --- rust/cardano-blockchain-types/Cargo.toml | 4 ++-- rust/cardano-blockchain-types/src/hashes.rs | 13 +++++++++++++ rust/cardano-blockchain-types/src/lib.rs | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 rust/cardano-blockchain-types/src/hashes.rs diff --git a/rust/cardano-blockchain-types/Cargo.toml b/rust/cardano-blockchain-types/Cargo.toml index e69cc10377..80d5557ca3 100644 --- a/rust/cardano-blockchain-types/Cargo.toml +++ b/rust/cardano-blockchain-types/Cargo.toml @@ -20,8 +20,8 @@ workspace = true [dependencies] pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" } # pallas-hardano = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" } -cbork-utils = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250127-00" } -catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250127-00" } +cbork-utils = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250128-01" } +catalyst-types = { version = "0.0.1", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250128-01" } ouroboros = "0.18.4" tracing = "0.1.41" diff --git a/rust/cardano-blockchain-types/src/hashes.rs b/rust/cardano-blockchain-types/src/hashes.rs new file mode 100644 index 0000000000..e46c44a2c2 --- /dev/null +++ b/rust/cardano-blockchain-types/src/hashes.rs @@ -0,0 +1,13 @@ +//! Cardano blockchain specific hash types. + +use catalyst_types::{ + define_hashes, + hashes::{Blake2b224Hash, Blake2b256Hash}, +}; + +define_hashes!( + /// A transaction hash - Blake2b-256 hash of a transaction. + (TransactionHash, Blake2b256Hash), + /// A public key hash - raw Blake2b-224 hash of an Ed25519 public key (has no discriminator, just the hash). + (PubKeyHash, Blake2b224Hash) +); diff --git a/rust/cardano-blockchain-types/src/lib.rs b/rust/cardano-blockchain-types/src/lib.rs index 84afb9ec36..087362e8c3 100644 --- a/rust/cardano-blockchain-types/src/lib.rs +++ b/rust/cardano-blockchain-types/src/lib.rs @@ -3,6 +3,7 @@ mod auxdata; mod cip134_uri; mod fork; +mod hashes; mod metadata; mod multi_era_block_data; mod network; @@ -21,6 +22,7 @@ pub use auxdata::{ }; pub use cip134_uri::Cip0134Uri; pub use fork::Fork; +pub use hashes::{PubKeyHash, TransactionHash}; pub use metadata::cip36::{voting_pk::VotingPubKey, Cip36}; pub use multi_era_block_data::MultiEraBlock; pub use network::Network;