From ac7eeb75cdac0cfa5838d7729dda0e1ec9b2f9f6 Mon Sep 17 00:00:00 2001 From: Manish Kumar Date: Thu, 1 Aug 2024 19:13:51 +0530 Subject: [PATCH] readme and cfg files added --- hash/plonky2/bench/README.md | 11 +++++++++++ hash/plonky2/bench/bench.cfg | 11 +++++++++++ hash/plonky2/bench/bench_tree.cfg | 10 ++++++++++ .../bench/src/bench/keccak256/keccak_polygon.rs | 2 ++ 4 files changed, 34 insertions(+) create mode 100644 hash/plonky2/bench/README.md create mode 100644 hash/plonky2/bench/bench.cfg create mode 100644 hash/plonky2/bench/bench_tree.cfg diff --git a/hash/plonky2/bench/README.md b/hash/plonky2/bench/README.md new file mode 100644 index 0000000..cded41d --- /dev/null +++ b/hash/plonky2/bench/README.md @@ -0,0 +1,11 @@ +Plonky2 Hash Circuit Benchmarking +-------------------------------- +- The `plonky2/bench` contains the following hash circuit benchamrking code: sha256, keccak256 and poseidon. +- The code for sha256 is taken from [plonky2-sha256](https://github.com/polymerdao/plonky2-sha256). +- The keccak hash has two different implementation taken from [plonky2-keccak256](https://github.com/qope/plonky2-keccak256) and Polygon-zero [zk_evm](https://github.com/0xPolygonZero/zk_evm/tree/develop). +- The `build.sh` script builds the whole code. You need rust nightly version to build the code. The script overrides the default rust version to nightly. +- `run.sh` and `run_tree.sh` runs the benchmark. (`run.sh` for sha256, keccak, and keccak-polygon and `run_tree.sh` for poseidon) +- Benchmarks can be parameterized using environment variables. By convention, we start the names of these environment variables with the `ZKBENCH_` prefix. +- By default the `run.sh` will run the sha256 benchmark over 256 Bytes of data. other hashes can be run by settig the environment variables accordingly. +- By default the `run_tree.sh` will run the poseidon benchmark over tree depth 4. +- Additional files `bench.cfg` and `bench_tree.cfg` specifies the configurations and parameters. \ No newline at end of file diff --git a/hash/plonky2/bench/bench.cfg b/hash/plonky2/bench/bench.cfg new file mode 100644 index 0000000..1a0d6ea --- /dev/null +++ b/hash/plonky2/bench/bench.cfg @@ -0,0 +1,11 @@ +name: "Plonky2 hashes circuit benchmarking" +author: +timeout: 200 +params: + [ HASH_TYPE: [ "sha256", "keccak", "keccak-polygon"] + , INPUT_SIZE_BYTES: [ 256, 512, 1024, 2048 ] + ] +tags: plonky2, $HASH_TYPE + +comments: + The benchmarks includes for sha256, keccak and poseidon hash. \ No newline at end of file diff --git a/hash/plonky2/bench/bench_tree.cfg b/hash/plonky2/bench/bench_tree.cfg new file mode 100644 index 0000000..b34d338 --- /dev/null +++ b/hash/plonky2/bench/bench_tree.cfg @@ -0,0 +1,10 @@ +name: "Plonky2 hashes circuit benchmarking" +author: +timeout: 100 +params: + [ HASH_TYPE_TREE: [ "poseidon"] + , TREE_DEPTH: [ 2, 4, 8, 16 ] + ] +tags: plonky2, $HASH_TYPE_TREE +comments: + The benchmarks includes for poseidon hash. \ No newline at end of file diff --git a/hash/plonky2/bench/src/bench/keccak256/keccak_polygon.rs b/hash/plonky2/bench/src/bench/keccak256/keccak_polygon.rs index 3d3282c..c136491 100644 --- a/hash/plonky2/bench/src/bench/keccak256/keccak_polygon.rs +++ b/hash/plonky2/bench/src/bench/keccak256/keccak_polygon.rs @@ -1,3 +1,5 @@ +// original source: https://github.com/0xPolygonZero/zk_evm/tree/develop + use evm_arithmetization::{ keccak::keccak_stark::KeccakStark, prover::prove_single_table,