Skip to content

Commit

Permalink
feat: use tari_crypto's updated "extended pedersen commitment factory" (
Browse files Browse the repository at this point in the history
#4206)

Description
---
Update tari_crypto

- Updated tari_crypto to the latest version
- Switched to 'ExtendedPedersenCommitmentFactory' from 'PedersenCommitmentFactory'

_**Notes:**_
- _No functional changes, no commitment changes, no Bulletproof range proof changes._
- _Temporary use of the git commit instead of a tag for `tari-crypto` and in the `cargo.toml` files_

Motivation and Context
---
Preparation for `tari_bulletproofs_plus` implementation.

How Has This Been Tested?
---
- Existing unit tests pass
- Existing integration tests pass
  • Loading branch information
hansieodendaal authored Jun 16, 2022
1 parent edcce4a commit 50ce20a
Show file tree
Hide file tree
Showing 41 changed files with 199 additions and 117 deletions.
31 changes: 27 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.32", 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.13.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
tari_script = { path = "../../infrastructure/tari_script" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }

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.13.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
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.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }

clap = { version = "3.1.1", 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.13.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
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.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }

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.13.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
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.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
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.13.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
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.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }

# Uncomment for tokio tracing via tokio-console (needs "tracing" featurs)
#console-subscriber = "0.1.3"
Expand Down
5 changes: 2 additions & 3 deletions applications/tari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use strum_macros::{Display, EnumIter, EnumString};
use tari_common_types::{
emoji::EmojiId,
transaction::TxId,
types::{FixedHash, PublicKey},
types::{CommitmentFactory, FixedHash, PublicKey},
};
use tari_comms::{
connectivity::{ConnectivityEvent, ConnectivityRequester},
Expand All @@ -59,7 +59,6 @@ use tari_core::transactions::{
UnblindedOutput,
},
};
use tari_crypto::ristretto::pedersen::PedersenCommitmentFactory;
use tari_utilities::{hex::Hex, ByteArray, Hashable};
use tari_wallet::{
assets::{
Expand Down Expand Up @@ -1030,7 +1029,7 @@ async fn publish_contract_amendment(wallet: &WalletSqlite, args: PublishFileArgs
}

fn write_utxos_to_csv_file(utxos: Vec<UnblindedOutput>, file_path: PathBuf) -> Result<(), CommandError> {
let factory = PedersenCommitmentFactory::default();
let factory = CommitmentFactory::default();
let file = File::create(file_path).map_err(|e| CommandError::CSVFile(e.to_string()))?;
let mut csv_file = LineWriter::new(file);
writeln!(
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.13.0" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.3" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }

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.13.0" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.3" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }

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.13.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
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"]
avx2 = ["simd"]

[dependencies]
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.13.0" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.3" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }
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.32.3"
edition = "2018"

[dependencies]
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.13.0" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.3" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }

