Skip to content

Commit

Permalink
Merge branch 'development' into stealth_addresses_clean
Browse files Browse the repository at this point in the history
  • Loading branch information
agubarev authored Jul 22, 2022
2 parents e282c26 + d265c6f commit 909026f
Show file tree
Hide file tree
Showing 50 changed files with 1,973 additions and 12 deletions.
78 changes: 74 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"comms/dht",
"comms/rpc_macros",
"dan_layer/core",
"dan_layer/template_abi",
"dan_layer/storage_sqlite",
"common_sqlite",
"infrastructure/libtor",
Expand Down
36 changes: 36 additions & 0 deletions base_layer/common_types/src/types/default_hash_domain.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2022. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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 tari_crypto::hashing::DomainSeparation;

/// The default domain separation marker for use in the tari project.
pub struct DefaultHashDomain;

impl DomainSeparation for DefaultHashDomain {
fn version() -> u8 {
1
}

fn domain() -> &'static str {
"com.tari.tari_project.hash_domain"
}
}
36 changes: 36 additions & 0 deletions base_layer/common_types/src/types/mac_hash_domain.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2022. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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 tari_crypto::hashing::DomainSeparation;

/// A domain separation marker for use in MAC derivation algorithms.
pub struct MacHashDomain;

impl DomainSeparation for MacHashDomain {
fn version() -> u8 {
1
}

fn domain() -> &'static str {
"com.tari.tari_project.mac_domain"
}
}
11 changes: 11 additions & 0 deletions base_layer/common_types/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
// 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 @@ -41,6 +44,8 @@ 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 @@ -81,3 +86,9 @@ 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>;
9 changes: 9 additions & 0 deletions base_layer/core/src/blocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ 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: 9 additions & 0 deletions base_layer/core/src/consensus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,14 @@ 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: 9 additions & 0 deletions base_layer/core/src/covenants/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,19 @@ 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: 9 additions & 0 deletions base_layer/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,12 @@ 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: 10 additions & 0 deletions base_layer/core/src/proof_of_work/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ 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")
}
9 changes: 9 additions & 0 deletions base_layer/core/src/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod transaction_components;

mod format_currency;
pub use format_currency::format_currency;
use tari_common::hashing_domain::HashingDomain;

pub mod transaction_protocol;
pub use transaction_protocol::{recipient::ReceiverTransactionProtocol, sender::SenderTransactionProtocol};
Expand All @@ -24,3 +25,11 @@ pub mod weight;

#[macro_use]
pub mod test_helpers;

/// The base layer core transactions domain separated hashing domain
/// Usage:
/// let hash = core_transactions_hash_domain().digest::<Blake256>(b"my secret");
/// etc.
pub fn core_transactions_hash_domain() -> HashingDomain {
HashingDomain::new("base_layer.core.transactions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub struct UnblindedOutput {
impl UnblindedOutput {
/// Creates a new un-blinded output
#[allow(clippy::too_many_arguments)]
pub fn new(
version: TransactionOutputVersion,
value: MicroTari,
Expand Down
1 change: 1 addition & 0 deletions base_layer/mmr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ benches = ["criterion"]

[dependencies]
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
tari_common = {path = "../../common"}
thiserror = "1.0.26"
digest = "0.9.0"
log = "0.4"
Expand Down
Loading

0 comments on commit 909026f

Please sign in to comment.