-
Notifications
You must be signed in to change notification settings - Fork 8
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
NIMFS-centric API refactor for multifolding impl #41
Conversation
I'll review once there's a description of proposed changes and rationale, short is fine! |
31c3929
to
a947fc7
Compare
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.
Overall direction makes sense to me! Left some questions and comments
src/ccs/cccs.rs
Outdated
|
||
pub(crate) ccs: CCSShape<G>, | ||
#[derive(Clone, Debug, PartialEq, Eq /*Serialize, Deserialize*/)] | ||
//#[serde(bound(deserialize = "'de: 'a"))] |
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.
What is this?
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.
Ohh.. Leftover!
Fixed in 52f6a62
src/ccs/cccs.rs
Outdated
} | ||
impl<G: Group> CCCS<G> { | ||
/// Generates a new CCCS given a reference to it's original CCS repr & the multilinear extension of it's matrixes. | ||
/// Then, given the input vector `z`. |
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.
This sentence seems incomplete
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.
Fixed in 52f6a62
src/ccs/cccs.rs
Outdated
pub(crate) x: Vec<G::Scalar>, | ||
} | ||
impl<G: Group> CCCS<G> { | ||
/// Generates a new CCCS given a reference to it's original CCS repr & the multilinear extension of it's matrixes. |
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.
/// Generates a new CCCS given a reference to it's original CCS repr & the multilinear extension of it's matrixes. | |
/// Generates a new CCCS given a reference to its original CCS representation and the multilinear extension of its matrices. |
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.
Fixed in 52f6a62
pub(crate) ccs: CCSShape<G>, | ||
#[derive(Clone, Debug, PartialEq, Eq /*Serialize, Deserialize*/)] | ||
//#[serde(bound(deserialize = "'de: 'a"))] | ||
pub struct CCCS<G: Group> { |
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.
Calling this just CCCS seems a bit weird to me since it stands for "Committed Customizable Constraint Systems". Should this be CCCS Shape or Instance instead?
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 sure it is a big deal though. In any case, I can definitely change it. What do the rest think?
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 actually think is better to have shorter names. Also, we have always called it CCCS indeed in our calls. So that's why I considered a better alternative.
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 guess point would be to stay consistent with code base, but I don't feel super strongly about it, can see both sides
src/ccs/multifolding.rs
Outdated
let ccs_mle = ccs.M.iter().map(|matrix| matrix.to_mle()).collect(); | ||
Self { ccs, ccs_mle } | ||
impl<G: Group> NIMFS<G> { | ||
/// Generates a new NIMFS instance based on the given CCS. |
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.
It seems like it takes more than just ccs
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.
Fixed in 52f6a62
src/ccs/multifolding.rs
Outdated
/// Compute sigma_i and theta_i from step 4 | ||
pub fn compute_sigmas_and_thetas( | ||
&self, | ||
z1: &Vec<G::Scalar>, | ||
z2: &Vec<G::Scalar>, | ||
z2: &[G::Scalar], |
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.
Why is this signature so different?
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.
Because now z1
is hold inside the LCCCS
instance inside the NIMFS
instance. Hence, there's no need to pass it!
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.
Maybe can add this as a comment?
Some nitpicky thoughts on the APi:
|
This is nice! Thanks! I did not see it though. Will only pass the CCS then and compute the MLEs on the fly as they just need to be computed once.
I don't have any strong feelings on this. So changing it. |
This PR moves a tep forward to the NIMFS-centric API. First, removes all the `_Witness` & `_Instance` structs for CCS & CCCS as they added a bunch of overhead. Sedonc, it also re-assembles internal fm APIs so that they ask for slices instead of refs to `Vec`. Finally, reassembles all the tests to indeed modify CCS & CCCS interaction as described avobe.
Removes CCS & CCS_MLEs from the struct as well as renaming some variables. Aside from that, the functions are being modified so that they always get the removed fields as refs.
This gets rid of conversions that made no sense from a theoretical standpoint and were overtaken by a better API design.
Since we need to generate LCCCS instances from no-where to actually be able to test things or startup the NIMFS object.
LCCCS already contains `z` inside of it. So it's non-sensical to require twice the same thing that was already served to the struct in the pass as a creation attribute.
This allows to either generate a `Multifolding` instance from all of it's params or, instead, from the first `z` and confectioning the LCCCS.
d2239ee
to
6e6bed0
Compare
This is ready to be merged with the rebase done and all comments addressed. |
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.
Partial review done, nice work with the PR ^^
I have pending to review the src/ccs/multifolding.rs and tests/nimfs.rs files, I hope to have some time this night to do it.
/// Generates a new CCCS given a reference to it's original CCS repr and it's public and private inputs. | ||
pub(crate) fn new( | ||
ccs: &CCS<G>, | ||
ccs_matrix_mle: &[MultilinearPolynomial<G::Scalar>], |
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.
How do you feel about moving let mles = ccs.matrix_mles();
inside this method and avoiding the need to pass the MultilinearPolynomials as input in this method? Or the css_matrix_mle
is carried from other upper level logic and here is just reusing that already computed data?
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.
Or the css_matrix_mle is carried from other upper level logic and here is just reusing that already computed data?
That's exactly what happens. Ideally, I'll have the mles (as well as the CCS) serialized or given by the wire. So I don't want to spend time computing MLES. Specially since the matrixes are sparse. Which has the idea to minimize memory usage.
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.
LGTM!
pub(crate) ccs: CCSShape<G>, | ||
#[derive(Clone, Debug, PartialEq, Eq /*Serialize, Deserialize*/)] | ||
//#[serde(bound(deserialize = "'de: 'a"))] | ||
pub struct CCCS<G: Group> { |
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 guess point would be to stay consistent with code base, but I don't feel super strongly about it, can see both sides
// Is our single source of data. | ||
/// The NIMFS structure is the center of operations of the folding scheme. | ||
/// Once generated, it allows us to fold any upcomming CCCS instances within it without needing to do much. | ||
// XXX: Pending to add doc examples. |
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.
Ok let's do in follow up PR so we don't forget it
src/ccs/multifolding.rs
Outdated
/// Compute sigma_i and theta_i from step 4 | ||
pub fn compute_sigmas_and_thetas( | ||
&self, | ||
z1: &Vec<G::Scalar>, | ||
z2: &Vec<G::Scalar>, | ||
z2: &[G::Scalar], |
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.
Maybe can add this as a comment?
7966341
to
4231bed
Compare
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.
regarding src/ccs/multifolding.rs.
I find interesting the idea of having the running LCCCS data as a NIMFS structure parameter, since it feels more close to the idea of having a running instance which is folded with new instances on each iteration.
One thing to note though, is that there can be multiple LCCCS instances and multiple CCCS instances being folded in a single iteration.
// Here we perform steps 7 & 8 of the section 5 of the paper. Were we actually fold LCCCS & CCCS instances. | ||
self.lcccs.w_comm += cccs.w_comm.mul(rho); | ||
self.lcccs.v = folded_v; | ||
self.lcccs.r_x = r_x_prime; | ||
self.fold_z(cccs, rho); |
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.
Maybe the instance & witness parts should be separated? in a similar way that in [multifolding-poc]((/~https://github.com/privacy-scaling-explorations/multifolding-poc/tree/d118ea56418dadde005b5854b5cbbf38a686d24d/src/multifolding.rs#L202), since later the prover has both, but the verifier does not have the witness part of the folding.
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.
hmmmm I can definitely do that. I just went that way as we were folding both things at the end and is simpler to write and forces us to hold less attributes.
In any case, I can change it if you think is better.
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 think that this will be needed, since the verifier does not have the witness part of z
. But we can do it in a future iteration, filled #46 to keep track of it.
I know. |
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.
LGTM 😸
Regarding
That's why #37 was raised. The plan was to stabilize firs the API and then upgrade to N->1
Make sense, when doing the n-to-1 fold we will need to check how to adapt the running instance to multiple of them (eg. check if it makes sense to have an array of LCCCS in the NIMFS data structure or to just pass them as parameter together with the CCCS instances). I've left a comment to #37 to have it in mind then.
// Note `z2` represents the input of the incoming CCCS instance. | ||
// As the current IVC accumulated input is holded inside of the NIMFS(`self`). | ||
z: &[G::Scalar], |
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.
maybe z2
in the comment should match z
in the code now that has been updated (or incoming_z
if finally named that way as mentioned in #41 (comment) )
This leaves pending #46 as I haven't found a good enough API abstraction and I don't want to block the merge anymore. |
Yes let's merge this and other one |
The PR introduces usage from the associated trait/type of `Group` called `TranscriptEngineTrait` to perform the Fiat-Shamir inside the multifolding for the Sigmas and Thetas computations as well as gammas. This should be rebased on the top of `main` once #41 is merged and then reviewed. As there could be places where FS should be applied but it isn't.
…plorations#41) * Enforce program counter in SuperNova StepCircuit. * Improve documentation. * Rename pseudo_pc to rom_index. * Cleanup TestROM example. --------- Co-authored-by: porcuquine <porcuquine@users.noreply.github.com>
This is a proposal for the new API of the Hypernova/multifolding current impl.
The idea is that the API is NIMFS-centric. That means, the end user only needs to deal for now with
CCS
(this can be prevented) and theNIMFS
object.The rest of interactions with
CCCS
&LCCCS
have been "masked" or at the very least, is not necessary to import these structs to have full functionallity.The current workflow that this API brings can be clearly seen here:
This is part of a test, located in /~https://github.com/privacy-scaling-explorations/Nova/blob/change%2FNIMFS_centric_API/tests/nimfs.rs
The idea is that the user needs to type as less as possible in order to get a fold done.
I would appreciate some feedback on this @arnaucube @oskarth @asn-d6