diff --git a/Cargo.lock b/Cargo.lock index e8b7d401..3d314770 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4880,35 +4880,6 @@ dependencies = [ "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "zero-chain-cli 0.1.0", - "zero-chain-crypto 0.1.0", - "zero-chain-pairing 0.14.2", - "zero-chain-primitives 0.1.0", - "zero-chain-proofs 0.1.0", - "zero-chain-runtime 1.0.0", - "zerochain-wasm-utils 0.1.0", -] - -[[package]] -name = "zero-chain-cli" -version = "0.1.0" -dependencies = [ - "bellman 0.1.0 (git+https://github.com/LayerXcom/librustzcash?branch=zero-chain)", - "bellman-verifier 0.1.0", - "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jubjub 0.1.0", - "keys 0.1.0", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.14.2 (git+https://github.com/LayerXcom/librustzcash?branch=zero-chain)", - "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "polkadot-rs 0.1.0 (git+https://github.com/LayerXcom/polkadot.rs)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sapling-crypto 0.0.1 (git+https://github.com/LayerXcom/librustzcash?branch=zero-chain)", - "sr-primitives 1.0.0 (git+https://github.com/osuketh/substrate?branch=patch-zerochain)", - "substrate-primitives 1.0.0 (git+https://github.com/osuketh/substrate?branch=patch-zerochain)", "zero-chain-crypto 0.1.0", "zero-chain-pairing 0.14.2", "zero-chain-primitives 0.1.0", @@ -5011,6 +4982,34 @@ dependencies = [ "zero-chain-primitives 0.1.0", ] +[[package]] +name = "zeroc" +version = "0.1.0" +dependencies = [ + "bellman 0.1.0 (git+https://github.com/LayerXcom/librustzcash?branch=zero-chain)", + "bellman-verifier 0.1.0", + "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "jubjub 0.1.0", + "keys 0.1.0", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pairing 0.14.2 (git+https://github.com/LayerXcom/librustzcash?branch=zero-chain)", + "parity-codec 3.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "polkadot-rs 0.1.0 (git+https://github.com/LayerXcom/polkadot.rs)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sapling-crypto 0.0.1 (git+https://github.com/LayerXcom/librustzcash?branch=zero-chain)", + "sr-primitives 1.0.0 (git+https://github.com/osuketh/substrate?branch=patch-zerochain)", + "substrate-primitives 1.0.0 (git+https://github.com/osuketh/substrate?branch=patch-zerochain)", + "zero-chain-crypto 0.1.0", + "zero-chain-pairing 0.14.2", + "zero-chain-primitives 0.1.0", + "zero-chain-proofs 0.1.0", + "zero-chain-runtime 1.0.0", + "zerochain-wasm-utils 0.1.0", +] + [[package]] name = "zerochain-wasm-utils" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 1b828386..dffcf7d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,7 @@ parking_lot = '0.7.1' slog = '^2' tokio = '0.1' trie-root = '0.11.0' - bellman-verifier = { path = "core/bellman-verifier"} -demo = { package = "zero-chain-cli", path = "demo/cli" } zcrypto = { package = "zero-chain-crypto", path = "core/crypto" } zpairing = { package = "zero-chain-pairing", path = "core/pairing" } zprimitives = { package = "zero-chain-primitives", path = "core/primitives" } @@ -107,15 +105,11 @@ version = '1.0.0' name = 'zero-chain' path = 'src/main.rs' -[[bin]] -name = 'zero-chain-cli' -path = 'demo/cli/src/main.rs' - [workspace] members = [ "core/bellman-verifier", "core/crypto", - "demo/cli", + "zeroc", "core/jubjub", "core/pairing", "core/primitives", diff --git a/README.md b/README.md index 7e5a67f0..4061f0a9 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,33 @@ You can send the transaction from firefox browser. +## zeroc: Zerochain command line tool + +- Setup +``` +cargo install --path zeroc +``` + +- Setup for zk-SNARKs +``` +zeroc setup +``` + +- Generate key pairs +``` +zeroc init +``` + +- Send extrinsic to substrate node +``` +zeroc send-tx +``` + +- Get balance +``` +zeroc get-balance +``` + ### Documentations - [Announcing Zerochain: Applying zk-SNARKs to Substrate](https://medium.com/layerx/announcing-zerochain-5b08e158355d) diff --git a/runtime/src/conf_transfer.rs b/runtime/src/conf_transfer.rs index f935707e..ea5f53fe 100644 --- a/runtime/src/conf_transfer.rs +++ b/runtime/src/conf_transfer.rs @@ -1,9 +1,7 @@ //! A simple module for dealing with confidential transfer of fungible assets. use support::{decl_module, decl_storage, decl_event, StorageMap, dispatch::Result, ensure}; use rstd::prelude::*; -use bellman_verifier::{ - verify_proof, -}; +use bellman_verifier::verify_proof; use pairing::{ bls12_381::{ Bls12, @@ -11,12 +9,7 @@ use pairing::{ }, Field, }; -use jubjub::{ - redjubjub::{ - PublicKey, - }, - }; - +use jubjub::redjubjub::PublicKey; use zprimitives::{ PkdAddress, Ciphertext, diff --git a/demo/cli/Cargo.toml b/zeroc/Cargo.toml similarity index 60% rename from demo/cli/Cargo.toml rename to zeroc/Cargo.toml index 0421523c..7d4bee07 100644 --- a/demo/cli/Cargo.toml +++ b/zeroc/Cargo.toml @@ -1,31 +1,31 @@ [package] -name = "zero-chain-cli" +name = "zeroc" version = "0.1.0" authors = ["osuke "] edition = "2018" [dependencies] rand = "0.4" -proofs = { package = "zero-chain-proofs", path = "../../core/proofs" } +proofs = { package = "zero-chain-proofs", path = "../core/proofs" } clap = "~2.32" primitives = { package = "substrate-primitives", git = "https://github.com/osuketh/substrate", branch = "patch-zerochain" } runtime-primitives = { package = "sr-primitives", git = "https://github.com/osuketh/substrate", branch = "patch-zerochain" } -zpairing = { package = "zero-chain-pairing", path = "../../core/pairing" } +zpairing = { package = "zero-chain-pairing", path = "../core/pairing" } pairing = { git = "https://github.com/LayerXcom/librustzcash", branch = "zero-chain" } bellman = { git = "https://github.com/LayerXcom/librustzcash", branch = "zero-chain" } scrypto = { package = "sapling-crypto", git = "https://github.com/LayerXcom/librustzcash", branch = "zero-chain" } -bellman-verifier = { path = "../../core/bellman-verifier"} -zcrypto = { package = "zero-chain-crypto", path = "../../core/crypto"} -zprimitives = { package = "zero-chain-primitives", path = "../../core/primitives" } -zjubjub = { package = "jubjub", path = "../../core/jubjub"} +bellman-verifier = { path = "../core/bellman-verifier"} +zcrypto = { package = "zero-chain-crypto", path = "../core/crypto"} +zprimitives = { package = "zero-chain-primitives", path = "../core/primitives" } +zjubjub = { package = "jubjub", path = "../core/jubjub"} lazy_static = "1.3.0" byteorder = "1" -keys = { path = "../../core/keys" } -wasm-utils = {package = "zerochain-wasm-utils", path = "../wasm-utils"} +keys = { path = "../core/keys" } +wasm-utils = {package = "zerochain-wasm-utils", path = "../demo/wasm-utils"} hex = "0.3.2" polkadot-rs = { git = "https://github.com/LayerXcom/polkadot.rs" } parity-codec = "3.2" -zero-chain-runtime = { path = "../../runtime" } +zero-chain-runtime = { path = "../runtime" } [dependencies.blake2-rfc] git = "https://github.com/gtank/blake2-rfc" diff --git a/demo/cli/proving.params b/zeroc/proving.params similarity index 100% rename from demo/cli/proving.params rename to zeroc/proving.params diff --git a/demo/cli/src/main.rs b/zeroc/src/main.rs similarity index 99% rename from demo/cli/src/main.rs rename to zeroc/src/main.rs index a7404a6c..f25868f9 100644 --- a/demo/cli/src/main.rs +++ b/zeroc/src/main.rs @@ -53,8 +53,8 @@ fn main() { } fn cli() -> Result<(), String> { - const VERIFICATION_KEY_PATH: &str = "demo/cli/verification.params"; - const PROVING_KEY_PATH: &str = "demo/cli/proving.params"; + const VERIFICATION_KEY_PATH: &str = "cli/verification.params"; + const PROVING_KEY_PATH: &str = "cli/proving.params"; const DEFAULT_AMOUNT: &str = "10"; const DEFAULT_BALANCE: &str = "100"; const DEFAULT_FEE: &str = "1"; @@ -65,7 +65,7 @@ fn cli() -> Result<(), String> { const DEFAULT_ENCRYPTED_BALANCE: &str = "6f4962da776a391c3b03f3e14e8156d2545f39a3ebbed675ea28859252cb006fac776c796563fcd44cc49cfaea8bb796952c266e47779d94574c10ad01754b11"; const URL: &str = ""; - let matches = App::new("zero-chain-cli") + let matches = App::new("zeroc") .setting(AppSettings::SubcommandRequiredElseHelp) .version("0.1.0") .author("Osuke Sudo") diff --git a/demo/cli/src/setup.rs b/zeroc/src/setup.rs similarity index 100% rename from demo/cli/src/setup.rs rename to zeroc/src/setup.rs diff --git a/demo/cli/src/utils.rs b/zeroc/src/utils.rs similarity index 100% rename from demo/cli/src/utils.rs rename to zeroc/src/utils.rs diff --git a/demo/cli/verification.params b/zeroc/verification.params similarity index 100% rename from demo/cli/verification.params rename to zeroc/verification.params