Skip to content

Commit

Permalink
rusk-prover: Hide transaction payloads from the api
Browse files Browse the repository at this point in the history
  • Loading branch information
moCello committed Aug 9, 2024
1 parent 3ba1a8f commit da6994a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
59 changes: 30 additions & 29 deletions rusk-prover/src/prover/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -33,10 +33,10 @@ pub static EXEC_4_2_PROVER: Lazy<PlonkProver> =
fn create_circuit<const I: usize>(
utx: &UnprovenTransaction,
) -> Result<TxCircuit<NOTES_TREE_DEPTH, I>, 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(),
Expand All @@ -46,7 +46,7 @@ fn create_circuit<const I: usize>(
signature: input.sig,
});
});
let tx_input_notes: [TxInputNote<NOTES_TREE_DEPTH>; I] = tx_input_notes
let tx_input_notes: [InputNoteInfo<NOTES_TREE_DEPTH>; I] = tx_input_notes
.try_into()
.expect("the numbers of input-notes should be as expected");

Expand Down Expand Up @@ -81,38 +81,39 @@ fn create_circuit<const I: usize>(
}
};
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<NOTES_TREE_DEPTH, I> = 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<NOTES_TREE_DEPTH, I> = 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)
}
Expand Down
5 changes: 4 additions & 1 deletion rusk-prover/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit da6994a

Please sign in to comment.