diff --git a/template/sc_example/Cargo.toml b/template/sc_example/Cargo.toml deleted file mode 100644 index 10a5510..0000000 --- a/template/sc_example/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "sc_example" -version = "0.1.0" -edition = "2024" - -[dependencies] -serde_json = "1.0.81" - -[dependencies.sc_core] -path = "../../sc_core" - -[dependencies.utxo] -path = "../../utxo" - -[dependencies.serde] -features = ["derive"] -version = "1.0.60" diff --git a/template/sc_example/src/lib.rs b/template/sc_example/src/lib.rs deleted file mode 100644 index e680d20..0000000 --- a/template/sc_example/src/lib.rs +++ /dev/null @@ -1,70 +0,0 @@ -use sc_core::traits::{ - IContract, IDeshieldedExecutor, IInputParameters, IPrivateOutput, IPublicOutput, -}; -use serde::{Deserialize, Serialize}; -use utxo::utxo_core::UTXO; - -#[derive(Debug, Serialize, Deserialize)] -struct SmartContract {} - -impl<'a> IContract<'a> for SmartContract {} - -#[derive(Debug, Serialize, Deserialize)] -struct InputParameters { - pub a: u64, - pub b: u64, -} - -impl<'a> IInputParameters<'a> for InputParameters { - fn public_input_parameters_ser(&self) -> Vec> { - let param_vec = vec![self.a]; - - param_vec - .into_iter() - .map(|item| serde_json::to_vec(&item).unwrap()) - .collect::>() - } -} - -#[derive(Debug, Serialize)] -struct PublicOutputs { - pub ab: u64, -} - -impl IPublicOutput for PublicOutputs {} - -struct PrivateOutputs { - pub a_plus_b: u64, -} - -impl IPrivateOutput for PrivateOutputs { - fn make_utxo_list(&self) -> Vec { - let mut utxo_list = vec![]; - - let res_utxo = UTXO { - hash: [0; 32], - owner: [1; 32], - asset: vec![1, 2, 3], - amount: self.a_plus_b as u128, - privacy_flag: true, - randomness: [2; 32], - }; - - utxo_list.push(res_utxo); - - utxo_list - } -} - -impl<'a> IDeshieldedExecutor<'a, InputParameters, PublicOutputs, PrivateOutputs> for SmartContract { - fn deshielded_execution(&self, inputs: InputParameters) -> (PublicOutputs, PrivateOutputs) { - ( - PublicOutputs { - ab: inputs.a * inputs.b, - }, - PrivateOutputs { - a_plus_b: inputs.a + inputs.b, - }, - ) - } -} diff --git a/template/zk_test_template/Cargo.toml b/template/zk_test_template/Cargo.toml deleted file mode 100644 index 965545e..0000000 --- a/template/zk_test_template/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "zk_test_template" -version = "0.1.0" -edition = "2021" - -[dependencies] -anyhow = "1.0" -serde_json = "1.0.81" - -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } -test-methods = { path = "test_methods" } - -[dependencies.serde] -features = ["derive"] -version = "1.0.60" - -[features] -cuda = ["risc0-zkvm/cuda"] -default = [] -prove = ["risc0-zkvm/prove"] diff --git a/template/zk_test_template/src/lib.rs b/template/zk_test_template/src/lib.rs deleted file mode 100644 index d44b282..0000000 --- a/template/zk_test_template/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -//ToDo: handle ABI of smart contract diff --git a/template/zk_test_template/test_methods/Cargo.toml b/template/zk_test_template/test_methods/Cargo.toml deleted file mode 100644 index 35dc8bd..0000000 --- a/template/zk_test_template/test_methods/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "test-methods" -version = "0.1.0" -edition = "2021" - -[build-dependencies] -risc0-build = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } - -[package.metadata.risc0] -methods = ["guest"] diff --git a/template/zk_test_template/test_methods/build.rs b/template/zk_test_template/test_methods/build.rs deleted file mode 100644 index 08a8a4e..0000000 --- a/template/zk_test_template/test_methods/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - risc0_build::embed_methods(); -} diff --git a/template/zk_test_template/test_methods/guest/Cargo.toml b/template/zk_test_template/test_methods/guest/Cargo.toml deleted file mode 100644 index c207f1d..0000000 --- a/template/zk_test_template/test_methods/guest/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "test" -version = "0.1.0" -edition = "2021" - -[workspace] - -[dependencies] -serde_json = "1.0.81" -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", default-features = false, features = [ - "std", -] } - -[dependencies.serde] -features = ["derive"] -version = "1.0.60" - -[dependencies.{sc_name}] -path = "../../../{sc_name}" - -[dependencies.sc_core] -path = "../../../../sc_core" diff --git a/template/zk_test_template/test_methods/guest/src/bin/template_sc.rs b/template/zk_test_template/test_methods/guest/src/bin/template_sc.rs deleted file mode 100644 index eb914eb..0000000 --- a/template/zk_test_template/test_methods/guest/src/bin/template_sc.rs +++ /dev/null @@ -1,59 +0,0 @@ -use risc0_zkvm::{ - guest::env, -}; - -use {sc_name}::{SmartContract, InputParameters, PublicOutputs, PrivateOutputs}; -use sc_core::traits::{IContract, IInputParameters, IPublicOutput, IPrivateOutput}; -use sc_core::{{execution_type_trait}}; - -use sc_core::{PublicSCContext, produce_blob_list_from_sc_public_state, compare_blob_lists}; - -fn main() { - let mut state: SmartContract = env::read(); - //Must fail if this step fails - let old_state = produce_blob_list_from_sc_public_state(&state).unwrap(); - - let public_context: PublicSCContext = env::read(); - let inputs: InputParameters = env::read(); - - //In RISC0 all input parameters are private, so we need to commit to public ones - env::commit(&(inputs.public_input_parameters_ser())) - - //Next, push one of possible variants depending on execution type - { - public => let public_outputs = state.public_execution(inputs);, - private => let private_outputs = state.private_execution(inputs);, - shielded => let (public_outputs, private_outputs) = state.shielded_execution(inputs);, - deshielded => let (public_outputs, private_outputs) = state.shielded_execution(inputs);, - } - - //Next, push one of possible variants depending on execution type - //ToDo [Debatable]: Rework and update circuits to work with new trait system system - { - public => , - private => private_circuit(public_context, private_outputs);, - shielded => shielded_circuit(public_context, public_outputs, private_outputs);, - deshielded => deshielded_circuit(public_context, public_outputs, private_outputs);, - } - - //Must fail if this step fails - let new_state = produce_blob_list_from_sc_public_state(&state).unwrap(); - - //Commiting public state changes - let state_changes = compare_blob_lists(old_state, new_state); - env::commit(&state_changes); - - //Next, push one of possible variants depending on execution type - { - public => { - env::commit(&public_outputs); - }, - private => { - env::commit(&(public_context.encode_utxo_for_owners(private_outputs))); - }, - shielded | deshielded => { - env::commit(&public_outputs); - env::commit(&(public_context.encode_utxo_for_owners(private_outputs))); - }, - } -} diff --git a/template/zk_test_template/test_methods/src/lib.rs b/template/zk_test_template/test_methods/src/lib.rs deleted file mode 100644 index 1bdb308..0000000 --- a/template/zk_test_template/test_methods/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -include!(concat!(env!("OUT_DIR"), "/methods.rs"));