-
Notifications
You must be signed in to change notification settings - Fork 118
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
VidScheme
allow disperse
to reuse work done in commit_only
#479
Comments
Discuss: If we change @akonring If we do make breaking API changes then we should open PRs for everything downstream that will break. In order to do so we need to test everything locally via cargo patch directives. EDIT: ...or maybe we can make a subtrait |
I don't have a strong opinion on this. I see that breaking changes to |
We already have an instance of the subtrait pattern with |
Preliminary design of the subtrait below: //! Trait for additional functionality in Verifiable Information Retrieval (VID)
//! for precomputation of specific data that allows for calling
//! methods using the data to save computation for the callee.
use core::fmt::Debug;
use super::{VidDisperse, VidResult, VidScheme};
use ark_std::hash::Hash;
use serde::{de::DeserializeOwned, Serialize};
/// Allow for precomputation of certain data for [`VidScheme`].
pub trait Precomputable: VidScheme {
/// Precomputed data that can be (re-)used during disperse computation
type PrecomputeData: Clone + Debug + Eq + PartialEq + Hash + Sync + Serialize + DeserializeOwned;
/// Similar to [`VidScheme::commit_only`] but returns additional data that
/// can be used as input to `disperse_precompute` for faster dispersal.
fn commit_only_precompute<B>(
&self,
payload: B,
) -> VidResult<(Self::Commit, Self::PrecomputeData)>
where
B: AsRef<[u8]>;
/// Similar to [`VidScheme::disperse`] but takes as input additional
/// data for more efficient computation and faster disersal.
fn disperse_precompute<B>(
&self,
payload: B,
data: Self::PrecomputeData,
) -> VidResult<VidDisperse<Self>>
where
B: AsRef<[u8]>;
} Currently, looking into the implementation: figure out the data we want to re-use and how to satisfy |
Looks pretty good. Notes:
#[derive(CanonicalSerialize, CanonicalDeserialize, Derivative, Deserialize, Serialize)]
#[derivative(
Clone(bound = ""),
Debug(bound = ""),
Eq(bound = ""),
Hash(bound = ""),
PartialEq(bound = "")
)]
pub struct PrecomputeData<E>
where
E: Pairing,
{
#[serde(with = "canonical")]
poly_commits: Vec<KzgCommit<E>>,
} Because there's no |
A significant fraction of the work of
commit_only
is duplicated indisperse
. ie. computing polynomial commitments (dominant cost!),bytes_to_field
, and possibly other things.commit_only
should return additional data beyond the commitment. At a minimum, it should also return the polynomial commitmentsdisperse
should take a (optional) argument for pre-computed polynomial commitments.Need to update
VidScheme
trait with these API changes, then update ADVZ impl to conform.VidScheme
is supposed to be abstract, so we can't just add apoly_commits: Option<Vec<KzgCommit<E>>>
arg todisperse
. Instead we could add yet another assoc type toVidScheme
calledDisperseHelperData
or whatever. The proposal is something likecc @elliedavidson for visibility.
The text was updated successfully, but these errors were encountered: