-
Notifications
You must be signed in to change notification settings - Fork 120
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
New PCS trait and implementation #116
Conversation
primitives/src/pcs/mod.rs
Outdated
type ProverParam; | ||
/// Verifier parameters | ||
type VerifierParam; | ||
/// Structured reference string | ||
type SRS; | ||
/// Polynomial and its associated types | ||
type Polynomial; | ||
/// Polynomial input domain | ||
type Point; | ||
/// Polynomial Evaluation | ||
type Evaluation; | ||
/// Commitments | ||
type Commitment: CanonicalSerialize; | ||
/// Batch commitments | ||
type BatchCommitment: CanonicalSerialize; | ||
/// Proofs | ||
type Proof; | ||
/// Batch proofs | ||
type BatchProof; |
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.
Can add more trait bounds such as:
type Proof: Clone + Serialize + CanonicalSerialize + Debug + PartialEq...
can take a look at PairingEngine's associated type, they inherented a lot of basic traits.
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.
@mrain, @chancharles92 maybe use this?
/// Prover parameters
type ProverParam: Clone;
/// Verifier parameters
type VerifierParam: Clone + CanonicalSerialize + CanonicalDeserialize;
/// Structured reference string
type SRS: Clone + Debug;
/// Polynomial and its associated types
type Polynomial: Sized + Clone + Debug + Hash + PartialEq + Eq + Add + Neg + Zero + CanonicalSerialize + CanonicalDeserialize + for<'a> AddAssign<&'a Self> + for<'a> AddAssign<(F, &'a Self)> + for<'a> SubAssign<&'a Self>;
/// Polynomial input domain
type Point:: Clone + Ord + Debug + Sync + Hash + PartialEq + Eq;
/// Polynomial Evaluation
type Evaluation: Field;
/// Commitments
type Commitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq;
/// Batch commitments
type BatchCommitment: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq;
/// Proofs
type Proof: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq;
/// Batch proofs
type BatchProof: Clone + CanonicalSerialize + CanonicalDeserialize + Debug + PartialEq + Eq;
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.
type Polynomial
should be greatest common subset of traits bound fromPolynomial
andMultilinearExtension
.type Point
maybe excludeCopy
(I've updated my comment above)
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.
Thanks @alxiong . But for Polynomial
, Rc
used in multilinear setting could not fit in this trait bound.
I think it make sense to put polynomial in heap because it's usually quite large.
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.
I agree, but similar to the argument for impl Borrow<>
, how do you know what type of smart pointer one wants?
I don't think we should fix smart pointer type at the associate type level, (namely MultilinearKzgPCS::Polynomial = Rc<DenseMultilinearExtension<E::Fr>>
is not as flexible as just DenseMultilinearExtension<E::Fr>
.
and you can always wrap this MLE into some smart pointer, such as Rc
, RefCell
, or Arc
etc.
@chancharles92 what's your opinion?
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.
I don't have a strong opinion. Actually we were using Polynomial = DenseMultilinearExtension
, but later Zhenfei changed it to Polynomial = Rc<Dense...>
which has a few advantages:
- It significantly simplifies the code, o/w we need to add Rc everywhere.
- It make sure that the developer never forget to use
Rc
, otherwise the code performance can be accidentally effected. - When we want to use other smart pointers, we can e.g. use
Polynomial = Arc<...>
in associated type rather than change it everywhere.
- Better naming and exporting. - Interfaces opt for better efficiency.
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.
I give a provisional approval on my comments #116 (comment) being settled.
Description
closes: #62
PolynomialCommitmentScheme
trait and basic implementationsPlonkKzgSnark
use our own KZG10 implementationBefore we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the GitHub PR explorer