Skip to content

Commit 84137d9

Browse files
Use Blake2b256Hash type
1 parent 927da38 commit 84137d9

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

rust/rbac-registration/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ uuid = "1.11.0"
3434

3535
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git" , tag = "v0.0.3" }
3636
pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
37+
cardano-blockchain-types = { version = "0.0.1", path = "../cardano-blockchain-types" }

rust/rbac-registration/src/cardano/cip509/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ pub mod utils;
1010
pub(crate) mod validation;
1111
pub mod x509_chunks;
1212

13+
use cardano_blockchain_types::hashes::Blake2b256Hash;
1314
use minicbor::{
1415
decode::{self},
1516
Decode, Decoder,
1617
};
17-
use pallas::{crypto::hash::Hash, ledger::traverse::MultiEraTx};
18+
use pallas::ledger::traverse::MultiEraTx;
1819
use strum_macros::FromRepr;
1920
use types::tx_input_hash::TxInputHash;
2021
use uuid::Uuid;
@@ -54,8 +55,7 @@ pub struct Cip509 {
5455
/// An optional hash of the previous transaction.
5556
///
5657
/// The hash must always be present except for the first registration transaction.
57-
// TODO: Use the `Blake2b256Hash` type from the `cardano-blockchain-types` crate.
58-
pub prv_tx_id: Option<Hash<32>>,
58+
pub prv_tx_id: Option<Blake2b256Hash>,
5959
/// Metadata.
6060
///
6161
/// This field encoded in chunks. See [`X509Chunks`] for more details.
@@ -141,7 +141,7 @@ impl Decode<'_, ()> for Cip509 {
141141
.map_err(|_| {
142142
decode::Error::message("Invalid data size of PreviousTxId")
143143
})?;
144-
prv_tx_id = Some(Hash::from(hash));
144+
prv_tx_id = Some(hash.into());
145145
},
146146
Cip509IntIdentifier::ValidationSignature => {
147147
let signature = decode_bytes(d, "CIP509 validation signature")?;

rust/rbac-registration/src/registration/cardano/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use std::{collections::HashMap, sync::Arc};
88

99
use anyhow::bail;
1010
use c509_certificate::c509::C509;
11+
use cardano_blockchain_types::hashes::Blake2b256Hash;
1112
use ed25519_dalek::VerifyingKey;
1213
use pallas::{
13-
crypto::hash::Hash,
1414
ledger::{
1515
addresses::{Address, ShelleyAddress},
1616
traverse::MultiEraTx,
@@ -92,7 +92,7 @@ impl RegistrationChain {
9292

9393
/// Get the current transaction ID hash.
9494
#[must_use]
95-
pub fn current_tx_id_hash(&self) -> Hash<32> {
95+
pub fn current_tx_id_hash(&self) -> Blake2b256Hash {
9696
self.inner.current_tx_id_hash
9797
}
9898

@@ -143,7 +143,7 @@ impl RegistrationChain {
143143
#[derive(Clone)]
144144
struct RegistrationChainInner {
145145
/// The current transaction ID hash (32 bytes)
146-
current_tx_id_hash: Hash<32>,
146+
current_tx_id_hash: Blake2b256Hash,
147147
/// List of purpose for this registration chain
148148
purpose: Vec<Uuid>,
149149

@@ -222,7 +222,7 @@ impl RegistrationChainInner {
222222

223223
Ok(Self {
224224
purpose,
225-
current_tx_id_hash: txn.hash(),
225+
current_tx_id_hash: txn.hash().into(),
226226
x509_certs: x509_cert_map,
227227
c509_certs: c509_cert_map,
228228
certificate_uris,

0 commit comments

Comments
 (0)