Skip to content

Commit

Permalink
circuits: Make TxInputNote fields public
Browse files Browse the repository at this point in the history
  • Loading branch information
moCello committed Jun 25, 2024
1 parent ec8ac0b commit be9acb5
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions circuits/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ use crate::sender_enc;
/// suitable for being introduced in the transfer circuit
#[derive(Debug, Clone)]
pub struct TxInputNote<const H: usize> {
pub(crate) merkle_opening: Opening<(), H>,
pub(crate) note: Note,
pub(crate) note_pk_p: JubJubAffine,
pub(crate) value: u64,
pub(crate) value_blinder: JubJubScalar,
pub(crate) nullifier: BlsScalar,
pub(crate) signature: SignatureDouble,
/// the merkle opening for the note
pub merkle_opening: Opening<(), H>,
/// the input note
pub note: Note,
/// the note-public-key prime
pub note_pk_p: JubJubAffine,
/// the value associated to the note
pub value: u64,
/// the value blinder used to obfuscate the value
pub value_blinder: JubJubScalar,
/// the nullifier used to spend the note
pub nullifier: BlsScalar,
/// the signature of the payload-hash
pub signature: SignatureDouble,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -408,6 +415,25 @@ impl<const H: usize, const I: usize> TxCircuit<H, I> {
sender_blinder,
}
}

/// Return the public-input values used for the circuit
pub fn public_inputs(&self) -> Vec<BlsScalar> {
let size = 1 + 1 + I + 2 * 2 + 1 + 1 + 2 * 2 + 4 + 4;
let mut pi = Vec::with_capacity(size);
pi.push(self.payload_hash);
pi.push(self.root);
for input in self.tx_input_notes.iter() {
pi.push(input.nullifier);
}
pi.push(self.tx_output_notes[0].value_commitment.get_u());
pi.push(self.tx_output_notes[0].value_commitment.get_v());
pi.push(self.tx_output_notes[1].value_commitment.get_u());
pi.push(self.tx_output_notes[1].value_commitment.get_v());
pi.push(BlsScalar::from(self.max_fee));
pi.push(BlsScalar::from(self.deposit));

pi
}
}

impl<const H: usize, const I: usize> Circuit for TxCircuit<H, I> {
Expand Down

0 comments on commit be9acb5

Please sign in to comment.