digest = "0.9.0"
lazy_static = "1.4.0"
Expand Down
5 changes: 3 additions & 2 deletions base_layer/common_types/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tari_crypto::{
common::Blake256,
ristretto::{
dalek_range_proof::DalekRangeProofService,
pedersen::{PedersenCommitment, PedersenCommitmentFactory},
pedersen::{extended_commitment_factory::ExtendedPedersenCommitmentFactory, PedersenCommitment},
RistrettoComSig,
RistrettoPublicKey,
RistrettoSchnorr,
Expand All @@ -49,7 +49,7 @@ pub type ComSignature = RistrettoComSig;

/// Define the explicit Commitment implementation for the Tari base layer.
pub type Commitment = PedersenCommitment;
pub type CommitmentFactory = PedersenCommitmentFactory;
pub type CommitmentFactory = ExtendedPedersenCommitmentFactory;

/// Define the explicit Public key implementation for the Tari base layer
pub type PublicKey = RistrettoPublicKey;
Expand All @@ -76,6 +76,7 @@ pub type HashOutput = Vec<u8>;
pub const MAX_RANGE_PROOF_RANGE: usize = 64; // 2^64

/// Specify the range proof type
// TODO: Replace `DalekRangeProofService` with `BulletproofsPlusService` when 'bulletproofs_plus'
pub type RangeProofService = DalekRangeProofService;

/// Specify the range proof
Expand Down
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.32", path = "../../base_layer/common_types"
tari_comms = { version = "^0.32", path = "../../comms/core" }
tari_comms_dht = { version = "^0.32", path = "../../comms/dht" }
tari_comms_rpc_macros = { version = "^0.32", path = "../../comms/rpc_macros" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.13.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", rev = "a564ba8f15ea37f0e26f9e13d3ad7ed8e397d312" }
tari_metrics = { path = "../../infrastructure/metrics" }
tari_mmr = { version = "^0.32", path = "../../base_layer/mmr", optional = true, features = ["native_bitmap"] }
tari_p2p = { version = "^0.32", path = "../../base_layer/p2p" }
Expand All @@ -33,7 +33,7 @@ tari_service_framework = { version = "^0.32", path = "../service_framework" }
tari_shutdown = { version = "^0.32", path = "../../infrastructure/shutdown" }
tari_storage = { version = "^0.32", path = "../../infrastructure/storage" }
tari_test_utils = { version = "^0.32", path = "../../infrastructure/test_utils" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.3" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag = "v0.4.4" }

async-trait = "0.1.50"
bincode = "1.1.4"
Expand Down
9 changes: 8 additions & 1 deletion base_layer/core/src/transactions/crypto_factories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
use std::sync::Arc;

use tari_common_types::types::{CommitmentFactory, RangeProofService, MAX_RANGE_PROOF_RANGE};
use tari_crypto::ristretto::pedersen::commitment_factory::PedersenCommitmentFactory;

/// A convenience struct wrapping cryptographic factories that are used throughout the rest of the code base
/// Uses Arcs internally so calling clone on this is cheap, no need to wrap this in an Arc
pub struct CryptoFactories {
pub commitment: Arc<CommitmentFactory>,
pub commitment_dalek_bulletproofs: Arc<PedersenCommitmentFactory>, // TODO: Remove this when 'bulletproofs_plus'
pub range_proof: Arc<RangeProofService>,
}

Expand All @@ -29,9 +31,13 @@ impl CryptoFactories {
/// * `max_proof_range`: Sets the the maximum value in range proofs, where `max = 2^max_proof_range`
pub fn new(max_proof_range: usize) -> Self {
let commitment = Arc::new(CommitmentFactory::default());
let range_proof = Arc::new(RangeProofService::new(max_proof_range, &commitment).unwrap());
// TODO: Remove this when 'bulletproofs_plus'
let commitment_dalek_bulletproofs = Arc::new(PedersenCommitmentFactory::default());
// TODO: Replace `commitment_dalek_bulletproofs` with `commitment` when 'bulletproofs_plus'
let range_proof = Arc::new(RangeProofService::new(max_proof_range, &commitment_dalek_bulletproofs).unwrap());
Self {
commitment,
commitment_dalek_bulletproofs,
range_proof,
}
}
Expand All @@ -42,6 +48,7 @@ impl Clone for CryptoFactories {
fn clone(&self) -> Self {
Self {
commitment: self.commitment.clone(),
commitment_dalek_bulletproofs: self.commitment_dalek_bulletproofs.clone(),
range_proof: self.range_proof.clone(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use std::io;

use serde::{Deserialize, Serialize};
use tari_crypto::{range_proof::RangeProofError, signatures::CommitmentSignatureError};
use tari_crypto::{errors::RangeProofError, signatures::CommitmentSignatureError};
use tari_script::ScriptError;
use thiserror::Error;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// Version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0.

use tari_common_types::types::BlindingFactor;
use tari_crypto::range_proof::{FullRewindResult as CryptoFullRewindResult, REWIND_USER_MESSAGE_LENGTH};
use tari_crypto::rewindable_range_proof::{FullRewindResult as CryptoFullRewindResult, REWIND_USER_MESSAGE_LENGTH};

use crate::transactions::tari_amount::MicroTari;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//
// Portions of this file were originally copyrighted (c) 2018 The Grin Developers, issued under the Apache License,
// Version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0.
use tari_crypto::range_proof::{RewindResult as CryptoRewindResult, REWIND_USER_MESSAGE_LENGTH};
use tari_crypto::rewindable_range_proof::{RewindResult as CryptoRewindResult, REWIND_USER_MESSAGE_LENGTH};

use crate::transactions::tari_amount::MicroTari;

Expand Down
Loading

0 comments on commit 50ce20a

Please sign in to comment.