From d1d0fa20f0aee65d3044389ee9f6213b5e0c2668 Mon Sep 17 00:00:00 2001 From: Cifko Date: Thu, 1 Feb 2024 06:52:54 +0100 Subject: [PATCH 1/2] fix: use hash domains from tari_hash_domains --- Cargo.lock | 1 + dan_layer/engine_types/src/hashing.rs | 5 ++--- dan_layer/wallet/sdk/Cargo.toml | 1 + dan_layer/wallet/sdk/src/confidential/proof.rs | 7 +------ 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8c82c179..2b80124cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9336,6 +9336,7 @@ dependencies = [ "tari_dan_storage", "tari_dan_wallet_storage_sqlite", "tari_engine_types", + "tari_hash_domains", "tari_key_manager", "tari_template_lib", "tari_transaction", diff --git a/dan_layer/engine_types/src/hashing.rs b/dan_layer/engine_types/src/hashing.rs index b5777fdf7..650f5b734 100644 --- a/dan_layer/engine_types/src/hashing.rs +++ b/dan_layer/engine_types/src/hashing.rs @@ -29,11 +29,10 @@ use blake2::{ use digest::Digest; use serde::Serialize; use tari_bor::encode_into; -use tari_crypto::{hash_domain, hashing::DomainSeparation}; +use tari_crypto::hashing::DomainSeparation; +use tari_hash_domains::TariEngineHashDomain; use tari_template_lib::Hash; -hash_domain!(TariEngineHashDomain, "com.tari.dan.engine", 0); - pub fn hasher64(label: EngineHashDomainLabel) -> TariHasher64 { TariHasher64::new_with_label::(label.as_label()) } diff --git a/dan_layer/wallet/sdk/Cargo.toml b/dan_layer/wallet/sdk/Cargo.toml index 27013d01a..39933558b 100644 --- a/dan_layer/wallet/sdk/Cargo.toml +++ b/dan_layer/wallet/sdk/Cargo.toml @@ -14,6 +14,7 @@ tari_engine_types = { workspace = true } tari_dan_common_types = { workspace = true } # Just used for QuorumCertificate tari_dan_storage = { workspace = true } +tari_hash_domains = { workspace = true } tari_key_manager = { workspace = true } tari_transaction = { workspace = true } tari_template_lib = { workspace = true } diff --git a/dan_layer/wallet/sdk/src/confidential/proof.rs b/dan_layer/wallet/sdk/src/confidential/proof.rs index 9830b9d06..fde832ce4 100644 --- a/dan_layer/wallet/sdk/src/confidential/proof.rs +++ b/dan_layer/wallet/sdk/src/confidential/proof.rs @@ -28,6 +28,7 @@ use tari_crypto::{ ristretto::bulletproofs_plus::{BulletproofsPlusService, RistrettoExtendedMask, RistrettoExtendedWitness}, tari_utilities::ByteArray, }; +use tari_hash_domains::TransactionSecureNonceKdfDomain; use tari_template_lib::{ crypto::RistrettoPublicKeyBytes, models::{Amount, ConfidentialOutputProof, ConfidentialStatement, EncryptedData}, @@ -119,12 +120,6 @@ pub fn generate_confidential_proof( fn inner_encrypted_data_kdf_aead(encryption_key: &PrivateKey, commitment: &Commitment) -> EncryptedDataKey32 { let mut aead_key = EncryptedDataKey32::from(SafeArray::default()); - // This has to be the same as the base layer so that burn claims are spendable - hash_domain!( - TransactionSecureNonceKdfDomain, - "com.tari.base_layer.core.transactions.secure_nonce_kdf", - 0 - ); DomainSeparatedHasher::, TransactionSecureNonceKdfDomain>::new_with_label("encrypted_value_and_mask") .chain(encryption_key.as_bytes()) .chain(commitment.as_bytes()) From 8b8d89a8c3d8c6461f3bb81ca26be0c7a3272e19 Mon Sep 17 00:00:00 2001 From: Cifko Date: Fri, 2 Feb 2024 16:17:23 +0100 Subject: [PATCH 2/2] fix clippy --- dan_layer/wallet/sdk/src/confidential/proof.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/dan_layer/wallet/sdk/src/confidential/proof.rs b/dan_layer/wallet/sdk/src/confidential/proof.rs index fde832ce4..af8edac36 100644 --- a/dan_layer/wallet/sdk/src/confidential/proof.rs +++ b/dan_layer/wallet/sdk/src/confidential/proof.rs @@ -22,7 +22,6 @@ use tari_crypto::{ commitment::{ExtensionDegree, HomomorphicCommitmentFactory}, errors::RangeProofError, extended_range_proof::ExtendedRangeProofService, - hash_domain, hashing::DomainSeparatedHasher, keys::SecretKey, ristretto::bulletproofs_plus::{BulletproofsPlusService, RistrettoExtendedMask, RistrettoExtendedWitness},