This commit is contained in:
Sergio Chouhy 2025-07-16 17:33:58 -03:00
parent 3d582d491f
commit 0e704cd51a
6 changed files with 21 additions and 20 deletions

View File

@ -1,5 +1,5 @@
[package] [package]
name = "tuki" name = "nssa"
version = "0.12.0" version = "0.12.0"
edition = "2021" edition = "2021"
@ -11,10 +11,9 @@ outer-methods = { path = "outer_methods" }
serde = "1.0" serde = "1.0"
tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] }
rand = "0.8" rand = "0.8"
sparse-merkle-tree = {path="./sparse_merkle_tree/"} sparse-merkle-tree = { path = "./sparse_merkle_tree/" }
[features] [features]
cuda = ["risc0-zkvm/cuda"] cuda = ["risc0-zkvm/cuda"]
default = [] default = []
prove = ["risc0-zkvm/prove"] prove = ["risc0-zkvm/prove"]

View File

@ -1,7 +1,8 @@
mod programs; mod programs;
use nssa;
use nssa::program::TransferProgram;
use outer_methods::{OUTER_ELF, OUTER_ID}; use outer_methods::{OUTER_ELF, OUTER_ID};
use programs::TransferProgram;
use risc0_zkvm::{default_prover, ExecutorEnv, ProveInfo, Receipt}; use risc0_zkvm::{default_prover, ExecutorEnv, ProveInfo, Receipt};
use sparse_merkle_tree::SparseMerkleTree; use sparse_merkle_tree::SparseMerkleTree;
use toy_example_core::{ use toy_example_core::{
@ -11,7 +12,6 @@ use toy_example_core::{
types::{Address, AuthenticationPath, Commitment, Nonce, Nullifier}, types::{Address, AuthenticationPath, Commitment, Nonce, Nullifier},
}; };
use transfer_methods::{TRANSFER_ELF, TRANSFER_ID}; use transfer_methods::{TRANSFER_ELF, TRANSFER_ID};
use tuki::{prove_privacy_execution, Program};
fn mint_fresh_account(address: Address) -> Account { fn mint_fresh_account(address: Address) -> Account {
let nonce = [0; 8]; let nonce = [0; 8];
@ -51,7 +51,7 @@ fn main() {
InputVisibiility::Private(Some((sender_private_key, auth_path))), InputVisibiility::Private(Some((sender_private_key, auth_path))),
InputVisibiility::Private(None), InputVisibiility::Private(None),
]; ];
let prove_info = prove_privacy_execution::<TransferProgram>( let prove_info = nssa::prove_privacy_execution::<TransferProgram>(
&[sender, receiver], &[sender, receiver],
&balance_to_move, &balance_to_move,
&visibilities, &visibilities,

View File

@ -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;
}

View File

@ -4,9 +4,9 @@ use risc0_zkvm::{default_executor, ExecutorEnv};
use toy_example_core::account::Account; use toy_example_core::account::Account;
use transfer_methods::TRANSFER_ELF; use transfer_methods::TRANSFER_ELF;
use tuki::{execute, Program}; use nssa;
use crate::programs::TransferProgram; use nssa::program::TransferProgram;
/// A public execution. /// A public execution.
/// This would be executed by the runtime after checking that /// This would be executed by the runtime after checking that
@ -28,7 +28,8 @@ pub fn main() {
let balance_to_move: u128 = 3; let balance_to_move: u128 = 3;
let inputs_outputs = execute::<TransferProgram>(&[sender, receiver], &balance_to_move).unwrap(); let inputs_outputs =
nssa::execute::<TransferProgram>(&[sender, receiver], &balance_to_move).unwrap();
println!( println!(
"sender_before: {:?}, sender_after: {:?}", "sender_before: {:?}, sender_after: {:?}",

View File

@ -6,6 +6,8 @@ use risc0_zkvm::{
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use toy_example_core::{account::Account, input::InputVisibiility, types::Nonce}; use toy_example_core::{account::Account, input::InputVisibiility, types::Nonce};
pub mod program;
pub fn new_random_nonce() -> Nonce { pub fn new_random_nonce() -> Nonce {
let mut rng = OsRng; let mut rng = OsRng;
std::array::from_fn(|_| rng.gen()) std::array::from_fn(|_| rng.gen())

View File

@ -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;
}