plonky2 version changed to 0.2.2, build.sh and run.sh added

This commit is contained in:
Manish Kumar 2024-04-24 23:15:15 +05:30
parent 8f98119c3b
commit 839e3448e1
7 changed files with 47 additions and 10 deletions

View File

@ -1,14 +1,15 @@
[package]
name = "plonky2"
name = "plonky2_hash_benchmarks"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
plonky2_u32 ={ git = "https://github.com/0xPolygonZero/plonky2-u32"}
plonky2_field ={ git = "https://github.com/0xPolygonZero/plonky2"}
plonky2 = "0.1.4"
# TODO: This can be later changed to original github
plonky2_u32 ={ git = "https://github.com/man2706kum/plonky2-u32.git"}
plonky2 = "0.2.2"
rand = "0.8.3"
anyhow = "1.0.79"
sha2 = "0.10"

8
hash/plonky2/build.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
# Set nightly as the default toolchain
rustup override set nightly
# Build
cargo build

15
hash/plonky2/run.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
if [ -z ${ZKBENCH_HASH_TYPE} ]; then
ZKBENCH_HASH_TYPE="poseidon"
fi
if [ -z ${ZKBENCH_INPUT_SIZE_BYTES} ]; then
ZKBENCH_INPUT_SIZE_BYTES=4
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/debug/plonky2_hash_benchmarks $ZKBENCH_HASH_TYPE $ZKBENCH_INPUT_SIZE_BYTES

View File

@ -19,7 +19,7 @@
pub fn keccak_bench(size: usize) {
pub fn keccak_bench(_size: usize) {
}

View File

@ -10,6 +10,7 @@ use plonky2::plonk::circuit_builder::CircuitBuilder;
use plonky2::plonk::circuit_data::CircuitConfig;
use plonky2::plonk::config::{/*AlgebraicHasher,*/ GenericConfig, PoseidonGoldilocksConfig};
use rand::Rng;
use std::time;
fn generate_data(size: usize) -> Vec<GoldilocksField> {
// let mut rng = rand::thread_rng();
@ -56,9 +57,23 @@ pub fn poseidon_bench(depth: usize) -> Result<()> {
let data = builder.build::<C>();
let proof = data.prove(pw)?;
let (proof_generation_time, proof) = {
data.verify(proof)
let start = time::Instant::now();
let proof = data.prove(pw)?;
let end_time = start.elapsed();
(end_time, proof)
};
let (verification_time, result) = {
let start = time::Instant::now();
let result = data.verify(proof);
let end_time = start.elapsed();
(end_time, result)
};
eprintln!("proof generation time: {:?}", proof_generation_time);
eprintln!("verification time: {:?}", verification_time);
result
}

View File

@ -1,6 +1,5 @@
use plonky2::iop::target::BoolTarget;
use plonky2::hash::hash_types::RichField;
use plonky2::iop::target::Target;
use plonky2::plonk::circuit_builder::CircuitBuilder;
use plonky2::field::extension::Extendable;
use plonky2_u32::gadgets::arithmetic_u32::{CircuitBuilderU32, U32Target};
@ -9,7 +8,6 @@ use plonky2::plonk::config::PoseidonGoldilocksConfig;
use plonky2::plonk::config::GenericConfig;
use plonky2::plonk::circuit_data::CircuitConfig;
use plonky2::iop::witness::{PartialWitness, WitnessWrite};
// use rand::Rng;
use sha2::{Digest, Sha256};
use super::sigma::big_sigma0;
use super::sigma::big_sigma1;

@ -1 +1 @@
Subproject commit 1742ef8098d246871055501a0559811c9a8fece4
Subproject commit 02fad7a498764d5c6cc851f246813b73b41c30b8