Skip to content

Commit

Permalink
building
Browse files Browse the repository at this point in the history
  • Loading branch information
SWvheerden committed Jan 22, 2025
1 parent 798a0bd commit 3d70ea3
Show file tree
Hide file tree
Showing 137 changed files with 1,244 additions and 770 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion applications/minotari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_core = { path = "../../base_layer/core" }
tari_crypto = { git = "https://github.com/SWvheerden/tari-crypto", rev = "97f1c9f90b24974b25d029c740adff8d6c13f27d" }
tari_crypto = { git = "https://github.com/SWvheerden/tari-crypto", rev = "236aa26779bbeb9468250af622695f1dcc5b8d6a" }
tari_script = { path = "../../infrastructure/tari_script" }
tari_max_size = { path = "../../infrastructure/max_size" }
tari_utilities = { version = "0.8" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@

use std::convert::TryFrom;

use tari_common_types::types::{PrivateKey, PublicKey};
use tari_crypto::{commitment::HomomorphicCommitment, signatures::CommitmentSignature};
use tari_common_types::types::PrivateKey;
use tari_crypto::{commitment::HomomorphicCommitment, ristretto::RistrettoPublicKey, signatures::CommitmentSignature};
use tari_utilities::ByteArray;

use crate::tari_rpc as grpc;

impl TryFrom<grpc::CommitmentSignature> for CommitmentSignature<PublicKey, PrivateKey> {
impl TryFrom<grpc::CommitmentSignature> for CommitmentSignature<RistrettoPublicKey, PrivateKey> {
type Error = String;

fn try_from(sig: grpc::CommitmentSignature) -> Result<Self, Self::Error> {
let public_nonce = HomomorphicCommitment::<PublicKey>::from_canonical_bytes(&sig.public_nonce)
let public_nonce = HomomorphicCommitment::<RistrettoPublicKey>::from_canonical_bytes(&sig.public_nonce)
.map_err(|_| "Could not get public nonce".to_string())?;
let u = PrivateKey::from_canonical_bytes(&sig.u).map_err(|_| "Could not get u_x".to_string())?;
let v = PrivateKey::from_canonical_bytes(&sig.v).map_err(|_| "Could not get v_x".to_string())?;
Expand All @@ -41,8 +41,8 @@ impl TryFrom<grpc::CommitmentSignature> for CommitmentSignature<PublicKey, Priva
}
}

impl From<CommitmentSignature<PublicKey, PrivateKey>> for grpc::CommitmentSignature {
fn from(sig: CommitmentSignature<PublicKey, PrivateKey>) -> Self {
impl From<CommitmentSignature<RistrettoPublicKey, PrivateKey>> for grpc::CommitmentSignature {
fn from(sig: CommitmentSignature<RistrettoPublicKey, PrivateKey>) -> Self {
Self {
public_nonce: sig.public_nonce().to_vec(),
u: sig.u().to_vec(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl TryFrom<grpc::Signature> for Signature {
impl<T: Borrow<Signature>> From<T> for grpc::Signature {
fn from(sig: T) -> Self {
Self {
public_nonce: sig.borrow().get_public_nonce().to_vec(),
public_nonce: sig.borrow().get_compressed_public_nonce().to_vec(),
signature: sig.borrow().get_signature().to_vec(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl From<TransactionKernel> for grpc::TransactionKernel {
lock_height: kernel.lock_height,
excess: Vec::from(kernel.excess.as_bytes()),
excess_sig: Some(grpc::Signature {
public_nonce: Vec::from(kernel.excess_sig.get_public_nonce().as_bytes()),
public_nonce: Vec::from(kernel.excess_sig.get_compressed_public_nonce().as_bytes()),
signature: Vec::from(kernel.excess_sig.get_signature().as_bytes()),
}),
hash,
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_comms_dht = { path = "../../comms/dht" }
tari_contacts = { path = "../../base_layer/contacts" }
tari_crypto = { git = "https://github.com/SWvheerden/tari-crypto", rev = "97f1c9f90b24974b25d029c740adff8d6c13f27d" }
tari_crypto = { git = "https://github.com/SWvheerden/tari-crypto", rev = "236aa26779bbeb9468250af622695f1dcc5b8d6a" }
tari_key_manager = { path = "../../base_layer/key_manager" }
tari_libtor = { path = "../../infrastructure/libtor", optional = true }
tari_max_size = { path = "../../infrastructure/max_size" }
Expand Down
71 changes: 41 additions & 30 deletions applications/minotari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ use tari_common_types::{
key_branches::TransactionKeyManagerBranch,
tari_address::TariAddress,
transaction::TxId,
types::{Commitment, FixedHash, HashOutput, PrivateKey, PublicKey, Signature},
types::{
Commitment,
FixedHash,
HashOutput,
PrivateKey,
PublicKey,
Signature,
UncompressedCommitment,
UncompressedPublicKey,
UncompressedSignature,
},
wallet_types::WalletType,
};
use tari_comms::{
Expand All @@ -78,7 +88,7 @@ use tari_core::{
covenants::Covenant,
one_sided::shared_secret_to_output_encryption_key,
transactions::{
key_manager::TransactionKeyManagerInterface,
key_manager::{TariKeyId, TransactionKeyManagerInterface},
tari_amount::{uT, MicroMinotari, Minotari},
transaction_components::{
encrypted_data::{PaymentId, TxType},
Expand All @@ -99,15 +109,11 @@ use tari_core::{
use tari_crypto::{
commitment::HomomorphicCommitmentFactory,
dhke::DiffieHellmanSharedSecret,
ristretto::{pedersen::PedersenCommitment, RistrettoSecretKey},
};
use tari_key_manager::{
cipher_seed::CipherSeed,
key_manager_service::{KeyId, KeyManagerInterface},
SeedWords,
ristretto::RistrettoSecretKey,
};
use tari_key_manager::{cipher_seed::CipherSeed, SeedWords};
use tari_p2p::{auto_update::AutoUpdateConfig, peer_seeds::SeedPeer, PeerSeedsConfig};
use tari_script::{push_pubkey_script, CheckSigSchnorrSignature};
use tari_script::{push_pubkey_script, CompressedCheckSigSchnorrSignature};
use tari_shutdown::Shutdown;
use tari_utilities::{encoding::MBase58, hex::Hex, ByteArray, SafePassword};
use tokio::{
Expand Down Expand Up @@ -207,8 +213,8 @@ pub async fn burn_tari(
async fn encumber_aggregate_utxo(
mut wallet_transaction_service: TransactionServiceHandle,
fee_per_gram: MicroMinotari,
expected_commitment: PedersenCommitment,
script_input_shares: HashMap<PublicKey, CheckSigSchnorrSignature>,
expected_commitment: Commitment,
script_input_shares: HashMap<PublicKey, CompressedCheckSigSchnorrSignature>,
script_signature_public_nonces: Vec<PublicKey>,
sender_offset_public_key_shares: Vec<PublicKey>,
metadata_ephemeral_public_key_shares: Vec<PublicKey>,
Expand Down Expand Up @@ -240,7 +246,7 @@ async fn spend_backup_pre_mine_utxo(
mut wallet_transaction_service: TransactionServiceHandle,
fee_per_gram: MicroMinotari,
output_hash: HashOutput,
expected_commitment: PedersenCommitment,
expected_commitment: Commitment,
recipient_address: TariAddress,
payment_id: PaymentId,
) -> Result<TxId, CommandError> {
Expand All @@ -266,18 +272,23 @@ async fn finalise_aggregate_utxo(
) -> Result<TxId, CommandError> {
trace!(target: LOG_TARGET, "finalise_aggregate_utxo: start");

let mut meta_sig = Signature::default();
let mut meta_sig = UncompressedSignature::default();
for sig in &meta_signatures {
meta_sig = &meta_sig + sig;
meta_sig = &meta_sig + sig.to_schnorr_signature()?;
}
let mut script_sig = Signature::default();
let mut script_sig = UncompressedSignature::default();
for sig in &script_signatures {
script_sig = &script_sig + sig;
script_sig = &script_sig + sig.to_schnorr_signature()?;
}
trace!(target: LOG_TARGET, "finalise_aggregate_utxo: aggregated signatures");

wallet_transaction_service
.finalize_aggregate_utxo(tx_id, meta_sig, script_sig, wallet_script_secret_key)
.finalize_aggregate_utxo(
tx_id,
Signature::new_from_schnorr(meta_sig),
Signature::new_from_schnorr(script_sig),
wallet_script_secret_key,
)
.await
.map_err(CommandError::TransactionServiceError)
}
Expand Down Expand Up @@ -803,7 +814,7 @@ pub async fn command_runner(
println!("The following can be used to claim the burnt funds:");
println!();
println!("claim_public_key: {}", proof.reciprocal_claim_public_key);
println!("commitment: {}", proof.commitment.as_public_key());
println!("commitment: {}", proof.commitment.to_public_key()?);
println!("ownership_proof: {:?}", proof.ownership_proof);
println!("ownership_proof: {:?}", proof.range_proof);
tx_ids.push(tx_id);
Expand Down Expand Up @@ -1105,7 +1116,7 @@ pub async fn command_runner(
.await?;
let shared_secret_public_key = PublicKey::from_canonical_bytes(shared_secret.as_bytes())?;

let pre_mine_script_key_id = KeyId::Managed {
let pre_mine_script_key_id = TariKeyId::Managed {
branch: TransactionKeyManagerBranch::PreMine.get_branch_key(),
index: *output_index as u64,
};
Expand Down Expand Up @@ -1528,7 +1539,7 @@ pub async fn command_runner(
};

// lets verify the script
let shared_secret = match DiffieHellmanSharedSecret::<PublicKey>::from_canonical_bytes(
let shared_secret = match DiffieHellmanSharedSecret::<UncompressedPublicKey>::from_canonical_bytes(
leader_info.shared_secret.as_bytes(),
) {
Ok(v) => v,
Expand Down Expand Up @@ -1805,15 +1816,15 @@ pub async fn command_runner(
},
}

let mut utxo_sum = Commitment::default();
let mut utxo_sum = UncompressedCommitment::default();
for output in tx.transaction.body.outputs() {
outputs.push(output.clone());
utxo_sum = &utxo_sum + &output.commitment;
utxo_sum = &utxo_sum + &output.commitment.to_commitment()?;
}
for input in tx.transaction.body.inputs() {
inputs.push(input.clone());
match input.commitment() {
Ok(commitment) => utxo_sum = &utxo_sum - commitment,
Ok(commitment) => utxo_sum = &utxo_sum - &commitment.to_commitment()?,
Err(e) => {
eprintln!("\nError: Input commitment ({})!\n", e);
error = true;
Expand All @@ -1824,10 +1835,10 @@ pub async fn command_runner(
if error {
break;
}
let mut kernel_sum = Commitment::default();
let mut kernel_sum = UncompressedCommitment::default();
for kernel in tx.transaction.body.kernels() {
kernels.push(kernel.clone());
kernel_sum = &kernel_sum + &kernel.excess;
kernel_sum = &kernel_sum + &kernel.excess.to_commitment()?;
}
kernel_offset = &kernel_offset + &tx.transaction.offset;
// Ensure that the balance equation holds:
Expand Down Expand Up @@ -1873,22 +1884,22 @@ pub async fn command_runner(
if session_info.use_pre_mine_input_file {
// Ensure that the balance equation holds:
// sum(output commitments) - sum(input commitments) = sum(kernel excesses) + kernel_offset
let mut utxo_sum = Commitment::default();
let mut utxo_sum = UncompressedCommitment::default();
for output in &outputs {
utxo_sum = &utxo_sum + &output.commitment;
utxo_sum = &utxo_sum + &output.commitment.to_commitment()?;
}
for input in &inputs {
match input.commitment() {
Ok(commitment) => utxo_sum = &utxo_sum - commitment,
Ok(commitment) => utxo_sum = &utxo_sum - &commitment.to_commitment()?,
Err(e) => {
eprintln!("\nError: Input commitment ({})!\n", e);
break;
},
}
}
let mut kernel_sum = Commitment::default();
let mut kernel_sum = UncompressedCommitment::default();
for kernel in &kernels {
kernel_sum = &kernel_sum + &kernel.excess;
kernel_sum = &kernel_sum + &kernel.excess.to_commitment()?;
}
let offset = CryptoFactories::default().commitment.commit_value(&kernel_offset, 0);
if utxo_sum != &kernel_sum + &offset {
Expand Down
7 changes: 5 additions & 2 deletions applications/minotari_console_wallet/src/automation/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ use minotari_wallet::{
};
use tari_common::exit_codes::{ExitCode, ExitError};
use tari_common_types::types::FixedHashSizeError;
use tari_core::transactions::{tari_amount::MicroMinotariError, transaction_components::TransactionError};
use tari_core::transactions::{
key_manager::error::KeyManagerServiceError,
tari_amount::MicroMinotariError,
transaction_components::TransactionError,
};
use tari_crypto::signatures::SchnorrSignatureError;
use tari_key_manager::key_manager_service::KeyManagerServiceError;
use tari_script::ScriptError;
use tari_utilities::{hex::HexError, ByteArrayError};
use thiserror::Error;
Expand Down
4 changes: 2 additions & 2 deletions applications/minotari_console_wallet/src/automation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use tari_core::transactions::{
tari_amount::MicroMinotari,
transaction_components::{EncryptedData, OutputFeatures},
};
use tari_script::{CheckSigSchnorrSignature, ExecutionStack, TariScript};
use tari_script::{CompressedCheckSigSchnorrSignature, ExecutionStack, TariScript};

// Step 1 outputs for all with `PreMineSpendSessionInfo`
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
Expand Down Expand Up @@ -88,7 +88,7 @@ struct PreMineSpendStep2OutputsForLeader {
pub struct Step2OutputsForLeader {
output_index: usize,
recipient_address: TariAddress,
script_input_signature: CheckSigSchnorrSignature,
script_input_signature: CompressedCheckSigSchnorrSignature,
public_script_nonce_key: PublicKey,
public_sender_offset_key: PublicKey,
public_sender_offset_nonce_key: PublicKey,
Expand Down
5 changes: 4 additions & 1 deletion applications/minotari_console_wallet/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,10 @@ fn setup_identity_from_db<D: WalletBackend + 'static>(
// to None
let identity_sig = identity_sig.filter(|sig| {
let comms_public_key = CommsPublicKey::from_secret_key(&comms_secret_key);
sig.is_valid(&comms_public_key, node_features, &node_addresses)
match sig.is_valid(&comms_public_key, node_features, &node_addresses) {
Ok(true) => true,
_ => false,
}
});

// SAFETY: we are manually checking the validity of this signature before adding Some(..)
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_console_wallet/src/notifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ fn args_from_complete(tx: &CompletedTransaction, event: &str, confirmations: Opt
let excess_sig = &kernel.excess_sig;
(
kernel.excess.to_hex(),
excess_sig.get_public_nonce().to_hex(),
excess_sig.get_compressed_public_nonce().to_hex(),
excess_sig.get_signature().to_hex(),
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ impl CompletedTransactionInfo {
.unwrap_or_default(),
tx.transaction
.first_kernel_excess_sig()
.map(|s| s.get_public_nonce().to_hex())
.map(|s| s.get_compressed_public_nonce().to_hex())
.unwrap_or_default()
);
let weight = tx.transaction.calculate_weight(transaction_weighting)?;
Expand Down
10 changes: 6 additions & 4 deletions applications/minotari_console_wallet/src/ui/state/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use minotari_wallet::{
use rand::{random, rngs::OsRng};
use tari_common_types::{
tari_address::TariAddress,
types::{PublicKey, Signature},
types::{PublicKey, Signature, UncompressedSignature},
};
use tari_core::{
consensus::DomainSeparatedConsensusHasher,
Expand All @@ -42,7 +42,7 @@ use tari_core::{
transaction_components::{encrypted_data::PaymentId, BuildInfo, OutputFeatures, TemplateType},
},
};
use tari_crypto::{keys::PublicKey as PublicKeyTrait, ristretto::RistrettoPublicKey};
use tari_crypto::ristretto::RistrettoPublicKey;
use tari_hashing::TransactionHashDomain;
use tari_key_manager::key_manager::KeyManager;
use tari_max_size::{MaxSizeBytes, MaxSizeString};
Expand Down Expand Up @@ -417,8 +417,10 @@ pub async fn send_register_template_transaction_task(
.chain(&b"")
.finalize();

let author_signature = Signature::sign_raw_uniform(&author_private_key, secret_nonce, &challenge)
.expect("Sign cannot fail with 32-byte challenge and a RistrettoPublicKey");
let author_signature = Signature::new_from_schnorr(
UncompressedSignature::sign_raw_uniform(&author_private_key, secret_nonce, &challenge)
.expect("Sign cannot fail with 32-byte challenge and a RistrettoPublicKey"),
);

// ----------------------------------------------------------------------------
// ============================================================================
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_ledger_wallet/comms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "BSD-3-Clause"
edition = "2021"

[dependencies]
tari_crypto = { git = "https://github.com/SWvheerden/tari-crypto", rev = "97f1c9f90b24974b25d029c740adff8d6c13f27d", default-features = false }
tari_crypto = { git = "https://github.com/SWvheerden/tari-crypto", rev = "236aa26779bbeb9468250af622695f1dcc5b8d6a", default-features = false }
tari_utilities = { version = "0.8" }
tari_common = { path = "../../../common" }
tari_common_types = { path = "../../../base_layer/common_types" }
Expand Down
Loading

0 comments on commit 3d70ea3

Please sign in to comment.