From c5186dce0ea7f9acde414b1db5ce995e19adcdfb Mon Sep 17 00:00:00 2001 From: ashWhiteHat Date: Sun, 5 Nov 2023 14:50:19 +0900 Subject: [PATCH] refactor: move benches --- .github/workflows/bench.yml | 20 ------- .github/workflows/pr.yml | 16 ----- Cargo.lock | 23 +++----- Cargo.toml | 58 ------------------- README.md | 35 +++-------- bls12_381/Cargo.toml | 10 ++++ .../benches}/bls12_381_curve.rs | 0 .../benches}/bls12_381_field.rs | 0 jubjub/Cargo.toml | 10 ++++ {benches => jubjub/benches}/jubjub_curve.rs | 0 {benches => jubjub/benches}/jubjub_field.rs | 0 pairing/Cargo.toml | 6 ++ {benches => pairing/benches}/pairing.rs | 0 poly/Cargo.toml | 7 +++ {benches => poly/benches}/msm.rs | 0 src/lib.rs | 1 - 16 files changed, 48 insertions(+), 138 deletions(-) delete mode 100644 .github/workflows/bench.yml rename {benches => bls12_381/benches}/bls12_381_curve.rs (100%) rename {benches => bls12_381/benches}/bls12_381_field.rs (100%) rename {benches => jubjub/benches}/jubjub_curve.rs (100%) rename {benches => jubjub/benches}/jubjub_field.rs (100%) rename {benches => pairing/benches}/pairing.rs (100%) rename {benches => poly/benches}/msm.rs (100%) delete mode 100644 src/lib.rs diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml deleted file mode 100644 index 37c903f7..00000000 --- a/.github/workflows/bench.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Performance Check -on: - push: - branches: [ master ] - -jobs: - bench: - name: Benchmark - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Update submodules - id: update - run: git submodule update -i - - uses: actions-rs/cargo@v1 - with: - command: bench diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5cdd84d0..dec8f542 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,22 +23,6 @@ jobs: command: fmt args: --all -- --check - bench: - if: contains(github.event.pull_request.labels.*.name, 'performance') - name: Benchmark - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Update submodules - id: update - run: git submodule update -i - - uses: actions-rs/cargo@v1 - with: - command: bench - clippy: if: github.event.pull_request.draft == false name: Clippy Check diff --git a/Cargo.lock b/Cargo.lock index b7291ebf..74985c85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,9 +71,11 @@ checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" name = "bls-12-381" version = "0.0.23" dependencies = [ + "criterion", "parity-scale-codec", "paste", "proptest", + "rand", "rand_core", "serde", "zkstd", @@ -256,8 +258,10 @@ name = "ec-pairing" version = "0.0.14" dependencies = [ "bls-12-381", + "criterion", "jub-jub", "parity-scale-codec", + "rand", "rand_core", "zkstd", ] @@ -411,9 +415,11 @@ name = "jub-jub" version = "0.0.20" dependencies = [ "bls-12-381", + "criterion", "parity-scale-codec", "paste", "proptest", + "rand", "rand_core", "serde", "zkstd", @@ -428,21 +434,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "kogarashi-network" -version = "0.1.0" -dependencies = [ - "bls-12-381", - "criterion", - "ec-pairing", - "jub-jub", - "poly-commit", - "rand", - "she-elgamal", - "zksnarks", - "zkstd", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -601,8 +592,10 @@ name = "poly-commit" version = "0.0.13" dependencies = [ "bls-12-381", + "criterion", "ec-pairing", "parity-scale-codec", + "rand", "rand_core", "rayon", "zksnarks", diff --git a/Cargo.toml b/Cargo.toml index cbd8aa12..f2ae1f97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,30 +1,3 @@ -[package] -authors = [ - 'ashWhiteHat', - 'KiriosK' -] -name = "kogarashi-network" -description = 'Kogarashi Network hybrid smart contract blockchain' -version = "0.1.0" -edition = "2021" -license = "Apache-2.0" -homepage = 'https://github.com/KogarashiNetwork/Kogarashi/' -repository = 'https://github.com/KogarashiNetwork/Kogarashi/' -readme = 'README.md' - -[dependencies] -bls-12-381 = { path = "./bls12_381", default-features = false } -zkstd = { path = "./zkstd", default-features = false } -she-elgamal = { path = "./elgamal", default-features = false } -jub-jub = { path = "./jubjub", default-features = false } -poly-commit = { path = "./poly", default-features = false } -ec-pairing = { path = "./pairing", default-features = false } -zksnarks = { path = "./zksnarks", default-features = false } - -[dev-dependencies] -criterion = "0.4.0" -rand = { version = "0.8" } - [workspace] members = [ "bls12_381", @@ -50,34 +23,3 @@ overflow-checks = false lto = true incremental = false codegen-units = 1 - -[features] -default = ["std"] -std = [ - 'poly-commit/std', -] - -[[bench]] -name = "bls12_381_curve" -harness = false - -[[bench]] -name = "bls12_381_field" -harness = false - -[[bench]] -name = "jubjub_curve" -harness = false - -[[bench]] -name = "jubjub_field" -harness = false - -[[bench]] -name = "msm" -harness = false -required-features = ["std"] - -[[bench]] -name = "pairing" -harness = false diff --git a/README.md b/README.md index fd181ce4..a8165a9e 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,7 @@ We supports following functionalities. 3. Trustless Single Node Off-Chain Oracle 4. IoT TEE Device Remote Attestation -## Library - -All users balances are encrypted by the `homomorphic encryption` by default and all transactions executions are proved by the `non-interactive zero knowledge proof`. The blockchain runtime is optimized its structure and execution environment for improving encryption scheme. This blockchain supports the privacy and simplicity of use at the same time. Users balances are encrypted as default and transactions are verified by zero knowledge proof on chain. - -### [Crypto Primitives](https://github.com/KogarashiNetwork/Kogarashi/tree/master/primitive) +## Crypto Primitives | Name | Crates.io | Documentation | Description | |-------------|-----------|-----------|-----------| @@ -28,20 +24,10 @@ All users balances are encrypted by the `homomorphic encryption` by default and | [`ec-pairing`] | [![crates.io badge](https://img.shields.io/crates/v/ec-pairing.svg)](https://crates.io/crates/ec-pairing) | [![Documentation](https://docs.rs/ec-pairing/badge.svg)](https://docs.rs/ec-pairing) |`Tate Pairing` implementation. This includes the Miller loop algorithm and pairing construction with pairing-friendly curve. | [`she-elgamal`] | [![crates.io](https://img.shields.io/crates/v/she-elgamal.svg)](https://crates.io/crates/she-elgamal) | [![Documentation](https://docs.rs/she-elgamal/badge.svg)](https://docs.rs/she-elgamal) | `ElGamal Encryption` implementation. This includes a public key encryption interface that supports **additive homomorphism**. | [`poly-commit`] | [![crates.io](https://img.shields.io/crates/v/poly-commit.svg)](https://crates.io/crates/poly-commit) | [![Documentation](https://docs.rs/poly-commit/badge.svg)](https://docs.rs/poly-commit) | `Kate Polynomial Commitment` implementation. This includes polynomial commitment and operations used for **zero knowledge proof plonk**. -| [`red-jubjub`] | [![crates.io](https://img.shields.io/crates/v/red-jubjub.svg)](https://crates.io/crates/red-jubjub) | [![Documentation](https://docs.rs/red-jubjub/badge.svg)](https://docs.rs/red-jubjub) | `Redjubjub` implementation. This includes **RedDSA** interfact and public key encryption algorithm. - -### [Pallet Functionalities](https://github.com/KogarashiNetwork/Kogarashi/tree/master/pallets) - -|Name|Documentation|Description| -|----|-------------|-----------| -| [`pallet-plonk`] | [Plonk Tutorial](https://kogarashinetwork.github.io/Kogarashi/plonk_pallet/) |$gen(d) \rightarrow srs,\ com(f, srs) \rightarrow commitment,\ V_{PC} \rightarrow acc\ or\ rej$| -| [`pallet-encrypted-balance`] |-|$get(address) \rightarrow (g^{r + r'}, g^{a + c} * b^{r + r'})$| -| [`confidential_transfer`] | [Confidential Transfer Tutorial](https://kogarashinetwork.github.io/Kogarashi/confidential_transfer/) |$C = g^{b^\star}y^r \land \hat C = g^{b^\star} \hat y^r \land D = g^r \land C_L/C = g^{b'}(C_R/D)^{sk} \land y = g^{sk} \land b^\star \in [0, MAX] \land b' \in [0,MAX] $| ## Test ```shell -$ git submodule update --init --recursive $ cargo test --all --release ``` @@ -61,16 +47,9 @@ You can check more detail [here](./LICENSE). [//]: # (crypto primitives) -[`zkstd`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/primitive/zkstd -[`jub-jub`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/primitive/jubjub -[`bls-12-381`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/primitive/bls12_381 -[`ec-pairing`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/primitive/pairing -[`she-elgamal`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/primitive/elgamal -[`poly-commit`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/primitive/poly -[`red-jubjub`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/primitive/redjubjub - -[//]: # (pallet functionalities) - -[`pallet-plonk`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/pallets/plonk -[`pallet-encrypted-balance`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/pallets/encrypted_balance -[`confidential_transfer`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/pallets/confidential_transfer +[`zkstd`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/zkstd +[`jub-jub`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/jubjub +[`bls-12-381`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/bls12_381 +[`ec-pairing`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/pairing +[`she-elgamal`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/elgamal +[`poly-commit`]: https://github.com/KogarashiNetwork/Kogarashi/tree/master/poly diff --git a/bls12_381/Cargo.toml b/bls12_381/Cargo.toml index 143f14a5..e6f23f47 100644 --- a/bls12_381/Cargo.toml +++ b/bls12_381/Cargo.toml @@ -25,5 +25,15 @@ parity-scale-codec = { version = "2.0.0", default-features = false, features = [ zkstd = { path = "../zkstd", default-features = false } [dev-dependencies] +criterion = "0.4.0" +rand = { version = "0.8" } paste = "1.0.11" proptest = "1" + +[[bench]] +name = "bls12_381_curve" +harness = false + +[[bench]] +name = "bls12_381_field" +harness = false diff --git a/benches/bls12_381_curve.rs b/bls12_381/benches/bls12_381_curve.rs similarity index 100% rename from benches/bls12_381_curve.rs rename to bls12_381/benches/bls12_381_curve.rs diff --git a/benches/bls12_381_field.rs b/bls12_381/benches/bls12_381_field.rs similarity index 100% rename from benches/bls12_381_field.rs rename to bls12_381/benches/bls12_381_field.rs diff --git a/jubjub/Cargo.toml b/jubjub/Cargo.toml index 0f28520c..dc9e22e2 100644 --- a/jubjub/Cargo.toml +++ b/jubjub/Cargo.toml @@ -26,5 +26,15 @@ parity-scale-codec = { version = "2.0.0", default-features = false, features = [ rand_core = { version="0.6.4", default-features = false } [dev-dependencies] +criterion = "0.4.0" +rand = { version = "0.8" } proptest = "1" paste = "1.0.11" + +[[bench]] +name = "jubjub_curve" +harness = false + +[[bench]] +name = "jubjub_field" +harness = false diff --git a/benches/jubjub_curve.rs b/jubjub/benches/jubjub_curve.rs similarity index 100% rename from benches/jubjub_curve.rs rename to jubjub/benches/jubjub_curve.rs diff --git a/benches/jubjub_field.rs b/jubjub/benches/jubjub_field.rs similarity index 100% rename from benches/jubjub_field.rs rename to jubjub/benches/jubjub_field.rs diff --git a/pairing/Cargo.toml b/pairing/Cargo.toml index 66ac25dd..08adad1a 100644 --- a/pairing/Cargo.toml +++ b/pairing/Cargo.toml @@ -25,4 +25,10 @@ jub-jub = { path = "../jubjub", default-features = false } parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] } [dev-dependencies] +criterion = "0.4.0" +rand = { version = "0.8" } rand_core = { version="0.6.4", features = ["getrandom"] } + +[[bench]] +name = "pairing" +harness = false diff --git a/benches/pairing.rs b/pairing/benches/pairing.rs similarity index 100% rename from benches/pairing.rs rename to pairing/benches/pairing.rs diff --git a/poly/Cargo.toml b/poly/Cargo.toml index 66bd13ec..b6e74a89 100644 --- a/poly/Cargo.toml +++ b/poly/Cargo.toml @@ -27,8 +27,15 @@ rand_core = { version = "0.6", default-features = false } rayon = { version = "1.5.1", optional = true } [dev-dependencies] +criterion = "0.4.0" +rand = { version = "0.8" } zksnarks = { path = "../zksnarks" } [features] default = ["std"] std = ["rand_core/getrandom", "rayon"] + +[[bench]] +name = "msm" +harness = false +required-features = ["std"] diff --git a/benches/msm.rs b/poly/benches/msm.rs similarity index 100% rename from benches/msm.rs rename to poly/benches/msm.rs diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 8731421b..00000000 --- a/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)]