-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add arkzkey, adjust build.rs and update circuit code
- Loading branch information
Showing
7 changed files
with
486 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "ark-zkey" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
# XXX: Shouldn't be necessary, but this way we stay consistent with wasmer version and fix | ||
# error[E0432]: unresolved import `wasmer` error | ||
# (likely due to other packages) | ||
[patch.crates-io] | ||
# NOTE: Forked wasmer to work around memory limits | ||
# See https://github.com/wasmerio/wasmer/commit/09c7070 | ||
wasmer = { git = "https://github.com/oskarth/wasmer.git", rev = "09c7070" } | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
[dependencies] | ||
color-eyre = "0.6" | ||
memmap2 = "0.9" | ||
flame = "0.2" | ||
flamer = "0.5" | ||
|
||
ark-serialize = { version = "=0.4.1", features = ["derive"] } | ||
ark-bn254 = { version = "=0.4.0" } | ||
ark-groth16 = { version = "=0.4.0" } | ||
ark-circom = { git = "https://github.com/arkworks-rs/circom-compat.git" } | ||
ark-relations = { version = "=0.4.0" } | ||
ark-ff = { version = "=0.4.1" } | ||
ark-ec = { version = "=0.4.1" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# ark-zkey | ||
|
||
Library to read `zkey` faster by serializing to `arkworks` friendly format. | ||
|
||
See https://github.com/oskarth/mopro/issues/25 for context. | ||
|
||
## To generate arkzkey | ||
|
||
Hacky, but the way we generate `arkzkey` now is by running the corresponding test. | ||
|
||
Note that we also neeed to change the const `ZKEY_BYTES` above. | ||
|
||
E.g.: | ||
|
||
``` | ||
cargo test multiplier2 --release -- --nocapture | ||
cargo test keccak256 --release -- --nocapture | ||
cargo test rsa --release -- --nocapture | ||
``` | ||
|
||
Will take corresponding `zkey` and put `arkzkey`` in same folder. | ||
|
||
## Multiplier | ||
|
||
NOTE: Need to change const ZKEY here | ||
|
||
`cargo test multiplier2 --release -- --nocapture` | ||
|
||
``` | ||
running 1 test | ||
[build] Processing zkey data... | ||
[build] Time to process zkey data: 3.513041ms | ||
[build] Serializing proving key and constraint matrices | ||
[build] Time to serialize proving key and constraint matrices: 42ns | ||
[build] Writing arkzkey to: ../mopro-core/examples/circom/multiplier2/target/multiplier2_final.arkzkey | ||
[build] Time to write arkzkey: 1.884875ms | ||
Reading arkzkey from: ../mopro-core/examples/circom/multiplier2/target/multiplier2_final.arkzkey | ||
Time to open arkzkey file: 18.084µs | ||
Time to mmap arkzkey: 8.542µs | ||
Time to deserialize proving key: 305.75µs | ||
Time to deserialize matrices: 5µs | ||
Time to read arkzkey: 348.083µs | ||
test tests::test_multiplier2_serialization_deserialization ... ok | ||
``` | ||
|
||
Naive test: `cargo test naive --release -- --nocapture` (with right zkey constant). | ||
|
||
**Result: `350µs` vs naive `3.3ms`** | ||
|
||
## Keccak | ||
|
||
NOTE: Need to change const ZKEY here | ||
|
||
`cargo test keccak256 --release -- --nocapture` | ||
|
||
``` | ||
[build] Processing zkey data... | ||
test tests::test_keccak256_serialization_deserialization has been running for over 60 seconds | ||
[build]Time to process zkey data: 158.753181958s | ||
[build] Serializing proving key and constraint matrices | ||
[build] Time to serialize proving key and constraint matrices: 42ns | ||
[build] Writing arkzkey to: ../mopro-core/examples/circom/keccak256/target/keccak256_256_test_final.arkzkey | ||
[build] Time to write arkzkey: 16.204274125s | ||
Reading arkzkey from: ../mopro-core/examples/circom/keccak256/target/keccak256_256_test_final.arkzkey | ||
Time to open arkzkey file: 51.75µs | ||
Time to mmap arkzkey: 17.25µs | ||
Time to deserialize proving key: 18.323550083s | ||
Time to deserialize matrices: 46.935792ms | ||
Time to read arkzkey: 18.3730695s | ||
test tests::test_keccak256_serialization_deserialization ... ok | ||
``` | ||
|
||
Vs naive: | ||
|
||
`[build] Time to process zkey data: 158.753181958s` | ||
|
||
|
||
**Result: 18s vs 158s** |
Oops, something went wrong.
shouldn't this rather use the
_from_path
function?