Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hansieodendaal committed May 11, 2023
1 parent 08e8a4b commit f16bbca
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 8 deletions.
3 changes: 3 additions & 0 deletions base_layer/core/src/transactions/coinbase_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use crate::{
types::WalletServiceHashingDomain,
},
};
use crate::transactions::transaction_components::RangeProofType;

#[derive(Debug, Clone, Error, PartialEq, Eq)]
pub enum CoinbaseBuildError {
Expand Down Expand Up @@ -254,6 +255,8 @@ impl CoinbaseBuilder {
&covenant,
&encrypted_openings,
minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)
.map_err(|e| CoinbaseBuildError::BuildError(e.to_string()))?;

Expand Down
9 changes: 9 additions & 0 deletions base_layer/core/src/transactions/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use crate::{
SenderTransactionProtocol,
},
};
use crate::transactions::transaction_components::RangeProofType;

pub fn create_test_input(
amount: MicroTari,
Expand Down Expand Up @@ -196,6 +197,8 @@ impl TestParams {
&params.covenant,
&encrypted_openings,
params.minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)
.unwrap();

Expand Down Expand Up @@ -755,6 +758,8 @@ pub fn create_stx_protocol(schema: TransactionSchema) -> (SenderTransactionProto
&utxo.covenant,
&utxo.encrypted_openings,
utxo.minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)
.unwrap();
utxo.sender_offset_public_key = test_params.sender_offset_public_key;
Expand Down Expand Up @@ -787,6 +792,8 @@ pub fn create_stx_protocol(schema: TransactionSchema) -> (SenderTransactionProto
&covenant,
&encrypted_openings,
minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)
.unwrap();

Expand Down Expand Up @@ -858,6 +865,8 @@ pub fn create_utxo(
covenant,
&EncryptedOpenings::default(),
minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)
.unwrap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,15 @@ impl TransactionOutput {
) -> Result<ComAndPubSignature, TransactionError> {
let nonce_a = TransactionOutput::nonce_a(range_proof_type, value, minimum_value_promise)?;
let nonce_b = PrivateKey::random(&mut OsRng);
let nonce_commitment = CommitmentFactory::default().commit(&nonce_b, &nonce_a);
let ephemeral_commitment = CommitmentFactory::default().commit(&nonce_b, &nonce_a);
let pk_value = PrivateKey::from(value.as_u64());
let commitment = CommitmentFactory::default().commit(spending_key, &pk_value);
let e = TransactionOutput::build_metadata_signature_challenge(
version,
script,
output_features,
sender_offset_public_key,
&nonce_commitment,
&ephemeral_commitment,
ephemeral_pubkey,
&commitment,
covenant,
Expand Down Expand Up @@ -446,14 +446,14 @@ impl TransactionOutput {
Some(v) => v,
None => &random_key,
};
let public_nonce = PublicKey::from_secret_key(nonce);
let ephemeral_pubkey = PublicKey::from_secret_key(nonce);
let e = TransactionOutput::build_metadata_signature_challenge(
version,
script,
output_features,
&sender_offset_public_key,
ephemeral_commitment,
&public_nonce,
&ephemeral_pubkey,
commitment,
covenant,
encrypted_openings,
Expand Down Expand Up @@ -506,9 +506,9 @@ impl TransactionOutput {
) -> Result<ComAndPubSignature, TransactionError> {
let nonce_a = TransactionOutput::nonce_a(range_proof_type, value, minimum_value_promise)?;
let nonce_b = PrivateKey::random(&mut OsRng);
let nonce_commitment = CommitmentFactory::default().commit(&nonce_b, &nonce_a);
let ephemeral_commitment = CommitmentFactory::default().commit(&nonce_b, &nonce_a);
let nonce_x = PrivateKey::random(&mut OsRng);
let public_nonce_x = PublicKey::from_secret_key(&nonce_x);
let ephemeral_pubkey = PublicKey::from_secret_key(&nonce_x);
let pk_value = PrivateKey::from(value.as_u64());
let commitment = CommitmentFactory::default().commit(spending_key, &pk_value);
let sender_offset_public_key = PublicKey::from_secret_key(sender_offset_private_key);
Expand All @@ -517,8 +517,8 @@ impl TransactionOutput {
script,
output_features,
&sender_offset_public_key,
&nonce_commitment,
&public_nonce_x,
&ephemeral_commitment,
&ephemeral_pubkey,
&commitment,
covenant,
encrypted_openings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use crate::{
transaction_protocol::RewindData,
},
};
use crate::transactions::transaction_components::RangeProofType;

#[derive(Derivative, Clone)]
#[derivative(Debug)]
Expand Down Expand Up @@ -145,6 +146,8 @@ impl UnblindedOutputBuilder {
&self.covenant,
&self.encrypted_openings,
self.minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)?;
self.sender_offset_public_key = Some(PublicKey::from_secret_key(sender_offset_private_key));
self.metadata_signature = Some(metadata_signature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ mod test {
},
validation::transaction::TransactionInternalConsistencyValidator,
};
use crate::transactions::transaction_components::RangeProofType;

#[test]
fn test_not_single() {
Expand Down Expand Up @@ -890,6 +891,8 @@ mod test {
&covenant,
&encrypted_openings,
minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)
.unwrap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use crate::transactions::{
TransactionProtocolError as TPE,
},
};
use crate::transactions::transaction_components::RangeProofType;

/// SingleReceiverTransactionProtocol represents the actions taken by the single receiver in the one-round Tari
/// transaction protocol. The procedure is straightforward. Upon receiving the sender's information, the receiver:
Expand Down Expand Up @@ -146,6 +147,8 @@ impl SingleReceiverTransactionProtocol {
&sender_info.covenant,
&encrypted_openings,
minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)?;

let output = TransactionOutput::new_current_version(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ use crate::{
},
},
};
use crate::transactions::transaction_components::RangeProofType;

pub const LOG_TARGET: &str = "c::tx::tx_protocol::tx_initializer";

Expand Down Expand Up @@ -421,6 +422,8 @@ impl SenderTransactionInitializer {
&self.change_covenant,
&encrypted_openings,
minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)
.map_err(|e| e.to_string())?;

Expand Down
2 changes: 2 additions & 0 deletions base_layer/core/tests/node_comms_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use tari_crypto::keys::PublicKey as PublicKeyTrait;
use tari_script::{inputs, script, TariScript};
use tari_service_framework::reply_channel;
use tokio::sync::{broadcast, mpsc};
use tari_core::transactions::transaction_components::RangeProofType;

#[allow(dead_code)]
mod helpers;
Expand Down Expand Up @@ -299,6 +300,7 @@ async fn inbound_fetch_blocks_before_horizon_height() {
&Covenant::default(),
&utxo.encrypted_openings,
utxo.minimum_value_promise,
RangeProofType::BulletProofPlus,
)
.unwrap();
let unblinded_output = UnblindedOutput::new_current_version(
Expand Down
11 changes: 11 additions & 0 deletions base_layer/wallet/src/output_manager_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ use tari_service_framework::reply_channel;
use tari_shutdown::ShutdownSignal;
use tari_utilities::{hex::Hex, ByteArray};
use tokio::sync::Mutex;
use tari_core::transactions::transaction_components::RangeProofType;

use crate::{
base_node_service::handle::{BaseNodeEvent, BaseNodeServiceHandle},
Expand Down Expand Up @@ -842,6 +843,8 @@ where
&single_round_sender_data.covenant,
&encrypted_openings,
minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)?,
0,
single_round_sender_data.covenant.clone(),
Expand Down Expand Up @@ -1327,6 +1330,8 @@ where
&covenant,
&encrypted_openings,
minimum_amount_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)?;
let utxo = DbUnblindedOutput::rewindable_from_unblinded_output(
UnblindedOutput::new_current_version(
Expand Down Expand Up @@ -1825,6 +1830,8 @@ where
&covenant,
&encrypted_openings,
minimum_amount_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)?;

let output = DbUnblindedOutput::rewindable_from_unblinded_output(
Expand Down Expand Up @@ -2043,6 +2050,8 @@ where
&covenant,
&encrypted_openings,
minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)?;

let output = DbUnblindedOutput::rewindable_from_unblinded_output(
Expand Down Expand Up @@ -2254,6 +2263,8 @@ where
&covenant,
&encrypted_openings,
minimum_value_promise,
// TODO: Provide user options to use `RangeProofType::RevealedValue`
RangeProofType::BulletProofPlus,
)?;

let output = DbUnblindedOutput::rewindable_from_unblinded_output(
Expand Down

0 comments on commit f16bbca

Please sign in to comment.