-
Notifications
You must be signed in to change notification settings - Fork 193
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
Abstract over the vector commitment scheme #285
Conversation
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.
Not a full review - but this looks great! Thank you!
I left some comments inline - most are nits, but one will probably require some investigation.
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.
Thank you! Looks good! Still not a full review - but I left some comments inline. Most are pretty small, but I do wonder if we should maybe make VectorCommitment
trait less general as it seems like we are imposing quite a few restrictions on it anyway (see the last two comments in the PR review).
Specifically, I'm thinking that maybe we get rid of Item
and Commitment
associated types for now and assume that these are always digests of the associated hash function. If I'm reading the code correctly, we enforce these constraints almost everywhere anyway.
So, the trait could look something like this:
pub trait VectorCommitment<H: Hasher>: Sized {
type Options: Default;
type Proof: Clone + Serializable + Deserializable;
type MultiProof: Serializable + Deserializable;
type Error: Debug;
fn with_options(items: Vec<H::Digest>, options: Self::Options) -> Result<Self, Self::Error>;
fn commitment(&self) -> H::Digest;
...
}
I'm also wondering if it makes sense to make the H
type parameter into an associated type (e.g., HashFn
) - but I'm not sure if it will make things better or worse.
This does make the VectorCommitment
trait quite a bit less general, but I think we can approach this refactoring as a 2 step process:
- Introduce vector commitment scheme where we assume that items and commitments are digests. This would reduce the amount of changes in this PR.
- Make the vector commitment scheme more general. Maybe at first transforming items into associated types and then transforming commitments themselves into associated types.
What do you think?
I would probably try to remove the hash function from the vector commitment trait altogether and substitute that with bounds in the relevant places of the form |
Wouldn't this be roughly equivalent to imposing Overall, I don't mind trying different approaches, but my thinking was that we could simplify this PR now, and then experimenting would get simpler in the future as we'll have the core structure in place. |
Yes, but it would move closer to where it is actually needed.
Sure |
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.
Looks good! Thank you! I've added some more comments inline - most are pretty simple and there are a few that are thoughts for the future PRs.
Once this PR is merged, I think the goal of the next PR could be:
- Investigate making hash function an associated type of
VectorCommitment
trait. - Add
Item
associated type to theVectorCommitment
trait.
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.
Looks good! Thank you! I left a few minor comments inline. Also, let's resolve the merge conflict.
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.
All looks good! Thank you!
Addresses #179