Skip to content

Commit

Permalink
circuits: Add sender_pk to Note creation in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moCello committed Jun 18, 2024
1 parent 616e062 commit 73991d9
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions circuits/tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ lazy_static! {
let schnorr_sk_b = SchnorrSecretKey::from(sender_sk.b());
let sig_b = schnorr_sk_b.sign(&mut rng, payload_hash);

// sender blinder for the output notes
let sender_blinder_0 = (
JubJubScalar::random(&mut rng),
JubJubScalar::random(&mut rng),
Expand Down Expand Up @@ -115,15 +116,21 @@ lazy_static! {
fn create_and_insert_test_note(
rng: &mut (impl RngCore + CryptoRng),
tree: &mut Tree<(), HEIGHT>,
pk: &PublicKey,
receiver_pk: &PublicKey,
pos: u64,
value: u64,
) -> Note {
let sender_blinder = [
let sender_blinder = (
JubJubScalar::random(&mut *rng),
JubJubScalar::random(&mut *rng),
];
let mut note = Note::transparent(rng, pk, value, sender_blinder);
);
let mut note = Note::transparent(
rng,
&TP.sender_pk,
receiver_pk,
value,
sender_blinder,
);
note.set_pos(pos);

let item = Item {
Expand All @@ -138,17 +145,17 @@ fn create_and_insert_test_note(
fn create_test_tx_input_notes<const I: usize>(
rng: &mut (impl RngCore + CryptoRng),
tree: &mut Tree<(), HEIGHT>,
sk: &SecretKey,
receiver_sk: &SecretKey,
payload_hash: BlsScalar,
) -> [TxInputNote<HEIGHT>; I] {
let pk = PublicKey::from(sk);
let receiver_pk = PublicKey::from(receiver_sk);

let mut notes = Vec::new();
for i in 0..I {
notes.push(create_and_insert_test_note(
rng,
tree,
&pk,
&receiver_pk,
i.try_into().unwrap(),
25,
));
Expand All @@ -157,9 +164,14 @@ fn create_test_tx_input_notes<const I: usize>(
let mut input_notes = Vec::new();
for i in 0..I {
let merkle_opening = tree.opening(*notes[i].pos()).expect("Tree read.");
let input_note =
TxInputNote::new(rng, &notes[i], merkle_opening, &sk, payload_hash)
.expect("Note created properly.");
let input_note = TxInputNote::new(
rng,
&notes[i],
merkle_opening,
&receiver_sk,
payload_hash,
)
.expect("Note created properly.");

input_notes.push(input_note);
}
Expand Down

0 comments on commit 73991d9

Please sign in to comment.