From 0e704cd51a06a19a7d9c1803029c4d1dabe281a6 Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Wed, 16 Jul 2025 17:33:58 -0300 Subject: [PATCH] refactor --- risc0-selective-privacy-poc/Cargo.toml | 5 ++--- .../examples/private_execution.rs | 6 +++--- risc0-selective-privacy-poc/examples/programs/mod.rs | 11 ----------- .../examples/public_execution.rs | 7 ++++--- risc0-selective-privacy-poc/src/lib.rs | 2 ++ risc0-selective-privacy-poc/src/program.rs | 10 ++++++++++ 6 files changed, 21 insertions(+), 20 deletions(-) delete mode 100644 risc0-selective-privacy-poc/examples/programs/mod.rs diff --git a/risc0-selective-privacy-poc/Cargo.toml b/risc0-selective-privacy-poc/Cargo.toml index a236a11..a90a0e3 100644 --- a/risc0-selective-privacy-poc/Cargo.toml +++ b/risc0-selective-privacy-poc/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "tuki" +name = "nssa" version = "0.12.0" edition = "2021" @@ -11,10 +11,9 @@ outer-methods = { path = "outer_methods" } serde = "1.0" tracing-subscriber = { version = "0.3", features = ["env-filter"] } rand = "0.8" -sparse-merkle-tree = {path="./sparse_merkle_tree/"} +sparse-merkle-tree = { path = "./sparse_merkle_tree/" } [features] cuda = ["risc0-zkvm/cuda"] default = [] prove = ["risc0-zkvm/prove"] - diff --git a/risc0-selective-privacy-poc/examples/private_execution.rs b/risc0-selective-privacy-poc/examples/private_execution.rs index a19b5bb..0296a83 100644 --- a/risc0-selective-privacy-poc/examples/private_execution.rs +++ b/risc0-selective-privacy-poc/examples/private_execution.rs @@ -1,7 +1,8 @@ mod programs; +use nssa; +use nssa::program::TransferProgram; use outer_methods::{OUTER_ELF, OUTER_ID}; -use programs::TransferProgram; use risc0_zkvm::{default_prover, ExecutorEnv, ProveInfo, Receipt}; use sparse_merkle_tree::SparseMerkleTree; use toy_example_core::{ @@ -11,7 +12,6 @@ use toy_example_core::{ types::{Address, AuthenticationPath, Commitment, Nonce, Nullifier}, }; use transfer_methods::{TRANSFER_ELF, TRANSFER_ID}; -use tuki::{prove_privacy_execution, Program}; fn mint_fresh_account(address: Address) -> Account { let nonce = [0; 8]; @@ -51,7 +51,7 @@ fn main() { InputVisibiility::Private(Some((sender_private_key, auth_path))), InputVisibiility::Private(None), ]; - let prove_info = prove_privacy_execution::( + let prove_info = nssa::prove_privacy_execution::( &[sender, receiver], &balance_to_move, &visibilities, diff --git a/risc0-selective-privacy-poc/examples/programs/mod.rs b/risc0-selective-privacy-poc/examples/programs/mod.rs deleted file mode 100644 index b61b7ba..0000000 --- a/risc0-selective-privacy-poc/examples/programs/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -use transfer_methods::{TRANSFER_ELF, TRANSFER_ID}; -use tuki::Program; - -pub struct TransferProgram; - -impl Program for TransferProgram { - const PROGRAM_ID: [u32; 8] = TRANSFER_ID; - const PROGRAM_ELF: &[u8] = TRANSFER_ELF; - // Amount to transfer - type InstructionData = u128; -} diff --git a/risc0-selective-privacy-poc/examples/public_execution.rs b/risc0-selective-privacy-poc/examples/public_execution.rs index 9ede169..670ab68 100644 --- a/risc0-selective-privacy-poc/examples/public_execution.rs +++ b/risc0-selective-privacy-poc/examples/public_execution.rs @@ -4,9 +4,9 @@ use risc0_zkvm::{default_executor, ExecutorEnv}; use toy_example_core::account::Account; use transfer_methods::TRANSFER_ELF; -use tuki::{execute, Program}; +use nssa; -use crate::programs::TransferProgram; +use nssa::program::TransferProgram; /// A public execution. /// This would be executed by the runtime after checking that @@ -28,7 +28,8 @@ pub fn main() { let balance_to_move: u128 = 3; - let inputs_outputs = execute::(&[sender, receiver], &balance_to_move).unwrap(); + let inputs_outputs = + nssa::execute::(&[sender, receiver], &balance_to_move).unwrap(); println!( "sender_before: {:?}, sender_after: {:?}", diff --git a/risc0-selective-privacy-poc/src/lib.rs b/risc0-selective-privacy-poc/src/lib.rs index d83813a..f5326a4 100644 --- a/risc0-selective-privacy-poc/src/lib.rs +++ b/risc0-selective-privacy-poc/src/lib.rs @@ -6,6 +6,8 @@ use risc0_zkvm::{ use serde::{Deserialize, Serialize}; use toy_example_core::{account::Account, input::InputVisibiility, types::Nonce}; +pub mod program; + pub fn new_random_nonce() -> Nonce { let mut rng = OsRng; std::array::from_fn(|_| rng.gen()) diff --git a/risc0-selective-privacy-poc/src/program.rs b/risc0-selective-privacy-poc/src/program.rs index e69de29..52ec5e4 100644 --- a/risc0-selective-privacy-poc/src/program.rs +++ b/risc0-selective-privacy-poc/src/program.rs @@ -0,0 +1,10 @@ +use transfer_methods::{TRANSFER_ELF, TRANSFER_ID}; + +pub struct TransferProgram; + +impl crate::Program for TransferProgram { + const PROGRAM_ID: [u32; 8] = TRANSFER_ID; + const PROGRAM_ELF: &[u8] = TRANSFER_ELF; + // Amount to transfer + type InstructionData = u128; +}