mirror of
https://github.com/logos-storage/zk-benchmarks.git
synced 2026-01-03 06:13:11 +00:00
risc0 benchmarking removed from this branch
This commit is contained in:
parent
df55390be1
commit
c0429fa765
@ -1,7 +0,0 @@
|
||||
Benchmarking inside risc'0 zkvm
|
||||
--------------------------------
|
||||
|
||||
- `external` folder contains risc0 as a git submodule.
|
||||
- `bench` folder contains the benchmarking for different hash functions. Go to the `bench/README.md` for more details.
|
||||
- `inner_proof` folder contains methods for generating the Receipt for sha256 which is being used as an inner proof in `composition`
|
||||
- `composition` folder contains methods of proof composition which uses `inner_proof`.
|
||||
5
hash/risc0/bench/.vscode/settings.json
vendored
5
hash/risc0/bench/.vscode/settings.json
vendored
@ -1,5 +0,0 @@
|
||||
{
|
||||
"rust-analyzer.linkedProjects": [
|
||||
"./methods/guest/Cargo.toml"
|
||||
]
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
[package]
|
||||
name = "benchmark"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
risc0-zkvm = { path = "../external/risc0/risc0/zkvm" }
|
||||
serde = "1.0"
|
||||
rand = "0.8.3"
|
||||
sha2 ={ git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.6-risczero.0" }
|
||||
benchmark_methods = { path = "methods" }
|
||||
zkhash = { git = "https://github.com/HorizenLabs/poseidon2.git"}
|
||||
ark-ff = "0.4.2"
|
||||
hex = "0.4.3"
|
||||
ark-serialize = "0.4"
|
||||
risc0-core = { path = "../external/risc0/risc0/core" }
|
||||
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -1,12 +0,0 @@
|
||||
Benchmarking different hashes inside risc'0 zkvm
|
||||
-----------------------------------------------
|
||||
|
||||
The benchmark is defined by the following shell scripts:
|
||||
|
||||
- `build.sh` - build the code.
|
||||
|
||||
- `run.sh` and `run2.sh` - run the benchmark itself (`run.sh` for sha256, keccak, blake2b, blake3 and `run2.sh` for poseidon2 over bn128 and babybear)
|
||||
|
||||
Benchmarks can be parameterized using environment variables. By convention, we start the names of these environment variables with the `ZKBENCH_` prefix.
|
||||
|
||||
Additional files `bench.cfg` and `bench_tree.cfg` specifies the configurations and parameters.
|
||||
@ -1,11 +0,0 @@
|
||||
name: "Hashes benchmarking using risc0 prover"
|
||||
author:
|
||||
timeout: 200
|
||||
params:
|
||||
[ HASH_TYPE: [ "sha256", "keccak", "blake2b", "blake3"]
|
||||
, INPUT_SIZE_BYTES: [ 256, 512, 1024, 2048 ]
|
||||
]
|
||||
tags: risc0, $HASH_TYPE
|
||||
comments:
|
||||
The benchmarks includes for sha256, keccak, blake2b, blake3.
|
||||
the hashing is done inside the guest and receipt is received which is verified.
|
||||
@ -1,11 +0,0 @@
|
||||
name: "Hashes benchmarking using risc0 prover"
|
||||
author:
|
||||
timeout: 1000
|
||||
params:
|
||||
[ HASH_TYPE_TREE: [ "poseidon2_babybear", "poseidon2_babybear_native", "poseidon2_bn128"]
|
||||
, TREE_DEPTH: [ 2, 4, 8, 16 ]
|
||||
]
|
||||
tags: risc0, $HASH_TYPE_TREE
|
||||
comments:
|
||||
The benchmarks includes for poseidon2(merkle hashing) over bn128 and babybear.
|
||||
the hashing is done inside the guest and receipt is received which is verified.
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cargo build --release
|
||||
@ -1,10 +0,0 @@
|
||||
[package]
|
||||
name = "benchmark_methods"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[build-dependencies]
|
||||
risc0-build = { path = "../../external/risc0/risc0/build" }
|
||||
|
||||
[package.metadata.risc0]
|
||||
methods = ["guest"]
|
||||
@ -1,3 +0,0 @@
|
||||
fn main() {
|
||||
risc0_build::embed_methods();
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
[package]
|
||||
name = "method"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
# If you want to try (experimental) std support, add `features = [ "std" ]` to risc0-zkvm
|
||||
risc0-zkvm = { path = "../../../external/risc0/risc0/zkvm", default-features = false,features = ["std"] }
|
||||
sha3 = "0.10.8"
|
||||
sha2 ={ git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.6-risczero.0" }
|
||||
risc0-zkp = {path = "../../../external/risc0/risc0/zkp"}
|
||||
blake3 = "1.5.0"
|
||||
zkhash = { git = "https://github.com/HorizenLabs/poseidon2.git"}
|
||||
ark-serialize = "0.4"
|
||||
ark-ff = "0.4.2"
|
||||
risc0-core = {path = "../../../external/risc0/risc0/core"}
|
||||
lazy_static = "1.4"
|
||||
# risc0-zkp-core = "0.10.0"
|
||||
rand = "0.8.5"
|
||||
@ -1,15 +0,0 @@
|
||||
#![no_main]
|
||||
|
||||
use risc0_zkvm::{guest::env, sha::Digest};
|
||||
use risc0_zkp::core::hash::blake2b::{Blake2b, Blake2bCpuImpl};
|
||||
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let data: Vec<u8> = env::read();
|
||||
let hash = Blake2bCpuImpl::blake2b(&data);
|
||||
let digest: Digest = hash.into();
|
||||
env::commit(&digest)
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
#![no_main]
|
||||
|
||||
use risc0_zkvm::{guest::env, sha::Digest};
|
||||
use blake3::hash;
|
||||
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let data: Vec<u8> = env::read();
|
||||
let result = hash(&data);
|
||||
let digest = Digest::try_from(*result.as_bytes()).unwrap();
|
||||
env::commit(&digest)
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
#![no_main]
|
||||
|
||||
use risc0_zkvm::{guest::env, sha::Digest};
|
||||
use sha3::{Digest as _, Keccak256};
|
||||
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let data: Vec<u8> = env::read();
|
||||
let hash: [u8;32] = Keccak256::digest(data).into();
|
||||
let digest = Digest::try_from(hash).unwrap();
|
||||
env::commit(&digest)
|
||||
|
||||
}
|
||||
@ -1,135 +0,0 @@
|
||||
#![no_main]
|
||||
#![allow(non_snake_case)]
|
||||
use risc0_zkvm::guest::env;
|
||||
use zkhash::poseidon2::poseidon2;
|
||||
use zkhash::poseidon2::poseidon2::Poseidon2;
|
||||
use zkhash::poseidon2::poseidon2_instance_babybear::{/*POSEIDON2_BABYBEAR_16_PARAMS , */POSEIDON2_BABYBEAR_24_PARAMS};
|
||||
use zkhash::fields::babybear::FpBabyBear;
|
||||
use ark_serialize::{CanonicalSerialize, CanonicalDeserialize};
|
||||
use std::marker::PhantomData;
|
||||
use risc0_zkvm::guest::env::cycle_count;
|
||||
|
||||
use ark_ff::PrimeField;
|
||||
|
||||
pub trait MerkleTreeHash<F: PrimeField> {
|
||||
fn compress(&self, input: &[&F]) -> Vec<F>;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MerkleTree<F: PrimeField, P: MerkleTreeHash<F>> {
|
||||
perm: P,
|
||||
field: PhantomData<F>,
|
||||
}
|
||||
|
||||
impl<F: PrimeField, P: MerkleTreeHash<F>> MerkleTree<F, P> {
|
||||
pub fn new(perm: P) -> Self {
|
||||
MerkleTree {
|
||||
perm,
|
||||
field: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
fn round_up_pow_n(input: usize, n: usize) -> usize {
|
||||
debug_assert!(n >= 1);
|
||||
let mut res = 1;
|
||||
// try powers, starting from n
|
||||
loop {
|
||||
res *= n;
|
||||
if res >= input {
|
||||
break;
|
||||
}
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
pub fn accumulate(&mut self, set: &[F]) -> Vec<F> {
|
||||
assert!(set.len()%8 == 0);
|
||||
let set_size = set.len() / 8;
|
||||
let mut bound = Self::round_up_pow_n(set_size, 2);
|
||||
loop {
|
||||
if bound >= 2 {
|
||||
break;
|
||||
}
|
||||
bound *= 2;
|
||||
}
|
||||
let mut nodes: Vec<F> = Vec::with_capacity(bound * 8);
|
||||
for s in set {
|
||||
nodes.push(s.to_owned());
|
||||
}
|
||||
// pad
|
||||
for _ in nodes.len()..bound {
|
||||
nodes.push(nodes[set_size * 8 - 1].to_owned());
|
||||
}
|
||||
|
||||
while nodes.len() > 8 {
|
||||
let new_len = nodes.len() / 2;
|
||||
let mut new_nodes: Vec<F> = Vec::with_capacity(new_len);
|
||||
for i in (0..nodes.len()).step_by(16) {
|
||||
let inp = [
|
||||
&nodes[i], &nodes[i + 1], &nodes[i + 2], &nodes[i + 3], &nodes[i + 4], &nodes[i + 5], &nodes[i + 6], &nodes[i + 7],
|
||||
&nodes[i + 8], &nodes[i + 9], &nodes[i + 10], &nodes[i + 11], &nodes[i + 12], &nodes[i + 13], &nodes[i + 14], &nodes[i + 15]
|
||||
];
|
||||
let dig = self.perm.compress(&inp);
|
||||
|
||||
for j in 0..8 {
|
||||
new_nodes.push(dig[j]);
|
||||
}
|
||||
|
||||
}
|
||||
nodes = new_nodes;
|
||||
}
|
||||
vec![nodes[0].to_owned(), nodes[1].to_owned(), nodes[2].to_owned(), nodes[3].to_owned(), nodes[4].to_owned(), nodes[5].to_owned(), nodes[6].to_owned(), nodes[7].to_owned()]
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: PrimeField> MerkleTreeHash<F> for Poseidon2<F> {
|
||||
fn compress(&self, input: &[&F]) -> Vec<F> {
|
||||
let p = self.permutation(&[
|
||||
input[0].to_owned(), input[1].to_owned(),input[2].to_owned(), input[3].to_owned(),input[4].to_owned(), input[5].to_owned(),input[6].to_owned(), input[7].to_owned(),
|
||||
input[8].to_owned(), input[9].to_owned(),input[10].to_owned(), input[11].to_owned(),input[12].to_owned(), input[13].to_owned(),input[14].to_owned(), input[15].to_owned(),
|
||||
F::zero(), F::zero(), F::zero(), F::zero(), F::zero(), F::zero(), F::zero(), F::zero()
|
||||
]);
|
||||
|
||||
vec![p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]]
|
||||
}
|
||||
}
|
||||
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let data: Vec<Vec<u8>> = env::read();
|
||||
|
||||
let cycles1 = cycle_count();
|
||||
let mut hash_data: Vec<FpBabyBear> = Vec::new();
|
||||
for i in 0..data.len() {
|
||||
let a_uncompressed = FpBabyBear::deserialize_uncompressed(&**data.get(i).unwrap()).unwrap();
|
||||
hash_data.push(a_uncompressed);
|
||||
}
|
||||
let cycles2 = cycle_count();
|
||||
|
||||
|
||||
let permutation = poseidon2::Poseidon2::new(&POSEIDON2_BABYBEAR_24_PARAMS);
|
||||
let mut merkle_tree = MerkleTree::new(permutation.clone());
|
||||
let cycles3 = cycle_count();
|
||||
let hash_final = merkle_tree.accumulate(&hash_data);
|
||||
|
||||
let cycles4 = cycle_count();
|
||||
|
||||
let mut perm_seralised: Vec<Vec<u8>> = Vec::new();
|
||||
for i in 0..8 {
|
||||
let mut temp: Vec<u8> = Vec::new();
|
||||
hash_final.get(i).unwrap().serialize_uncompressed(&mut temp).unwrap();
|
||||
perm_seralised.push(temp);
|
||||
}
|
||||
let cycles6 = cycle_count();
|
||||
|
||||
env::commit(&perm_seralised);
|
||||
|
||||
eprintln!("number of cycles for input builder: {:?}", cycles2 - cycles1);
|
||||
eprintln!("number of cycles for hash permutation builder: {:?}", cycles3 - cycles2);
|
||||
eprintln!("number of cycles for hash accumulation: {:?}", cycles4 - cycles3);
|
||||
|
||||
eprintln!("number of cycles for permutation seralisation: {:?}", cycles6 - cycles4);
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,43 +0,0 @@
|
||||
#![no_main]
|
||||
use risc0_zkvm::{guest::env/* , sha::Digest*/};
|
||||
// use sha3::{Digest as _, Keccak256};
|
||||
use zkhash::poseidon2::poseidon2;
|
||||
use zkhash::poseidon2::poseidon2_instance_bn256::POSEIDON2_BN256_PARAMS;
|
||||
use zkhash::merkle_tree::merkle_tree_fp::MerkleTree;
|
||||
use zkhash::fields::bn256::FpBN256;
|
||||
use ark_serialize::{CanonicalSerialize, CanonicalDeserialize};
|
||||
use risc0_zkvm::guest::env::cycle_count;
|
||||
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let data: Vec<Vec<u8>> = env::read();
|
||||
let cycles1 = cycle_count();
|
||||
let mut hash_data: Vec<FpBN256> = Vec::new();
|
||||
for i in 0..data.len() {
|
||||
let a_uncompressed = FpBN256::deserialize_uncompressed(&**data.get(i).unwrap()).unwrap();
|
||||
hash_data.push(a_uncompressed);
|
||||
}
|
||||
let cycles2 = cycle_count();
|
||||
|
||||
let permutation = poseidon2::Poseidon2::new(&POSEIDON2_BN256_PARAMS);
|
||||
let mut merkle_tree = MerkleTree::new(permutation.clone());
|
||||
let cycles4 = cycle_count();
|
||||
let hash_final = merkle_tree.accumulate(&hash_data);
|
||||
let cycles5 = cycle_count();
|
||||
|
||||
|
||||
let mut hash_bytes: Vec<u8> = Vec::new();
|
||||
hash_final.serialize_uncompressed(&mut hash_bytes).unwrap();
|
||||
|
||||
let cycles6 = cycle_count();
|
||||
|
||||
env::commit(&hash_bytes);
|
||||
|
||||
eprintln!("number of cycles for input builder: {:?}", cycles2 - cycles1);
|
||||
eprintln!("number of cycles for hash builder: {:?}", cycles4 - cycles2);
|
||||
eprintln!("number of cycles for hash calculation: {:?}", cycles5 - cycles4);
|
||||
eprintln!("number of cycles for hash serealisation: {:?}", cycles6 - cycles5);
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
#![no_main]
|
||||
|
||||
use risc0_zkvm::{guest::env, sha, sha::Sha256};
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
use risc0_zkvm::guest::env::cycle_count;
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let data: Vec<u8> = env::read();
|
||||
let hash = sha::Impl::hash_bytes(&data);
|
||||
eprintln!("total cycle count for hashing: {:?}",cycle_count());
|
||||
env::commit(&hash)
|
||||
}
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
|
||||
// accelerated sha2 crate
|
||||
#![no_main]
|
||||
|
||||
use risc0_zkvm::guest::env;
|
||||
use sha2::{Sha256, Digest};
|
||||
use risc0_zkvm::guest::env::cycle_count;
|
||||
// use base16ct::lower::encode_str;
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
|
||||
pub fn main() {
|
||||
|
||||
let data: Vec<u8> = env::read();
|
||||
let result = Sha256::digest(data);
|
||||
let c1 = cycle_count();
|
||||
eprintln!("total cycle count for hashing: {:?}",c1);
|
||||
let result_bytes: [u8;32] = result.into();
|
||||
let c2 = cycle_count();
|
||||
eprintln!("cycle count to convert into bytes array: {:?}",c2-c1);
|
||||
env::commit(&result_bytes)
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
|
||||
@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ -z ${ZKBENCH_HASH_TYPE} ]; then
|
||||
ZKBENCH_HASH_TYPE="sha256"
|
||||
fi
|
||||
|
||||
if [ -z ${ZKBENCH_INPUT_SIZE_BYTES} ]; then
|
||||
ZKBENCH_INPUT_SIZE_BYTES=1024
|
||||
fi
|
||||
|
||||
echo "Running benchmarks with the following configurations:"
|
||||
echo "HASH = $ZKBENCH_HASH_TYPE"
|
||||
echo "Input Size (Bytes) = $ZKBENCH_INPUT_SIZE_BYTES"
|
||||
|
||||
# Run the benchmarks
|
||||
./target/release/benchmark $ZKBENCH_HASH_TYPE $ZKBENCH_INPUT_SIZE_BYTES
|
||||
@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ -z ${ZKBENCH_HASH_TYPE_TREE} ]; then
|
||||
ZKBENCH_HASH_TYPE_TREE="poseidon2_babybear_native"
|
||||
fi
|
||||
|
||||
if [ -z ${ZKBENCH_TREE_DEPTH} ]; then
|
||||
ZKBENCH_TREE_DEPTH=2
|
||||
fi
|
||||
|
||||
echo "Running benchmarks with the following configurations:"
|
||||
echo "HASH = $ZKBENCH_HASH_TYPE_TREE"
|
||||
echo "Tree Depth = $ZKBENCH_TREE_DEPTH"
|
||||
|
||||
# Run the benchmarks
|
||||
./target/release/benchmark $ZKBENCH_HASH_TYPE_TREE $ZKBENCH_TREE_DEPTH
|
||||
@ -1,4 +0,0 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
components = ["rustfmt", "rust-src"]
|
||||
profile = "minimal"
|
||||
@ -1,32 +0,0 @@
|
||||
use benchmark_methods::{
|
||||
BLAKE2B_ELF, BLAKE2B_ID
|
||||
};
|
||||
use risc0_zkvm::{default_prover, ExecutorEnv};
|
||||
use risc0_zkvm::{ sha};
|
||||
// use rand::RngCore;
|
||||
use std::time::Instant;
|
||||
|
||||
pub fn blake2b_bench(input: Vec<u8>) {
|
||||
|
||||
let env = ExecutorEnv::builder().write(&input).unwrap().build().unwrap();
|
||||
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
|
||||
let start_time = Instant::now();
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
let receipt = prover.prove(env, BLAKE2B_ELF).unwrap();
|
||||
|
||||
// For example:
|
||||
let _output: sha::Digest = receipt.journal.decode().unwrap();
|
||||
|
||||
let elapsed_time1 = start_time.elapsed();
|
||||
// verify your receipt
|
||||
receipt.verify(BLAKE2B_ID).unwrap();
|
||||
|
||||
let elapsed_time2 = start_time.elapsed();
|
||||
|
||||
eprintln!("Total time: {:?}", elapsed_time2);
|
||||
eprintln!("verification time: {:?}", elapsed_time2 - elapsed_time1);
|
||||
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
use benchmark_methods::{
|
||||
BLAKE3_ELF, BLAKE3_ID
|
||||
};
|
||||
use risc0_zkvm::{default_prover, ExecutorEnv};
|
||||
use risc0_zkvm::{ sha};
|
||||
// use rand::RngCore;
|
||||
use std::time::Instant;
|
||||
|
||||
pub fn blake3_bench(input: Vec<u8>) {
|
||||
|
||||
|
||||
|
||||
let env = ExecutorEnv::builder().write(&input).unwrap().build().unwrap();
|
||||
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
let start_time = Instant::now();
|
||||
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
let receipt = prover.prove(env, BLAKE3_ELF).unwrap();
|
||||
|
||||
// For example:
|
||||
let _output: sha::Digest = receipt.journal.decode().unwrap();
|
||||
|
||||
let elapsed_time1 = start_time.elapsed();
|
||||
// verify your receipt
|
||||
receipt.verify(BLAKE3_ID).unwrap();
|
||||
|
||||
let elapsed_time2 = start_time.elapsed();
|
||||
|
||||
eprintln!("Total time: {:?}", elapsed_time2);
|
||||
eprintln!("verification time: {:?}", elapsed_time2 - elapsed_time1);
|
||||
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
use benchmark_methods::{
|
||||
KECCAK_ELF, KECCAK_ID
|
||||
};
|
||||
use risc0_zkvm::{default_prover, ExecutorEnv};
|
||||
use risc0_zkvm::{ sha};
|
||||
// use rand::RngCore;
|
||||
use std::time::Instant;
|
||||
|
||||
pub fn keccak_bench(input: Vec<u8>) {
|
||||
|
||||
let start_time = Instant::now();
|
||||
|
||||
let env = ExecutorEnv::builder().write(&input).unwrap().build().unwrap();
|
||||
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
let receipt = prover.prove(env, KECCAK_ELF).unwrap();
|
||||
|
||||
// For example:
|
||||
let _output: sha::Digest = receipt.journal.decode().unwrap();
|
||||
|
||||
let elapsed_time1 = start_time.elapsed();
|
||||
// verify your receipt
|
||||
receipt.verify(KECCAK_ID).unwrap();
|
||||
|
||||
let elapsed_time2 = start_time.elapsed();
|
||||
|
||||
eprintln!("Total time: {:?}", elapsed_time2);
|
||||
eprintln!("verification time: {:?}", elapsed_time2 - elapsed_time1);
|
||||
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
pub mod sha256;
|
||||
pub mod sha256_accelerated;
|
||||
pub mod keccak;
|
||||
pub mod blake2b;
|
||||
pub mod blake3;
|
||||
pub mod poseidon2_bn128;
|
||||
pub mod poseidon2_babybear;
|
||||
pub mod poseidon2_babybear_native;
|
||||
@ -1,66 +0,0 @@
|
||||
#![allow(non_snake_case)]
|
||||
use benchmark_methods::{
|
||||
POSEIDON2_BABYBEAR_ELF,
|
||||
POSEIDON2_BABYBEAR_ID
|
||||
};
|
||||
use risc0_zkvm::{
|
||||
default_prover,
|
||||
ExecutorEnv
|
||||
};
|
||||
use zkhash::fields::{
|
||||
babybear::FpBabyBear,
|
||||
utils::random_scalar
|
||||
};
|
||||
use std::time::Instant;
|
||||
use ark_serialize::{
|
||||
CanonicalSerialize,
|
||||
CanonicalDeserialize
|
||||
};
|
||||
|
||||
|
||||
pub fn poseidon2_babybear_bench(mt_depth: usize) {
|
||||
|
||||
type Scalar = FpBabyBear;
|
||||
|
||||
let t = (1 << mt_depth) * 8;
|
||||
let mut input_scalar: Vec<Vec<u8>> = Vec::new();
|
||||
|
||||
for _ in 0..t {
|
||||
let mut uncompressed_bytes = Vec::new();
|
||||
let a: Scalar = random_scalar();
|
||||
a.serialize_uncompressed(&mut uncompressed_bytes).unwrap();
|
||||
input_scalar.push(uncompressed_bytes);
|
||||
}
|
||||
|
||||
let env = ExecutorEnv::builder().write(&input_scalar).unwrap().build().unwrap();
|
||||
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
|
||||
let start_time = Instant::now();
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
let receipt = prover.prove(env, POSEIDON2_BABYBEAR_ELF).unwrap();
|
||||
let elapsed_time = start_time.elapsed();
|
||||
|
||||
// verify your receipt
|
||||
receipt.verify(POSEIDON2_BABYBEAR_ID).unwrap();
|
||||
|
||||
let elapsed_time2 = start_time.elapsed();
|
||||
|
||||
// For example:
|
||||
let output: Vec<Vec<u8>> = receipt.journal.decode().unwrap();
|
||||
|
||||
let mut output_deseralised: Vec<Scalar> = Vec::new();
|
||||
|
||||
for i in 0..output.len() {
|
||||
output_deseralised.push(Scalar::deserialize_uncompressed(&**output.get(i).unwrap()).unwrap());
|
||||
}
|
||||
|
||||
eprintln!("hash: {:?}", output_deseralised);
|
||||
eprintln!("Total time: {:?}", elapsed_time2);
|
||||
eprintln!("Verification time: {:?}", elapsed_time2 - elapsed_time);
|
||||
|
||||
// eprintln!("Hash: {:?}", hash_final);
|
||||
|
||||
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
#![allow(non_snake_case)]
|
||||
use benchmark_methods::{
|
||||
POSEIDON2_BABYBEAR_NATIVE_ELF,
|
||||
POSEIDON2_BABYBEAR_NATIVE_ID
|
||||
};
|
||||
use risc0_zkvm::{
|
||||
default_prover,
|
||||
ExecutorEnv
|
||||
};
|
||||
use std::time::Instant;
|
||||
use rand::Rng;
|
||||
|
||||
pub fn poseidon2_babybear_native_bench(mt_depth: usize) {
|
||||
|
||||
let t = (1 << mt_depth) * 8;
|
||||
let mut input: Vec<u32> = Vec::new();
|
||||
|
||||
for _ in 0..t {
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let random_u32: u32 = rng.gen();
|
||||
input.push(random_u32);
|
||||
}
|
||||
|
||||
let env = ExecutorEnv::builder().write(&input).unwrap().build().unwrap();
|
||||
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
|
||||
let start_time = Instant::now();
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
let receipt = prover.prove(env, POSEIDON2_BABYBEAR_NATIVE_ELF).unwrap();
|
||||
let elapsed_time = start_time.elapsed();
|
||||
|
||||
// verify your receipt
|
||||
receipt.verify(POSEIDON2_BABYBEAR_NATIVE_ID).unwrap();
|
||||
|
||||
let elapsed_time2 = start_time.elapsed();
|
||||
|
||||
let output: Vec<u32> = receipt.journal.decode().unwrap();
|
||||
|
||||
eprintln!("hash: {:?}", output);
|
||||
|
||||
eprintln!("Total time: {:?}", elapsed_time2);
|
||||
eprintln!("Verification time: {:?}", elapsed_time2 - elapsed_time);
|
||||
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
use benchmark_methods::{
|
||||
POSEIDON2_BN128_ELF, POSEIDON2_BN128_ID
|
||||
};
|
||||
use risc0_zkvm::{default_prover, ExecutorEnv};
|
||||
use zkhash::{fields::{bn256::FpBN256, utils::random_scalar}/* , poseidon2::poseidon2_instance_bn256::POSEIDON2_BN256_PARAMS*/};
|
||||
use std::time::Instant;
|
||||
use ark_serialize::{CanonicalSerialize, CanonicalDeserialize};
|
||||
|
||||
|
||||
pub fn poseidon2_bn128_bench(mt_depth: usize) {
|
||||
|
||||
type Scalar = FpBN256;
|
||||
|
||||
let mut input_scalar: Vec<Vec<u8>> = Vec::new();
|
||||
let number_of_leaves: u32 = 1 << mt_depth;
|
||||
for _ in 0..number_of_leaves {
|
||||
let mut uncompressed_bytes = Vec::new();
|
||||
let a: Scalar = random_scalar();
|
||||
a.serialize_uncompressed(&mut uncompressed_bytes).unwrap();
|
||||
input_scalar.push(uncompressed_bytes);
|
||||
}
|
||||
|
||||
let env = ExecutorEnv::builder().write(&input_scalar).unwrap().build().unwrap();
|
||||
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
|
||||
let start_time = Instant::now();
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
let receipt = prover.prove(env, POSEIDON2_BN128_ELF).unwrap();
|
||||
let elapsed_time = start_time.elapsed();
|
||||
|
||||
|
||||
// verify your receipt
|
||||
receipt.verify(POSEIDON2_BN128_ID).unwrap();
|
||||
|
||||
let elapsed_time2 = start_time.elapsed();
|
||||
|
||||
// For example:
|
||||
let output: Vec<u8> = receipt.journal.decode().unwrap();
|
||||
|
||||
let hash_final = Scalar::deserialize_uncompressed(&*output).unwrap();
|
||||
|
||||
eprintln!("Hash: {:?}", hash_final);
|
||||
eprintln!("Total time: {:?}", elapsed_time2);
|
||||
eprintln!("Verification time: {:?}", elapsed_time2 - elapsed_time);
|
||||
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
use benchmark_methods::{
|
||||
SHA256_ELF, SHA256_ID
|
||||
};
|
||||
use risc0_zkvm::{default_prover, ExecutorEnv};
|
||||
use risc0_zkvm::{ sha};
|
||||
use std::time::Instant;
|
||||
pub fn sha_bench(input: Vec<u8>) {
|
||||
|
||||
let env = ExecutorEnv::builder().write(&input).unwrap().build().unwrap();
|
||||
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
eprintln!("\n------risc0_zkvm sha hashing------\n");
|
||||
|
||||
let start_time = Instant::now();
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
let receipt = prover.prove(env, SHA256_ELF).unwrap();
|
||||
let elapsed_time = start_time.elapsed();
|
||||
|
||||
// verify your receipt
|
||||
receipt.verify(SHA256_ID).unwrap();
|
||||
|
||||
let elapsed_time2 = start_time.elapsed();
|
||||
|
||||
let _output: sha::Digest = receipt.journal.decode().unwrap();
|
||||
|
||||
eprintln!("Total time: {:?}", elapsed_time2);
|
||||
eprintln!("Verification time: {:?}", elapsed_time2 - elapsed_time);
|
||||
|
||||
eprintln!("Hash: {:?}", _output);
|
||||
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
use benchmark_methods::{
|
||||
SHA256_ACCELERATED_ELF, SHA256_ACCELERATED_ID
|
||||
};
|
||||
use risc0_zkvm::{default_prover, ExecutorEnv};
|
||||
use std::time::Instant;
|
||||
use hex::encode;
|
||||
pub fn sha_accelerated_bench(input: Vec<u8>) {
|
||||
|
||||
let env = ExecutorEnv::builder().write(&input).unwrap().build().unwrap();
|
||||
eprintln!("\n------RustCrypto sha hashing(accelerated)------\n");
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
|
||||
let start_time = Instant::now();
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
let receipt = prover.prove(env, SHA256_ACCELERATED_ELF).unwrap();
|
||||
let elapsed_time = start_time.elapsed();
|
||||
|
||||
// verify your receipt
|
||||
receipt.verify(SHA256_ACCELERATED_ID).unwrap();
|
||||
|
||||
let elapsed_time2 = start_time.elapsed();
|
||||
|
||||
let _output: [u8;32] = receipt.journal.decode().unwrap();
|
||||
let hash = encode(_output);
|
||||
eprintln!("Total time: {:?}", elapsed_time2);
|
||||
eprintln!("Verification time: {:?}", elapsed_time2 - elapsed_time);
|
||||
|
||||
eprintln!("Hash: {:?}", hash);
|
||||
}
|
||||
@ -1,95 +0,0 @@
|
||||
mod benches;
|
||||
use benches::{
|
||||
sha256::sha_bench,
|
||||
sha256_accelerated::sha_accelerated_bench,
|
||||
keccak::keccak_bench,
|
||||
blake2b::blake2b_bench,
|
||||
blake3::blake3_bench,
|
||||
poseidon2_bn128::poseidon2_bn128_bench,
|
||||
poseidon2_babybear::poseidon2_babybear_bench,
|
||||
poseidon2_babybear_native::poseidon2_babybear_native_bench,
|
||||
};
|
||||
use rand::Rng;
|
||||
use std::process;
|
||||
|
||||
fn generate_bytes(size: usize) -> Vec<u8> {
|
||||
let mut rng = rand::thread_rng();
|
||||
(0..size).map(|_| rng.gen()).collect()
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
if args.len() != 3 {
|
||||
println!("Wrong number of arguments! The program expects two arguments: <hash_type> and <size>");
|
||||
// Exit the program with a non-zero exit code
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let hash_type = &args[1];
|
||||
let size = args[2].parse::<usize>().unwrap();
|
||||
|
||||
match hash_type.as_str() {
|
||||
"sha256" => {
|
||||
println!("SHA256 Benchmarking: ");
|
||||
eprintln!("data size(bytes): {:?}", size);
|
||||
let input = generate_bytes(size);
|
||||
sha_bench(input.clone());
|
||||
}
|
||||
"sha256_accelerated" => {
|
||||
println!("Accelerated SHA256 Benchmarking: ");
|
||||
eprintln!("data size(bytes): {:?}", size);
|
||||
let input = generate_bytes(size);
|
||||
sha_accelerated_bench(input.clone());
|
||||
}
|
||||
"keccak" => {
|
||||
println!("KECCAK Benchmarking: ");
|
||||
eprintln!("data size(bytes): {:?}", size);
|
||||
let input = generate_bytes(size);
|
||||
keccak_bench(input.clone());
|
||||
}
|
||||
|
||||
"blake2b" => {
|
||||
println!("Blake2b Benchmarking: ");
|
||||
eprintln!("data size(bytes): {:?}", size);
|
||||
let input = generate_bytes(size);
|
||||
blake2b_bench(input.clone());
|
||||
}
|
||||
|
||||
"blake3" => {
|
||||
println!("Blake3 Benchmarking: ");
|
||||
eprintln!("data size(bytes): {:?}", size);
|
||||
let input = generate_bytes(size);
|
||||
blake3_bench(input.clone());
|
||||
}
|
||||
|
||||
"poseidon2_bn128" => {
|
||||
println!("Poseidon2 Benchmarking on the BN128 field: ");
|
||||
eprintln!("Tree Depth: {:?}", size);
|
||||
poseidon2_bn128_bench(size);
|
||||
}
|
||||
|
||||
"poseidon2_babybear" => {
|
||||
println!("Poseidon2 Benchmarking on the BabyBear field: ");
|
||||
eprintln!("Tree Depth: {:?}", size);
|
||||
eprintln!("number of inputs {:?}", (1 << size) * 8);
|
||||
poseidon2_babybear_bench(size);
|
||||
}
|
||||
|
||||
"poseidon2_babybear_native" => {
|
||||
println!("Poseidon2 Benchmarking on the BabyBear field: ");
|
||||
eprintln!("Tree Depth: {:?}", size);
|
||||
eprintln!("number of inputs {:?}", (1 << size) * 8);
|
||||
poseidon2_babybear_native_bench(size);
|
||||
}
|
||||
|
||||
_ => {
|
||||
println!("Wrong Benchmark Name!");
|
||||
}
|
||||
}
|
||||
|
||||
println!("All Done!");
|
||||
|
||||
}
|
||||
2795
hash/risc0/composition/Cargo.lock
generated
2795
hash/risc0/composition/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,16 +0,0 @@
|
||||
[package]
|
||||
name = "composition"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
composition-methods = { path = "methods" }
|
||||
inner_proof = { path = "../inner_proof" }
|
||||
risc0-zkvm = { path = "../external/risc0/risc0/zkvm" }
|
||||
serde = "1.0"
|
||||
|
||||
[features]
|
||||
cuda = ["risc0-zkvm/cuda"]
|
||||
default = []
|
||||
metal = ["risc0-zkvm/metal"]
|
||||
prove = ["risc0-zkvm/prove"]
|
||||
@ -1 +0,0 @@
|
||||
cargo build --release
|
||||
@ -1,10 +0,0 @@
|
||||
[package]
|
||||
name = "composition-methods"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[build-dependencies]
|
||||
risc0-build = { path = "../../external/risc0/risc0/build" }
|
||||
|
||||
[package.metadata.risc0]
|
||||
methods = ["guest"]
|
||||
@ -1,17 +0,0 @@
|
||||
// Copyright 2024 RISC Zero, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
fn main() {
|
||||
risc0_build::embed_methods();
|
||||
}
|
||||
1100
hash/risc0/composition/methods/guest/Cargo.lock
generated
1100
hash/risc0/composition/methods/guest/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,11 +0,0 @@
|
||||
[package]
|
||||
name = "composition-method"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
risc0-zkvm = { path = "../../../external/risc0/risc0/zkvm", features = ["std"], default-features = false }
|
||||
inner_proof-methods = { path = "../../../inner_proof/methods" }
|
||||
bytemuck = "1.14"
|
||||
@ -1,31 +0,0 @@
|
||||
// Copyright 2024 RISC Zero, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use inner_proof_methods::INNER_PROOF_METHOD_ID;
|
||||
use risc0_zkvm::{guest::env, serde};
|
||||
use risc0_zkvm::sha;
|
||||
fn main() {
|
||||
let c1 = env::cycle_count();
|
||||
let hash: sha::Digest = env::read();
|
||||
let hash2: sha::Digest = env::read();
|
||||
let c2 = env::cycle_count();
|
||||
|
||||
env::verify(INNER_PROOF_METHOD_ID, &serde::to_vec(&hash).unwrap()).unwrap();
|
||||
env::verify(INNER_PROOF_METHOD_ID, &serde::to_vec(&hash2).unwrap()).unwrap();
|
||||
let c3 = env::cycle_count();
|
||||
eprintln!("cycles for input builder: {:?}", c2 - c1);
|
||||
eprintln!("cycles for inner_proof verification inside guest: {:?}", c3 - c2);
|
||||
env::commit(&hash);
|
||||
}
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
// Copyright 2024 RISC Zero, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
|
||||
@ -1 +0,0 @@
|
||||
./target/release/composition 32
|
||||
@ -1,65 +0,0 @@
|
||||
// Copyright 2024 RISC Zero, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use composition_methods::{COMPOSITION_METHOD_ELF, COMPOSITION_METHOD_ID};
|
||||
use inner_proof::sha_bench;
|
||||
use risc0_zkvm::{default_prover, ExecutorEnv};
|
||||
use risc0_zkvm::sha;
|
||||
use std::time::Instant;
|
||||
use std::process;
|
||||
|
||||
fn main() {
|
||||
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
if args.len() != 2 {
|
||||
println!("Wrong number of arguments! The program expects one arguments: <size>");
|
||||
// Exit the program with a non-zero exit code
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let data_size = args[1].parse::<usize>().unwrap();
|
||||
|
||||
let t0 = Instant::now();
|
||||
|
||||
let (hash_receipt, hash) = sha_bench(data_size.try_into().unwrap());
|
||||
let (hash_receipt2, hash2) = sha_bench(data_size.try_into().unwrap());
|
||||
|
||||
let env = ExecutorEnv::builder()
|
||||
// add_assumption makes the receipt to be verified available to the prover.
|
||||
.add_assumption(hash_receipt)
|
||||
.write(&hash)
|
||||
.unwrap()
|
||||
.add_assumption(hash_receipt2)
|
||||
.write(&hash2)
|
||||
.unwrap()
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let t1 = t0.elapsed();
|
||||
|
||||
let receipt = default_prover().prove(env, COMPOSITION_METHOD_ELF).unwrap();
|
||||
|
||||
let t2 = t0.elapsed();
|
||||
|
||||
receipt.verify(COMPOSITION_METHOD_ID).unwrap();
|
||||
|
||||
let t3 = t0.elapsed();
|
||||
|
||||
let hash: sha::Digest = receipt.journal.decode().unwrap();
|
||||
eprintln!("hash: {:?}", hash);
|
||||
eprintln!("ExecutorEnv Builder time: {:?}", t1);
|
||||
eprintln!("Proof generation + receiving receipt time: {:?}", t2 - t1);
|
||||
eprintln!("Verification time: {:?}", t3 - t2);
|
||||
}
|
||||
1
hash/risc0/external/risc0
vendored
1
hash/risc0/external/risc0
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 02fad7a498764d5c6cc851f246813b73b41c30b8
|
||||
2778
hash/risc0/inner_proof/Cargo.lock
generated
2778
hash/risc0/inner_proof/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,17 +0,0 @@
|
||||
[package]
|
||||
name = "inner_proof"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
inner_proof-methods = { path = "methods" }
|
||||
risc0-zkvm = { path = "../external/risc0/risc0/zkvm" }
|
||||
serde = "1.0"
|
||||
rand = "0.8.3"
|
||||
|
||||
|
||||
[features]
|
||||
cuda = ["risc0-zkvm/cuda"]
|
||||
default = []
|
||||
metal = ["risc0-zkvm/metal"]
|
||||
prove = ["risc0-zkvm/prove"]
|
||||
@ -1,10 +0,0 @@
|
||||
[package]
|
||||
name = "inner_proof-methods"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[build-dependencies]
|
||||
risc0-build = { path = "../../external/risc0/risc0/build" }
|
||||
|
||||
[package.metadata.risc0]
|
||||
methods = ["guest"]
|
||||
@ -1,3 +0,0 @@
|
||||
fn main() {
|
||||
risc0_build::embed_methods();
|
||||
}
|
||||
791
hash/risc0/inner_proof/methods/guest/Cargo.lock
generated
791
hash/risc0/inner_proof/methods/guest/Cargo.lock
generated
@ -1,791 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800"
|
||||
|
||||
[[package]]
|
||||
name = "ark-bn254"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f"
|
||||
dependencies = [
|
||||
"ark-ec",
|
||||
"ark-ff",
|
||||
"ark-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-crypto-primitives"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f3a13b34da09176a8baba701233fdffbaa7c1b1192ce031a3da4e55ce1f1a56"
|
||||
dependencies = [
|
||||
"ark-ec",
|
||||
"ark-ff",
|
||||
"ark-relations",
|
||||
"ark-serialize",
|
||||
"ark-snark",
|
||||
"ark-std",
|
||||
"blake2",
|
||||
"derivative",
|
||||
"digest",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-ec"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba"
|
||||
dependencies = [
|
||||
"ark-ff",
|
||||
"ark-poly",
|
||||
"ark-serialize",
|
||||
"ark-std",
|
||||
"derivative",
|
||||
"hashbrown",
|
||||
"itertools",
|
||||
"num-traits",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-ff"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba"
|
||||
dependencies = [
|
||||
"ark-ff-asm",
|
||||
"ark-ff-macros",
|
||||
"ark-serialize",
|
||||
"ark-std",
|
||||
"derivative",
|
||||
"digest",
|
||||
"itertools",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"paste",
|
||||
"rustc_version",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-ff-asm"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-ff-macros"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-groth16"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20ceafa83848c3e390f1cbf124bc3193b3e639b3f02009e0e290809a501b95fc"
|
||||
dependencies = [
|
||||
"ark-crypto-primitives",
|
||||
"ark-ec",
|
||||
"ark-ff",
|
||||
"ark-poly",
|
||||
"ark-relations",
|
||||
"ark-serialize",
|
||||
"ark-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-poly"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf"
|
||||
dependencies = [
|
||||
"ark-ff",
|
||||
"ark-serialize",
|
||||
"ark-std",
|
||||
"derivative",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-relations"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00796b6efc05a3f48225e59cb6a2cda78881e7c390872d5786aaf112f31fb4f0"
|
||||
dependencies = [
|
||||
"ark-ff",
|
||||
"ark-std",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-serialize"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5"
|
||||
dependencies = [
|
||||
"ark-serialize-derive",
|
||||
"ark-std",
|
||||
"digest",
|
||||
"num-bigint",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-serialize-derive"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-snark"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84d3cc6833a335bb8a600241889ead68ee89a3cf8448081fb7694c0fe503da63"
|
||||
dependencies = [
|
||||
"ark-ff",
|
||||
"ark-relations",
|
||||
"ark-serialize",
|
||||
"ark-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ark-std"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "blake2"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c041d3eab048880cb0b86b256447da3f18859a163c3b8d8893f4e6368abe6393"
|
||||
dependencies = [
|
||||
"bytemuck_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck_derive"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aca418a974d83d40a0c1f0c5cba6ff4bc28d8df099109ca459a2118d40b6322"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "const-oid"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derivative"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"const-oid",
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "downcast-rs"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
||||
|
||||
[[package]]
|
||||
name = "elf"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2b183d6ce6ca4cf30e3db37abf5b52568b5f9015c97d9fbdd7026aa5dcdd758"
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "human-repr"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f58b778a5761513caf593693f8951c97a5b610841e754788400f32102eefdff1"
|
||||
|
||||
[[package]]
|
||||
name = "inner_proof_method"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"risc0-zkvm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.149"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-derive"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
|
||||
[[package]]
|
||||
name = "risc0-binfmt"
|
||||
version = "0.20.0-rc.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"elf",
|
||||
"risc0-zkp",
|
||||
"risc0-zkvm-platform",
|
||||
"serde",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "risc0-circuit-recursion"
|
||||
version = "0.20.0-rc.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytemuck",
|
||||
"risc0-core",
|
||||
"risc0-zkp",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "risc0-circuit-rv32im"
|
||||
version = "0.20.0-rc.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"risc0-core",
|
||||
"risc0-zkp",
|
||||
"risc0-zkvm-platform",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "risc0-core"
|
||||
version = "0.20.0-rc.2"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "risc0-zkp"
|
||||
version = "0.20.0-rc.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"blake2",
|
||||
"bytemuck",
|
||||
"digest",
|
||||
"hex",
|
||||
"paste",
|
||||
"rand_core",
|
||||
"risc0-core",
|
||||
"risc0-zkvm-platform",
|
||||
"serde",
|
||||
"sha2",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "risc0-zkvm"
|
||||
version = "0.20.0-rc.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ark-bn254",
|
||||
"ark-groth16",
|
||||
"ark-serialize",
|
||||
"bytemuck",
|
||||
"cfg-if",
|
||||
"getrandom",
|
||||
"hex",
|
||||
"human-repr",
|
||||
"num-bigint",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"risc0-binfmt",
|
||||
"risc0-circuit-recursion",
|
||||
"risc0-circuit-rv32im",
|
||||
"risc0-core",
|
||||
"risc0-zkp",
|
||||
"risc0-zkvm-platform",
|
||||
"rrs-lib",
|
||||
"semver",
|
||||
"serde",
|
||||
"sha2",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "risc0-zkvm-platform"
|
||||
version = "0.20.0-rc.2"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"getrandom",
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rrs-lib"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4382d3af3a4ebdae7f64ba6edd9114fff92c89808004c4943b393377a25d001"
|
||||
dependencies = [
|
||||
"downcast-rs",
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.171"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.171"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.2.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71"
|
||||
dependencies = [
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
|
||||
dependencies = [
|
||||
"zeroize_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize_derive"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
]
|
||||
@ -1,9 +0,0 @@
|
||||
[package]
|
||||
name = "inner_proof_method"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
risc0-zkvm = { path = "../../../external/risc0/risc0/zkvm", default-features = false, features = ["std"]}
|
||||
@ -1,13 +0,0 @@
|
||||
#![no_main]
|
||||
|
||||
use risc0_zkvm::{guest::env, sha, sha::Sha256};
|
||||
|
||||
risc0_zkvm::guest::entry!(main);
|
||||
|
||||
fn main() {
|
||||
let data: String = env::read();
|
||||
let hash = sha::Impl::hash_bytes(&data.as_bytes());
|
||||
env::commit(&hash)
|
||||
}
|
||||
|
||||
|
||||
@ -1 +0,0 @@
|
||||
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
|
||||
@ -1,42 +0,0 @@
|
||||
use inner_proof_methods::INNER_PROOF_METHOD_ELF;
|
||||
use risc0_zkvm::{default_prover, ExecutorEnv, Receipt};
|
||||
use risc0_zkvm::{ sha};
|
||||
use rand::Rng;
|
||||
|
||||
|
||||
pub fn generate_bytes(size: u32) -> String {
|
||||
let mut rng = rand::thread_rng();
|
||||
let random_bytes: Vec<u8> = (0..(size/2)).map(|_| rng.gen()).collect();
|
||||
|
||||
let random_string: String = random_bytes
|
||||
.iter()
|
||||
.map(|byte| format!("{:02X}", byte)) // Convert each byte to a two-digit hexadecimal string
|
||||
.collect();
|
||||
|
||||
// eprintln!("bytes: {:?}", random_string.as_bytes().len());
|
||||
random_string
|
||||
|
||||
}
|
||||
|
||||
pub fn sha_bench(size: u32) -> (Receipt, sha::Digest) {
|
||||
|
||||
let input = generate_bytes(size);
|
||||
|
||||
let env = ExecutorEnv::builder()
|
||||
.write(&input)
|
||||
.unwrap()
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
// Obtain the default prover.
|
||||
let prover = default_prover();
|
||||
|
||||
// Produce a receipt by proving the specified ELF binary.
|
||||
let receipt = prover.prove(env, INNER_PROOF_METHOD_ELF).unwrap();
|
||||
|
||||
let _output: sha::Digest = receipt.journal.decode().expect(
|
||||
"cannot deserialise",
|
||||
);
|
||||
|
||||
(receipt, _output)
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
// Copyright 2024 RISC Zero, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
use inner_proof::sha_bench;
|
||||
use inner_proof_methods::INNER_PROOF_METHOD_ID;
|
||||
use std::process;
|
||||
|
||||
fn main() {
|
||||
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
if args.len() != 2 {
|
||||
println!("Wrong number of arguments! The program expects two arguments: <number_of_composition> and <size>");
|
||||
// Exit the program with a non-zero exit code
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let data_size = args[1].parse::<usize>().unwrap();
|
||||
|
||||
let (receipt, _output) = sha_bench(data_size.try_into().unwrap());
|
||||
|
||||
// Verify receipt, panic if it's wrong
|
||||
receipt.verify(INNER_PROOF_METHOD_ID).expect(
|
||||
"cannot verify",
|
||||
);
|
||||
|
||||
eprintln!("hash: {:?}", _output);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user