-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] Calculate proof size and number of hashes (#712)
This PR is base on #692 and provided required features to calculate the size of proofs and number of hashes Now it has been implied in the e2e test `test_single_add_instance_e2e` and `fibonacci` bench, obtained following output: > encoded zkvm proof size: 2756371, hash_num: 4411 The encoding of proof is done by `bincode` to kept the serialization as compact as possible --------- Co-authored-by: Matthias Goergens <[email protected]>
- Loading branch information
1 parent
830b840
commit de96bd4
Showing
8 changed files
with
145 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,59 @@ | ||
use crate::{BasicTranscript, Challenge, ForkableTranscript, Transcript}; | ||
use ff_ext::ExtensionField; | ||
use std::cell::RefCell; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct Statistic { | ||
pub field_appended_num: u32, | ||
} | ||
|
||
pub type StatisticRecorder = RefCell<Statistic>; | ||
|
||
#[derive(Clone)] | ||
pub struct BasicTranscriptWitStat<'a, E: ExtensionField> { | ||
inner: BasicTranscript<E>, | ||
stat: &'a StatisticRecorder, | ||
} | ||
|
||
impl<'a, E: ExtensionField> BasicTranscriptWitStat<'a, E> { | ||
pub fn new(stat: &'a StatisticRecorder, label: &'static [u8]) -> Self { | ||
Self { | ||
inner: BasicTranscript::<_>::new(label), | ||
stat, | ||
} | ||
} | ||
} | ||
|
||
impl<E: ExtensionField> Transcript<E> for BasicTranscriptWitStat<'_, E> { | ||
fn append_field_elements(&mut self, elements: &[E::BaseField]) { | ||
self.stat.borrow_mut().field_appended_num += 1; | ||
self.inner.append_field_elements(elements) | ||
} | ||
|
||
fn append_field_element_ext(&mut self, element: &E) { | ||
self.stat.borrow_mut().field_appended_num += E::DEGREE as u32; | ||
self.inner.append_field_element_ext(element) | ||
} | ||
|
||
fn read_challenge(&mut self) -> Challenge<E> { | ||
self.inner.read_challenge() | ||
} | ||
|
||
fn read_field_element_exts(&self) -> Vec<E> { | ||
self.inner.read_field_element_exts() | ||
} | ||
|
||
fn read_field_element(&self) -> E::BaseField { | ||
self.inner.read_field_element() | ||
} | ||
|
||
fn send_challenge(&self, challenge: E) { | ||
self.inner.send_challenge(challenge) | ||
} | ||
|
||
fn commit_rolling(&mut self) { | ||
self.inner.commit_rolling() | ||
} | ||
} | ||
|
||
impl<E: ExtensionField> ForkableTranscript<E> for BasicTranscriptWitStat<'_, E> {} |