From e11c701f9badd8a9e399686373bff306030e7254 Mon Sep 17 00:00:00 2001 From: Daksh <41485688+Daksh14@users.noreply.github.com> Date: Tue, 10 Sep 2024 12:53:00 -0400 Subject: [PATCH] test-wallet: Adapt to new wallet-core Co-authored-by: Daksh --- rusk-wallet/src/lib.rs | 5 ++--- rusk-wallet/src/wallet.rs | 17 +++++++++-------- wallet-core/src/transaction.rs | 15 +++++++++++---- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/rusk-wallet/src/lib.rs b/rusk-wallet/src/lib.rs index d89b1902c1..62e43610ef 100644 --- a/rusk-wallet/src/lib.rs +++ b/rusk-wallet/src/lib.rs @@ -40,9 +40,8 @@ use execution_core::{ signatures::bls::PublicKey as AccountPublicKey, stake::StakeData, transfer::phoenix::{ - ArchivedNoteLeaf, Note, NoteLeaf, NoteOpening, - PublicKey as PhoenixPublicKey, SecretKey as PhoenixSecretKey, - ViewKey as PhoenixViewKey, + ArchivedNoteLeaf, Note, NoteOpening, PublicKey as PhoenixPublicKey, + SecretKey as PhoenixSecretKey, ViewKey as PhoenixViewKey, }, BlsScalar, }; diff --git a/rusk-wallet/src/wallet.rs b/rusk-wallet/src/wallet.rs index 775866851a..f41dfa62fe 100644 --- a/rusk-wallet/src/wallet.rs +++ b/rusk-wallet/src/wallet.rs @@ -36,7 +36,7 @@ use wallet_core::{ use execution_core::{ signatures::bls::{PublicKey as BlsPublicKey, SecretKey as BlsSecretKey}, - transfer::{data::TransactionData, Transaction}, + transfer::{data::ContractCall, data::TransactionData, Transaction}, }; use zeroize::Zeroize; @@ -539,7 +539,7 @@ impl Wallet { gas.limit, gas.price, chain_id, - data, + Some(data), &Prover, )?; @@ -730,7 +730,6 @@ impl Wallet { } let state = self.state()?; - let amt = *amt; let sender_index = addr.index()?; let mut stake_sk = self.bls_secret_key(sender_index); @@ -741,13 +740,14 @@ impl Wallet { let nonce = state.fetch_stake(&pk)?.map(|s| s.nonce).unwrap_or(0); let stake = moonlight_stake( + &stake_sk, &stake_sk, amt, - chain_id, - nonce, - account.nonce, gas.limit, gas.price, + account.nonce, + nonce, + chain_id, )?; stake_sk.zeroize(); @@ -842,11 +842,12 @@ impl Wallet { let unstake = moonlight_unstake( &mut rng, &stake_sk, + &stake_sk, unstake_value, - chain_id, - account.nonce + 1, gas.price, gas.limit, + account.nonce + 1, + chain_id, )?; stake_sk.zeroize(); diff --git a/wallet-core/src/transaction.rs b/wallet-core/src/transaction.rs index de9378f5a3..51f9a313c0 100644 --- a/wallet-core/src/transaction.rs +++ b/wallet-core/src/transaction.rs @@ -4,8 +4,7 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. -//! Implementations of basic wallet functionalities to create phoenix -//! transactions. +//! Implementations of basic wallet functionalities to create transactions. use alloc::vec::Vec; @@ -30,7 +29,16 @@ use execution_core::{ BlsScalar, ContractId, Error, JubJubScalar, }; -/// Generate a phoenix-transaction with a given prover. +/// An unproven-transaction is nearly identical to a [`PhoenixTransaction`] with +/// the only difference being that it carries a serialized [`TxCircuitVec`] +/// instead of the proof bytes. +/// This way it is possible to delegate the proof generation of the +/// [`TxCircuitVec`] after the unproven transaction was created while at the +/// same time ensuring non-malleability of the transaction, as the transaction's +/// payload-hash is part of the public inputs of the circuit. +/// Once the proof is generated from the [`TxCircuitVec`] bytes, it can +/// replace the serialized circuit in the transaction by calling +/// [`Transaction::replace_proof`]. /// /// # Errors /// The creation of a transaction is not possible and will error if: @@ -40,7 +48,6 @@ use execution_core::{ /// - the `inputs` vector contains duplicate `Note`s /// - the `Prove` trait is implemented incorrectly /// - the Memo provided with `data` is too large -/// - the transaction-data is incorrect #[allow(clippy::too_many_arguments)] pub fn phoenix( rng: &mut R,