From f6a8a11f98799433c0a5f3d35e245a556c3801dc Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Thu, 17 Jul 2025 10:22:24 -0300 Subject: [PATCH] make inputs a vector to allow variable number of input accounts --- risc0-selective-privacy-poc/src/lib.rs | 5 ++--- .../transfer_methods/guest/src/bin/transfer.rs | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/risc0-selective-privacy-poc/src/lib.rs b/risc0-selective-privacy-poc/src/lib.rs index f9b167f..2d07b59 100644 --- a/risc0-selective-privacy-poc/src/lib.rs +++ b/risc0-selective-privacy-poc/src/lib.rs @@ -20,9 +20,8 @@ fn write_inputs( instruction_data: &P::InstructionData, env_builder: &mut ExecutorEnvBuilder, ) -> Result<(), ()> { - for account in input_accounts { - env_builder.write(&account).map_err(|_| ())?; - } + let input_accounts = input_accounts.to_vec(); + env_builder.write(&input_accounts).map_err(|_| ())?; env_builder.write(&instruction_data).map_err(|_| ())?; Ok(()) } diff --git a/risc0-selective-privacy-poc/transfer_methods/guest/src/bin/transfer.rs b/risc0-selective-privacy-poc/transfer_methods/guest/src/bin/transfer.rs index f3f19b4..1d786ee 100644 --- a/risc0-selective-privacy-poc/transfer_methods/guest/src/bin/transfer.rs +++ b/risc0-selective-privacy-poc/transfer_methods/guest/src/bin/transfer.rs @@ -8,10 +8,12 @@ use risc0_zkvm::{ /// A transfer of balance program. /// To be used both in public and private contexts. fn main() { - let sender: Account = env::read(); - let receiver: Account = env::read(); + let mut input_accounts: Vec = env::read(); let balance_to_move: u128 = env::read(); + assert_eq!(input_accounts.len(), 2); + let [sender, receiver] = input_accounts.try_into().unwrap(); + // Check sender has enough balance assert!(sender.balance >= balance_to_move);