diff --git a/Cargo.lock b/Cargo.lock index 8efb6dbfb4..43cb736409 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1384,8 +1384,11 @@ dependencies = [ "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto 0.2.2", + "group", "platforms", + "rand_core", "rustc_version", + "serde", "subtle", "zeroize", ] @@ -2723,15 +2726,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "itertools" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3f2be4da1690a039e9ae5fd575f706a63ad5a2120f161b1d653c9da3930dd21" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.10.5" @@ -5908,9 +5902,7 @@ dependencies = [ "curve25519-dalek-derive", "fiat-crypto 0.1.20", "platforms", - "rand_core", "rustc_version", - "serde", "subtle", "zeroize", ] @@ -5927,24 +5919,22 @@ dependencies = [ [[package]] name = "tari_bulletproofs_plus" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9abc9cbebffb1149112a80d6955498ed891f9b786e89c50e07de4b4f16290fd8" +checksum = "8eac57729e3b003c18e822c64c8c4977770102b2eaea920a7c40bca5caf12c54" dependencies = [ "blake2", "byteorder", - "derivative", - "derive_more", + "curve25519-dalek", "digest 0.10.7", - "itertools 0.6.5", - "lazy_static", + "ff", + "itertools 0.12.1", "merlin", - "rand", + "once_cell", "rand_core", "serde", "sha3", - "tari-curve25519-dalek", - "thiserror", + "thiserror-no-std", "zeroize", ] @@ -6255,21 +6245,23 @@ dependencies = [ [[package]] name = "tari_crypto" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63a3ed2c551101eb42b7f9386c207e28d53e6816f7b4c9a0883548922f317b3e" +checksum = "40833db37f54c3b176da3d07199c76ec7a062b19fbf74bf270d614804114ee58" dependencies = [ "blake2", "borsh", + "curve25519-dalek", "digest 0.10.7", "log", + "merlin", "once_cell", "rand_chacha", "rand_core", "serde", "sha3", "snafu", - "tari-curve25519-dalek", + "subtle", "tari_bulletproofs_plus", "tari_utilities", "zeroize", @@ -6627,6 +6619,26 @@ dependencies = [ "syn 2.0.38", ] +[[package]] +name = "thiserror-impl-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "thiserror-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" +dependencies = [ + "thiserror-impl-no-std", +] + [[package]] name = "thread-id" version = "4.2.1" diff --git a/applications/minotari_ledger_wallet/wallet/Cargo.toml b/applications/minotari_ledger_wallet/wallet/Cargo.toml index 0d2a7530be..9b51c06b52 100644 --- a/applications/minotari_ledger_wallet/wallet/Cargo.toml +++ b/applications/minotari_ledger_wallet/wallet/Cargo.toml @@ -6,6 +6,9 @@ license = "BSD-3-Clause" edition = "2021" [dependencies] +tari_crypto = { version = "0.20.1", default-features = false, features = ["borsh"]} +tari_hashing = { path = "../../../hashing", version = "1.0.0-pre.13" } + blake2 = { version = "0.10", default-features = false } borsh = { version = "1.2", default-features = false } critical-section = { version = "1.1.1" } @@ -13,7 +16,6 @@ digest = { version = "0.10", default-features = false } embedded-alloc = "0.5.0" include_gif = "1.0.1" ledger_device_sdk = "1.7.1" -tari_crypto = { version = "0.20.1", default-features = false, features = ["borsh"]} zeroize = { version = "1" , default-features = false } # once_cell defined here just to lock the version. Other dependencies may try to go to 1.19 which is incompatabile with diff --git a/applications/minotari_ledger_wallet/wallet/src/handlers/get_metadata_signature.rs b/applications/minotari_ledger_wallet/wallet/src/handlers/get_metadata_signature.rs index f3d3659c91..3361ec7a77 100644 --- a/applications/minotari_ledger_wallet/wallet/src/handlers/get_metadata_signature.rs +++ b/applications/minotari_ledger_wallet/wallet/src/handlers/get_metadata_signature.rs @@ -15,10 +15,11 @@ use tari_crypto::{ RistrettoSecretKey, }, }; +use tari_hashing::TransactionHashDomain; use crate::{ alloc::string::ToString, - hashing::{DomainSeparatedConsensusHasher, TransactionHashDomain}, + hashing::DomainSeparatedConsensusHasher, utils::{derive_from_bip32_key, get_key_from_canonical_bytes}, AppSW, KeyType, diff --git a/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_signature.rs b/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_signature.rs index a0a3e89214..90b82603f7 100644 --- a/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_signature.rs +++ b/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_signature.rs @@ -16,11 +16,12 @@ use tari_crypto::{ RistrettoSecretKey, }, }; +use tari_hashing::TransactionHashDomain; use zeroize::Zeroizing; use crate::{ alloc::string::ToString, - hashing::{DomainSeparatedConsensusHasher, TransactionHashDomain}, + hashing::DomainSeparatedConsensusHasher, utils::{alpha_hasher, derive_from_bip32_key, get_key_from_canonical_bytes}, AppSW, KeyType, diff --git a/applications/minotari_ledger_wallet/wallet/src/hashing.rs b/applications/minotari_ledger_wallet/wallet/src/hashing.rs index bea6d91a69..384a7932f0 100644 --- a/applications/minotari_ledger_wallet/wallet/src/hashing.rs +++ b/applications/minotari_ledger_wallet/wallet/src/hashing.rs @@ -6,15 +6,7 @@ use core::marker::PhantomData; use borsh::{io, io::Write, BorshSerialize}; use digest::Digest; -use tari_crypto::{hash_domain, hashing::DomainSeparation}; - -hash_domain!(LedgerHashDomain, "com.tari.minotari_ledger_wallet", 0); -hash_domain!( - KeyManagerTransactionsHashDomain, - "com.tari.base_layer.core.transactions.key_manager", - 1 -); -hash_domain!(TransactionHashDomain, "com.tari.base_layer.core.transactions", 0); +use tari_crypto::hashing::DomainSeparation; pub struct DomainSeparatedConsensusHasher { hasher: DomainSeparatedBorshHasher, diff --git a/applications/minotari_ledger_wallet/wallet/src/utils.rs b/applications/minotari_ledger_wallet/wallet/src/utils.rs index d3c12eccd4..9441768268 100644 --- a/applications/minotari_ledger_wallet/wallet/src/utils.rs +++ b/applications/minotari_ledger_wallet/wallet/src/utils.rs @@ -17,11 +17,11 @@ use tari_crypto::{ ristretto::RistrettoSecretKey, tari_utilities::ByteArray, }; +use tari_hashing::{KeyManagerTransactionsHashDomain, LedgerHashDomain}; use zeroize::Zeroizing; use crate::{ alloc::string::{String, ToString}, - hashing::{KeyManagerTransactionsHashDomain, LedgerHashDomain}, AppSW, KeyType, BIP32_COIN_TYPE, diff --git a/base_layer/core/src/transactions/key_manager/inner.rs b/base_layer/core/src/transactions/key_manager/inner.rs index 6561f6c3f5..f7cdcd3400 100644 --- a/base_layer/core/src/transactions/key_manager/inner.rs +++ b/base_layer/core/src/transactions/key_manager/inner.rs @@ -39,7 +39,6 @@ use tari_comms::types::CommsDHKE; use tari_crypto::{ commitment::{ExtensionDegree, HomomorphicCommitmentFactory}, extended_range_proof::ExtendedRangeProofService, - hash_domain, hashing::{DomainSeparatedHash, DomainSeparatedHasher}, keys::{PublicKey as PublicKeyTrait, SecretKey}, range_proof::RangeProofService as RPService, @@ -48,6 +47,7 @@ use tari_crypto::{ RistrettoComSig, }, }; +use tari_hashing::KeyManagerTransactionsHashDomain; #[cfg(feature = "ledger")] use tari_key_manager::error::KeyManagerError; use tari_key_manager::{ @@ -92,12 +92,6 @@ use crate::{ }, }; -hash_domain!( - KeyManagerTransactionsHashDomain, - "com.tari.base_layer.core.transactions.key_manager", - 1 -); - pub struct TransactionKeyManagerInner { key_managers: HashMap>>, db: KeyManagerDatabase, diff --git a/hashing/Cargo.toml b/hashing/Cargo.toml index 85b1aaa9fc..731fe3df08 100644 --- a/hashing/Cargo.toml +++ b/hashing/Cargo.toml @@ -12,9 +12,9 @@ license = "BSD-3-Clause" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -tari_crypto = "0.20.0" -digest = "0.10" -borsh = "1.2" +tari_crypto = { version = "0.20.1", default-features = false, features = ["borsh"]} +borsh = { version = "1.2", default-features = false } +digest = { version = "0.10", default-features = false } [dev-dependencies] blake2 = "0.10" \ No newline at end of file diff --git a/hashing/src/borsh_hasher.rs b/hashing/src/borsh_hasher.rs index 47c876fbe8..ca121cf407 100644 --- a/hashing/src/borsh_hasher.rs +++ b/hashing/src/borsh_hasher.rs @@ -23,9 +23,9 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::{io, io::Write, marker::PhantomData}; +use core::marker::PhantomData; -use borsh::BorshSerialize; +use borsh::{io, io::Write, BorshSerialize}; use digest::Digest; use tari_crypto::hashing::DomainSeparation; diff --git a/hashing/src/domains.rs b/hashing/src/domains.rs index cf400cc38e..e93769d465 100644 --- a/hashing/src/domains.rs +++ b/hashing/src/domains.rs @@ -28,3 +28,11 @@ hash_domain!( // Hash domain for all transaction-related hashes, including the script signature challenge, transaction hash and kernel // signature challenge hash_domain!(TransactionHashDomain, "com.tari.base_layer.core.transactions", 0); + +hash_domain!(LedgerHashDomain, "com.tari.minotari_ledger_wallet", 0); + +hash_domain!( + KeyManagerTransactionsHashDomain, + "com.tari.base_layer.core.transactions.key_manager", + 1 +); diff --git a/hashing/src/lib.rs b/hashing/src/lib.rs index 8993831cc4..6877a159a0 100644 --- a/hashing/src/lib.rs +++ b/hashing/src/lib.rs @@ -20,6 +20,8 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#![no_std] + mod domains; pub use domains::*;