Skip to content

Commit

Permalink
Add benchmark templates and sample benches for IPA (arkworks-rs#133)
Browse files Browse the repository at this point in the history
* Add benchmark templates and sample benches for IPA

Co-authored-by: Antonio Mejías Gil <[email protected]>

* adapt max poly degree to 20

* Move all PC Schemes to one module; bench-templates as a separate module

* inline one of the type aliases

* remove commented out comment

* Add benchmark instructions to the README

* make bench-templates non publishable

* fix yaml file: remove newline

* rename the inner dir to `poly-commit`

* rename usages of `pcs` to `poly-commit`

---------

Co-authored-by: Antonio Mejías Gil <[email protected]>
  • Loading branch information
mmagician and Antonio95 committed Nov 15, 2023
1 parent 6378829 commit 55fd8e5
Show file tree
Hide file tree
Showing 42 changed files with 445 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ jobs:
with:
use-cross: true
command: build
args: --no-default-features --target aarch64-unknown-none
args: --workspace --no-default-features --target aarch64-unknown-none --exclude ark-pcs-bench-templates

- name: Check
uses: actions-rs/cargo@v1
with:
use-cross: true
command: check
args: --examples --no-default-features --target aarch64-unknown-none
args: --workspace --examples --no-default-features --target aarch64-unknown-none --exclude ark-pcs-bench-templates
55 changes: 8 additions & 47 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,48 +1,20 @@
[package]
name = "ark-poly-commit"
[workspace]
members = ["poly-commit", "bench-templates"]
resolver = "2"


[workspace.package]
version = "0.4.0"
authors = ["arkworks contributors"]
description = "A library for constructing polynomial commitment schemes for use in zkSNARKs"
repository = "https://github.com/arkworks-rs/poly-commit"
documentation = "https://docs.rs/ark-poly-commit/"
keywords = ["cryptography", "commitments", "elliptic-curves", "pairing"]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
categories = ["cryptography"]
license = "MIT/Apache-2.0"
edition = "2018"

[dependencies]
ark-serialize = { version = "^0.4.0", default-features = false, features = [ "derive" ] }
ark-ff = { version = "^0.4.0", default-features = false }
ark-ec = { version = "^0.4.0", default-features = false }
ark-poly = {version = "^0.4.0", default-features = false }
ark-crypto-primitives = { version = "^0.4.0", default-features = false, features = ["sponge","merkle_tree" ] }
ark-std = { version = "^0.4.0", default-features = false }

ark-relations = { version = "^0.4.0", default-features = false, optional = true }
ark-r1cs-std = { version = "^0.4.0", default-features = false, optional = true }
hashbrown = { version = "0.14", default-features = false, optional = true }

digest = "0.10"
derivative = { version = "2", features = [ "use_core" ] }
rayon = { version = "1", optional = true }
merlin = { version = "3.0.0", default-features = false }
halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib", branch = "release-0.4.0-rc" }

poseidon-native = { git = "https://github.com/privacy-scaling-explorations/poseidon", package = "poseidon" }
criterion = { version = "0.5", optional = true }

[dev-dependencies]
ark-ed-on-bls12-381 = { version = "^0.4.0", default-features = false }
ark-bls12-381 = { version = "^0.4.0", default-features = false, features = [ "curve" ] }
ark-bls12-377 = { version = "^0.4.0", default-features = false, features = [ "curve" ] }
ark-bn254 = { version = "^0.4.0", default-features = false, features = [ "curve" ] }
blake2 = { version = "0.10", default-features = false }
rand_chacha = { version = "0.3.0", default-features = false }

[[bench]]
name = "pcs"
path = "benches/benches.rs"
harness = false

[profile.release]
opt-level = 3
Expand All @@ -56,17 +28,6 @@ debug-assertions = true
incremental = true
debug = true

[features]
default = [ "std", "parallel" ]
std = [ "ark-ff/std", "ark-ec/std", "ark-poly/std", "ark-std/std", "ark-relations/std", "ark-serialize/std", "ark-crypto-primitives/std"]
r1cs = [ "ark-relations", "ark-r1cs-std", "hashbrown", "ark-crypto-primitives/r1cs"]
print-trace = [ "ark-std/print-trace" ]
parallel = [ "std", "ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", "ark-std/parallel", "rayon" ]
benches = [ "std", "criterion" ]

[target.'cfg(target_arch = "aarch64")'.dependencies]
num-traits = { version = "0.2", default-features = false, features = ["libm"] }

[patch.crates-io]
ark-ff = { git = "https://github.com/HungryCatsStudio/algebra", branch = "ml-is-poly" }
ark-ec = { git = "https://github.com/HungryCatsStudio/algebra", branch = "ml-is-poly" }
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ This library comes with some unit and integration tests. Run these tests with:
cargo test
```

A benchmarking module is also provided for the `commit`, `open` and `verify` methods, as well as for computing the commitment and proof size. You can add a new benchmark for your scheme following the examples in the `pcs/benches` directory, or run the existing benchmarks with:
```bash
cargo bench
```

Lastly, this library is instrumented with profiling infrastructure that prints detailed traces of execution time. To enable this, compile with `cargo build --features print-trace`.

## Usage
Expand Down
24 changes: 24 additions & 0 deletions bench-templates/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "ark-pcs-bench-templates"
version.workspace = true
authors.workspace = true
repository.workspace = true
categories.workspace = true
include.workspace = true
license.workspace = true
edition.workspace = true
publish = false

[dependencies]
ark-poly-commit = { path = "../poly-commit", default-features = false }
ark-serialize = { version = "^0.4.0", default-features = false, features = [ "derive" ] }
ark-ff = { version = "^0.4.0", default-features = false }
ark-ec = { version = "^0.4.0", default-features = false }
ark-poly = {version = "^0.4.0", default-features = false }
ark-crypto-primitives = {version = "^0.4.0", default-features = false, features = ["sponge", "merkle_tree"] }
ark-std = { version = "^0.4.0", default-features = false }

rand_chacha = { version = "0.3.0", default-features = false }
criterion = { version = "0.5", default-features = false }

paste = "1.0"
Loading

0 comments on commit 55fd8e5

Please sign in to comment.