Skip to content

Commit

Permalink
Remove hashing domain
Browse files Browse the repository at this point in the history
- Removed hashing domain in favour of recent changes in `tari_crypto "v0.15.3"`.
- Added a specialized marker trait for tight coupling of `DomainSeparatedHasher`
  to `Digest`; this is useful when a low level hashing function that accepts
  `Digest` as type needs to guarantee that domain separated hashing is implemented.
- Added a MAC domain hasher that guarantees implementation of
  `DomainSeparatedHasher` and `LengthExtensionAttackResistant`.
- Upadated the key manager to use the MAC domain hasher.
  • Loading branch information
hansieodendaal committed Aug 1, 2022
1 parent d012823 commit 84ceff5
Show file tree
Hide file tree
Showing 52 changed files with 212 additions and 452 deletions.
12 changes: 8 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions applications/tari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ edition = "2018"
tari_common_types = { version = "^0.34", path = "../../base_layer/common_types"}
tari_comms = { path = "../../comms/core"}
tari_core = { path = "../../base_layer/core"}
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_script = { path = "../../infrastructure/tari_script" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

chrono = { version = "0.4.19", default-features = false }
prost = "0.9"
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ license = "BSD-3-Clause"

[dependencies]
tari_comms = { path = "../../comms/core" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_common = { path = "../../common" }
tari_common_types = { path = "../../base_layer/common_types" }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

clap = { version = "3.2.0", features = ["derive", "env"] }
config = { version = "0.13.0" }
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_base_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ tari_comms = { path = "../../comms/core", features = ["rpc"] }
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms_dht = { path = "../../comms/dht" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions"] }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_libtor = { path = "../../infrastructure/libtor" }
tari_mmr = { path = "../../base_layer/mmr", features = ["native_bitmap"] }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_storage = {path="../../infrastructure/storage"}
tari_service_framework = { path = "../../base_layer/service_framework" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

anyhow = "1.0.53"
async-trait = "0.1.52"
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_collectibles/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ tari_app_grpc = { path = "../../tari_app_grpc" }
tari_app_utilities = { path = "../../tari_app_utilities" }
tari_common = { path = "../../../common" }
tari_common_types = { path = "../../../base_layer/common_types" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_key_manager = { path = "../../../base_layer/key_manager" }
tari_mmr = { path = "../../../base_layer/mmr" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }
tari_dan_common_types = { path = "../../../dan_layer/common_types" }

blake2 = "^0.9.0"
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "BSD-3-Clause"

[dependencies]
tari_wallet = { path = "../../base_layer/wallet", features = ["bundled_sqlite"] }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_common = { path = "../../common" }
tari_app_utilities = { path = "../tari_app_utilities" }
tari_comms = { path = "../../comms/core" }
Expand All @@ -18,7 +18,7 @@ tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_app_grpc = { path = "../tari_app_grpc" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
tari_key_manager = { path = "../../base_layer/key_manager" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

# Uncomment for tokio tracing via tokio-console (needs "tracing" featurs)
#console-subscriber = "0.1.3"
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_merge_mining_proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ tari_common = { path = "../../common" }
tari_comms = { path = "../../comms/core" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions"] }
tari_app_utilities = { path = "../tari_app_utilities" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

anyhow = "1.0.53"
crossterm = { version = "0.17" }
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ tari_common = { path = "../../common" }
tari_comms = { path = "../../comms/core" }
tari_app_utilities = { path = "../tari_app_utilities"}
tari_app_grpc = { path = "../tari_app_grpc" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

crossterm = { version = "0.17" }
clap = { version = "3.1.1", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_validator_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tari_common = { path = "../../common" }
tari_comms = { path = "../../comms/core" }
tari_comms_dht = { path = "../../comms/dht" }
tari_comms_rpc_macros = { path = "../../comms/rpc_macros" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_mmr = { path = "../../base_layer/mmr" }
tari_p2p = { path = "../../base_layer/p2p" }
tari_service_framework = { path = "../../base_layer/service_framework" }
Expand Down
4 changes: 2 additions & 2 deletions applications/test_faucet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ simd = ["tari_crypto/simd_backend"]
avx2 = ["simd"]

[dependencies]
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }
tari_common_types = { path = "../../base_layer/common_types" }
tari_script = { path = "../../infrastructure/tari_script" }

Expand Down
4 changes: 2 additions & 2 deletions base_layer/common_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ version = "0.34.0"
edition = "2018"

[dependencies]
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

digest = "0.9.0"
lazy_static = "1.4.0"
Expand Down
36 changes: 0 additions & 36 deletions base_layer/common_types/src/types/default_hash_domain.rs

This file was deleted.

36 changes: 0 additions & 36 deletions base_layer/common_types/src/types/mac_hash_domain.rs

This file was deleted.

11 changes: 0 additions & 11 deletions base_layer/common_types/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

mod bullet_rangeproofs;
mod default_hash_domain;
mod fixed_hash;
mod mac_hash_domain;

pub use bullet_rangeproofs::BulletRangeProof;
use tari_crypto::{
hash::blake2::Blake256,
hashing::DomainSeparatedHasher,
ristretto::{
bulletproofs_plus::BulletproofsPlusService,
pedersen::{extended_commitment_factory::ExtendedPedersenCommitmentFactory, PedersenCommitment},
Expand All @@ -44,8 +41,6 @@ pub type BlockHash = Vec<u8>;

pub use fixed_hash::{FixedHash, FixedHashSizeError};

use crate::types::{default_hash_domain::DefaultHashDomain, mac_hash_domain::MacHashDomain};

/// Define the explicit Signature implementation for the Tari base layer. A different signature scheme can be
/// employed by redefining this type.
pub type Signature = RistrettoSchnorr;
Expand Down Expand Up @@ -86,9 +81,3 @@ pub type RangeProofService = BulletproofsPlusService;

/// Specify the range proof
pub type RangeProof = BulletRangeProof;

/// Generic domain separated hasher
pub type DefaultDomainHasher<D> = DomainSeparatedHasher<D, DefaultHashDomain>;

/// MAC domain separated hasher
pub type MacDomainHasher<D> = DomainSeparatedHasher<D, MacHashDomain>;
4 changes: 2 additions & 2 deletions base_layer/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tari_common_types = { version = "^0.34", path = "../../base_layer/common_types"
tari_comms = { version = "^0.34", path = "../../comms/core" }
tari_comms_dht = { version = "^0.34", path = "../../comms/dht" }
tari_comms_rpc_macros = { version = "^0.34", path = "../../comms/rpc_macros" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.1" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.15.3" }
tari_metrics = { path = "../../infrastructure/metrics" }
tari_mmr = { version = "^0.34", path = "../../base_layer/mmr", optional = true, features = ["native_bitmap"] }
tari_p2p = { version = "^0.34", path = "../../base_layer/p2p" }
Expand All @@ -33,7 +33,7 @@ tari_service_framework = { version = "^0.34", path = "../service_framework" }
tari_shutdown = { version = "^0.34", path = "../../infrastructure/shutdown" }
tari_storage = { version = "^0.34", path = "../../infrastructure/storage" }
tari_test_utils = { version = "^0.34", path = "../../infrastructure/test_utils" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.5" }

async-trait = "0.1.50"
bincode = "1.1.4"
Expand Down
9 changes: 0 additions & 9 deletions base_layer/core/src/blocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,3 @@ pub use new_block_template::NewBlockTemplate;
mod new_blockheader_template;
#[cfg(feature = "base_node")]
pub use new_blockheader_template::NewBlockHeaderTemplate;
use tari_common::hashing_domain::HashingDomain;

/// The base layer core blocks domain separated hashing domain
/// Usage:
/// let hash = core_blocks_hash_domain().digest::<Blake256>(b"my secret");
/// etc.
pub fn core_blocks_hash_domain() -> HashingDomain {
HashingDomain::new("base_layer.core.blocks")
}
9 changes: 0 additions & 9 deletions base_layer/core/src/consensus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,5 @@ pub use consensus_encoding::{

mod network;
pub use network::NetworkConsensus;
use tari_common::hashing_domain::HashingDomain;

pub mod emission;

/// The base layer core consensus domain separated hashing domain
/// Usage:
/// let hash = core_consensus_hash_domain().digest::<Blake256>(b"my secret");
/// etc.
pub fn core_consensus_hash_domain() -> HashingDomain {
HashingDomain::new("base_layer.core.consensus")
}
9 changes: 0 additions & 9 deletions base_layer/core/src/covenants/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,10 @@ pub use error::CovenantError;
// Used in macro
#[allow(unused_imports)]
pub(crate) use fields::OutputField;
use tari_common::hashing_domain::HashingDomain;
pub use token::CovenantToken;

#[macro_use]
mod macros;

#[cfg(test)]
mod test;

/// The base layer core covenants domain separated hashing domain
/// Usage:
/// let hash = core_covenants_hash_domain().digest::<Blake256>(b"my secret");
/// etc.
pub fn core_covenants_hash_domain() -> HashingDomain {
HashingDomain::new("base_layer.core.covenants")
}
9 changes: 0 additions & 9 deletions base_layer/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,3 @@ pub mod large_ints {
}
}
pub use large_ints::{U256, U512};
use tari_common::hashing_domain::HashingDomain;

/// The base layer core domain separated hashing domain
/// Usage:
/// let hash = core_hash_domain().digest::<Blake256>(b"my secret");
/// etc.
pub fn core_hash_domain() -> HashingDomain {
HashingDomain::new("base_layer.core")
}
10 changes: 0 additions & 10 deletions base_layer/core/src/proof_of_work/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,3 @@ pub mod lwma_diff;

#[cfg(feature = "base_node")]
pub mod randomx_factory;

use tari_common::hashing_domain::HashingDomain;

/// The base layer core proof-of-work domain separated hashing domain
/// Usage:
/// let hash = core_proof_of_work_hash_domain().digest::<Blake256>(b"my secret");
/// etc.
pub fn core_proof_of_work_hash_domain() -> HashingDomain {
HashingDomain::new("base_layer.core.proof_of_work")
}
Loading

0 comments on commit 84ceff5

Please sign in to comment.