From da6994a0d91ec283ddfea0e4c98b771b7805d362 Mon Sep 17 00:00:00 2001 From: moana Date: Fri, 9 Aug 2024 17:57:09 +0200 Subject: [PATCH] rusk-prover: Hide transaction payloads from the api --- rusk-prover/src/prover/execute.rs | 59 ++++++++++++++++--------------- rusk-prover/src/tx.rs | 5 ++- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/rusk-prover/src/prover/execute.rs b/rusk-prover/src/prover/execute.rs index b2ff21007..99cb8b045 100644 --- a/rusk-prover/src/prover/execute.rs +++ b/rusk-prover/src/prover/execute.rs @@ -8,7 +8,7 @@ use super::*; use execution_core::{ transfer::phoenix::{ - value_commitment, Sender, TxCircuit, TxInputNote, TxOutputNote, + value_commitment, InputNoteInfo, OutputNoteInfo, Sender, TxCircuit, NOTES_TREE_DEPTH, }, JubJubAffine, @@ -33,10 +33,10 @@ pub static EXEC_4_2_PROVER: Lazy = fn create_circuit( utx: &UnprovenTransaction, ) -> Result, ProverError> { - // Create the `TxInputNote` + // Create the `InputNoteInfo` let mut tx_input_notes = Vec::with_capacity(utx.inputs().len()); utx.inputs.iter().for_each(|input| { - tx_input_notes.push(TxInputNote { + tx_input_notes.push(InputNoteInfo { merkle_opening: input.opening, note: input.note.clone(), note_pk_p: input.npk_prime.into(), @@ -46,7 +46,7 @@ fn create_circuit( signature: input.sig, }); }); - let tx_input_notes: [TxInputNote; I] = tx_input_notes + let tx_input_notes: [InputNoteInfo; I] = tx_input_notes .try_into() .expect("the numbers of input-notes should be as expected"); @@ -81,38 +81,39 @@ fn create_circuit( } }; let tx_output_notes = [ - TxOutputNote::new( - *transfer_value, - transfer_value_commitment, - *transfer_value_blinder, - JubJubAffine::from( + OutputNoteInfo { + value: *transfer_value, + value_commitment: transfer_value_commitment, + value_blinder: *transfer_value_blinder, + note_pk: JubJubAffine::from( transfer_note.stealth_address().note_pk().as_ref(), ), - *transfer_note_sender_enc, - ), - TxOutputNote::new( - *change_value, - change_value_commitment, - *change_value_blinder, - JubJubAffine::from( + sender_enc: *transfer_note_sender_enc, + sender_blinder: *transfer_sender_blinder, + }, + OutputNoteInfo { + value: *change_value, + value_commitment: change_value_commitment, + value_blinder: *change_value_blinder, + note_pk: JubJubAffine::from( change_note.stealth_address().note_pk().as_ref(), ), - *change_note_sender_enc, - ), + sender_enc: *change_note_sender_enc, + sender_blinder: *change_sender_blinder, + }, ]; // Build the circuit - let circuit: TxCircuit = TxCircuit::new( - tx_input_notes, - tx_output_notes, - utx.payload_hash(), - utx.payload.tx_skeleton.root, - utx.payload.tx_skeleton.deposit, - utx.payload.fee.max_fee(), - utx.sender_pk, - utx.signatures, - [*transfer_sender_blinder, *change_sender_blinder], - ); + let circuit: TxCircuit = TxCircuit { + input_notes_info: tx_input_notes, + output_notes_info: tx_output_notes, + payload_hash: utx.payload_hash(), + root: utx.payload.tx_skeleton.root, + deposit: utx.payload.tx_skeleton.deposit, + max_fee: utx.payload.fee.max_fee(), + sender_pk: utx.sender_pk, + signatures: utx.signatures, + }; Ok(circuit) } diff --git a/rusk-prover/src/tx.rs b/rusk-prover/src/tx.rs index 92f94ccc7..f4453ff9e 100644 --- a/rusk-prover/src/tx.rs +++ b/rusk-prover/src/tx.rs @@ -175,7 +175,10 @@ pub struct UnprovenTransaction { impl UnprovenTransaction { /// Consumes self and a proof to generate a transaction. pub fn gen_transaction(self, proof: Proof) -> PhoenixTransaction { - PhoenixTransaction::new(self.payload, proof.to_bytes()) + PhoenixTransaction::from_payload_and_proof( + self.payload, + proof.to_bytes().to_vec(), + ) } /// Serialize the transaction to a variable length byte buffer.