proof generation time and verification time added

This commit is contained in:
Manish Kumar 2024-04-26 18:56:39 +05:30
parent 839e3448e1
commit 2583d79a7c
2 changed files with 17 additions and 10 deletions

View File

@ -13,8 +13,6 @@ use rand::Rng;
use std::time;
fn generate_data(size: usize) -> Vec<GoldilocksField> {
// let mut rng = rand::thread_rng();
// (0..size).map(|_| rng.gen()).collect()
let mut data: Vec<GoldilocksField> = Vec::new();
for _ in 0..(1<<size) {
@ -22,7 +20,6 @@ fn generate_data(size: usize) -> Vec<GoldilocksField> {
let random_u64: u64 = rng.gen();
data.push(GoldilocksField::from_canonical_u64(random_u64));
}
// eprint!("data: {:?}", data);
data
}

View File

@ -196,7 +196,6 @@ pub fn sha256_bench() -> Result<()> {
let mut hasher = Sha256::new();
hasher.update(msg.clone());
let hash = hasher.finalize();
// println!("Hash: {:#04X}", hash);
let msg_bits = array_to_bits(&msg.clone());
let len = msg.len() * 8;
@ -226,13 +225,24 @@ pub fn sha256_bench() -> Result<()> {
builder.num_gates()
);
let data = builder.build::<C>();
// let timing = TimingTree::new("prove", Level::Debug);
let proof = data.prove(pw).unwrap();
// timing.print();
// let timing = TimingTree::new("verify", Level::Debug);
let (proof_time, proof ) = {
let start = std::time::Instant::now();
let proof = data.prove(pw).unwrap();
let end = start.elapsed();
(end, proof)
};
let (verification_time, res) = {
let start = std::time::Instant::now();
let res = data.verify(proof);
// timing.print();
let end = start.elapsed();
(end, res)
};
eprintln!("Proof Generation Time: {:?}", proof_time);
eprintln!("Verification Time: {:?}", verification_time);
res