-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Compute size of Execution proof without needing to compute the proof #2949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
5a19d81
5d27960
727b65f
68defa5
99c00bd
47acade
32f3ea1
3191b05
532cd3d
6841b97
49f0a3a
1ee7a72
d394f44
de62b52
edac4f1
5f966ad
795df43
1988927
d63394f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,20 +15,22 @@ | |||||||||||||
|
|
||||||||||||||
| use crate::{ | ||||||||||||||
| SNARKError, | ||||||||||||||
| polycommit::sonic_pc, | ||||||||||||||
| snark::varuna::{CircuitId, ahp}, | ||||||||||||||
| polycommit::{kzg10::KZGCommitment, sonic_pc}, | ||||||||||||||
| snark::varuna::{CircuitId, VarunaVersion, ahp}, | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| use ahp::prover::{FourthMessage, ThirdMessage}; | ||||||||||||||
| use snarkvm_curves::PairingEngine; | ||||||||||||||
| use snarkvm_fields::PrimeField; | ||||||||||||||
| use snarkvm_fields::{One, PrimeField}; | ||||||||||||||
| use snarkvm_utilities::{FromBytes, ToBytes, into_io_error, serialize::*}; | ||||||||||||||
|
|
||||||||||||||
| use std::{ | ||||||||||||||
| collections::BTreeMap, | ||||||||||||||
| io::{self, Read, Write}, | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| use std::mem::size_of; | ||||||||||||||
|
|
||||||||||||||
| #[derive(Clone, Debug, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)] | ||||||||||||||
| pub struct Commitments<E: PairingEngine> { | ||||||||||||||
| pub witness_commitments: Vec<WitnessCommitments<E>>, | ||||||||||||||
|
|
@@ -378,6 +380,88 @@ impl<E: PairingEngine> FromBytes for Proof<E> { | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /// Computes the size of a Varuna proof in bytes without receiving the proof | ||||||||||||||
| /// itself. | ||||||||||||||
| /// | ||||||||||||||
| /// *Arguments*: | ||||||||||||||
| /// - `batch_sizes`: the batch sizes of the circuits and instances being | ||||||||||||||
| /// proved. | ||||||||||||||
| /// - `hiding`: indicates whether the proof system is run in ZK mode | ||||||||||||||
| /// - `varuna_version`: the version of Varuna being used | ||||||||||||||
| /// | ||||||||||||||
| /// *Returns*: | ||||||||||||||
| /// - `Some(size)` for `VarunaVersion::V2`, where `size` is the size of the | ||||||||||||||
| /// proof in bytes. | ||||||||||||||
| /// - `None` for `VarunaVersion::V1`. | ||||||||||||||
| pub fn proof_size<E: PairingEngine>( | ||||||||||||||
| batch_sizes: &[usize], | ||||||||||||||
| varuna_version: VarunaVersion, | ||||||||||||||
| hiding: bool, | ||||||||||||||
| ) -> Option<usize> { | ||||||||||||||
| let n_circuits: usize = batch_sizes.len(); | ||||||||||||||
| let n_instances: usize = batch_sizes.iter().sum(); | ||||||||||||||
|
|
||||||||||||||
| match varuna_version { | ||||||||||||||
| VarunaVersion::V1 => None, | ||||||||||||||
| VarunaVersion::V2 => { | ||||||||||||||
| // All fields are serialised in Compressed mode The breakdown is as | ||||||||||||||
vicsn marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
| // follows: | ||||||||||||||
| // - batch sizes: (boils down to CanonicalSerialize for [usize]) | ||||||||||||||
| // + one u64 for the length (the number of circuits) followed that many usize | ||||||||||||||
| // This contains the size information for the vectors in all other fields, | ||||||||||||||
| // which are therefore serialised without their length | ||||||||||||||
|
||||||||||||||
| // - batch sizes: (boils down to CanonicalSerialize for [usize]) | |
| // + one u64 for the length (the number of circuits) followed that many usize | |
| // This contains the size information for the vectors in all other fields, | |
| // which are therefore serialised without their length | |
| // - batch sizes: one `usize` for each batch size plus one `u64` for the number of batches. | |
| // This contains the size information for all other vectors in the `Proof`, allowing them to be serialized without a length prefix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
Antonio95 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
vicsn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
vicsn marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,8 @@ mod serialize; | |||||
| mod string; | ||||||
|
|
||||||
| use console::{network::prelude::*, program::Request, types::Field}; | ||||||
| use snarkvm_ledger_block::{Transaction, Transition}; | ||||||
| use snarkvm_algorithms::snark::varuna::{VarunaVersion, proof_size}; | ||||||
| use snarkvm_ledger_block::{Input, Transaction, Transition}; | ||||||
| use snarkvm_synthesizer_program::StackTrait; | ||||||
|
|
||||||
| use indexmap::IndexMap; | ||||||
|
|
@@ -285,6 +286,71 @@ impl<N: Network> PartialEq for Authorization<N> { | |||||
|
|
||||||
| impl<N: Network> Eq for Authorization<N> {} | ||||||
|
|
||||||
| impl<N: Network> Authorization<N> { | ||||||
| /// Returns the (exact) predicted size of the Varuna proof of an Authorization | ||||||
|
||||||
| /// Returns the (exact) predicted size of the Varuna proof of an Authorization | |
| /// Returns the size of the Varuna proof of an `Authorization` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(function gone in later commits)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // The value returned coincides with `Proof<N: Network>::write_le()`, which | |
| // The value returned is equal to the number of bytes returned by `Proof<N: Network>::write_le()`, which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(function gone in later commits)
Antonio95 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Total number of inputs to the passed `Transition`s that are of type | |
| /// Returns the total number of inputs to the passed `Transition`s that are of type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(addressed and also fixed other parts of the same documentation that had become outdated due to the interface change)
Uh oh!
There was an error while loading. Please reload this page.