mirror of https://github.com/zcash/halo2.git
Merge pull request #736 from CarloModicaPortfolio/sha256_update
Sha256 update
This commit is contained in:
commit
35eb268e20
|
@ -10,14 +10,13 @@ use halo2_proofs::{
|
|||
};
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use std::{
|
||||
fs::File,
|
||||
fs::{create_dir_all, File},
|
||||
io::{prelude::*, BufReader},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
|
||||
use halo2_gadgets::sha256::{BlockWord, Sha256, Table16Chip, Table16Config, BLOCK_SIZE};
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -77,6 +76,9 @@ fn bench(name: &str, k: u32, c: &mut Criterion) {
|
|||
}
|
||||
}
|
||||
|
||||
// Create parent directory for assets
|
||||
create_dir_all("./benches/sha256_assets").expect("Failed to create sha256_assets directory");
|
||||
|
||||
// Initialize the polynomial commitment parameters
|
||||
let params_path = Path::new("./benches/sha256_assets/sha256_params");
|
||||
if File::open(params_path).is_err() {
|
||||
|
@ -102,24 +104,25 @@ fn bench(name: &str, k: u32, c: &mut Criterion) {
|
|||
|
||||
let circuit: MyCircuit = MyCircuit {};
|
||||
|
||||
// let prover_name = name.to_string() + "-prover";
|
||||
let verifier_name = name.to_string() + "-verifier";
|
||||
|
||||
// /// Benchmark proof creation
|
||||
// c.bench_function(&prover_name, |b| {
|
||||
// b.iter(|| {
|
||||
// let mut transcript = Blake2bWrite::init(Fq::one());
|
||||
// create_proof(¶ms, &pk, &circuit, &[], &mut transcript)
|
||||
// .expect("proof generation should not fail");
|
||||
// let proof: Vec<u8> = transcript.finalize();
|
||||
// });
|
||||
// });
|
||||
// Benchmark proof creation
|
||||
/*
|
||||
let prover_name = name.to_string() + "-prover";
|
||||
c.bench_function(&prover_name, |b| {
|
||||
b.iter(|| {
|
||||
let mut transcript = Blake2bWrite::init(vec![]);
|
||||
create_proof(¶ms, &pk, &[circuit], &[&[]], OsRng, &mut transcript)
|
||||
.expect("proof generation should not fail");
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
// Create a proof
|
||||
let proof_path = Path::new("./benches/sha256_assets/sha256_proof");
|
||||
if File::open(proof_path).is_err() {
|
||||
let mut transcript = Blake2bWrite::<_, _, Challenge255<_>>::init(vec![]);
|
||||
create_proof(¶ms, &pk, &[circuit], &[], OsRng, &mut transcript)
|
||||
create_proof(¶ms, &pk, &[circuit], &[&[]], OsRng, &mut transcript)
|
||||
.expect("proof generation should not fail");
|
||||
let proof: Vec<u8> = transcript.finalize();
|
||||
let mut file = File::create(proof_path).expect("Failed to create sha256_proof");
|
||||
|
@ -136,7 +139,7 @@ fn bench(name: &str, k: u32, c: &mut Criterion) {
|
|||
b.iter(|| {
|
||||
let strategy = SingleVerifier::new(¶ms);
|
||||
let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]);
|
||||
assert!(verify_proof(¶ms, pk.get_vk(), strategy, &[], &mut transcript).is_ok());
|
||||
assert!(verify_proof(¶ms, pk.get_vk(), strategy, &[&[]], &mut transcript).is_ok());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue