-
Notifications
You must be signed in to change notification settings - Fork 37
clean up secondary circuit #16
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 all commits
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 |
|---|---|---|
|
|
@@ -259,7 +259,7 @@ where | |
| pub fn iter_base_step<C1: StepCircuit<G1::Scalar>, C2: StepCircuit<G2::Scalar>>( | ||
| claim: &RunningClaim<G1, G2, C1, C2>, | ||
| pp_digest: G1::Scalar, | ||
| initial_program_counter: G1::Scalar, | ||
| initial_program_counter: Option<G1::Scalar>, | ||
| first_augmented_circuit_index: usize, | ||
| num_augmented_circuits: usize, | ||
| z0_primary: &[G1::Scalar], | ||
|
|
@@ -329,7 +329,7 @@ where | |
| None, | ||
| Some(&u_primary), | ||
| None, | ||
| G2::Scalar::ZERO, // secondary circuit never constrain/bump program counter | ||
| None, | ||
| G2::Scalar::from(claim.augmented_circuit_index as u64), | ||
| ); | ||
| let circuit_secondary: SuperNovaAugmentedCircuit<'_, G1, C2> = SuperNovaAugmentedCircuit::new( | ||
|
|
@@ -379,6 +379,7 @@ where | |
| }) | ||
| .collect::<Result<Vec<<G1 as Group>::Scalar>, SuperNovaError>>()?; | ||
| let zi_primary_pc_next = zi_primary_pc_next | ||
| .expect("zi_primary_pc_next missing") | ||
| .get_value() | ||
| .ok_or(SuperNovaError::NovaError(NovaError::SynthesisError))?; | ||
| let zi_secondary = zi_secondary | ||
|
|
@@ -473,7 +474,7 @@ where | |
| Some(&self.r_U_secondary), | ||
| Some(&self.l_u_secondary), | ||
| Some(&T), | ||
| self.program_counter, | ||
| Some(self.program_counter), | ||
| G1::Scalar::ZERO, | ||
| ); | ||
|
|
||
|
|
@@ -540,7 +541,7 @@ where | |
| Some(&self.r_U_primary), | ||
| Some(&l_u_primary), | ||
| Some(&binding), | ||
| G2::Scalar::ZERO, // secondary circuit never constrain/bump program counter | ||
| None, | ||
| G2::Scalar::from(claim.get_augmented_circuit_index() as u64), | ||
| ); | ||
|
|
||
|
|
@@ -573,6 +574,7 @@ where | |
| }) | ||
| .collect::<Result<Vec<<G1 as Group>::Scalar>, SuperNovaError>>()?; | ||
| let zi_primary_pc_next = zi_primary_pc_next | ||
| .expect("zi_primary_pc_next missing") | ||
| .get_value() | ||
| .ok_or(SuperNovaError::NovaError(NovaError::SynthesisError))?; | ||
| let zi_secondary = zi_secondary | ||
|
|
@@ -659,7 +661,7 @@ where | |
|
|
||
| // secondary circuit | ||
| let num_field_secondary_ro = 2 // params_next, i_new | ||
| + 2 * pp.F_arity_primary // zo, z1 | ||
| + 2 * pp.F_arity_secondary // zo, z1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice 👍 |
||
| + self.num_augmented_circuits * (7 + 2 * pp.augmented_circuit_params_primary.get_n_limbs()); // #num_augmented_circuits * (7 + [X0, X1]*#num_limb) | ||
|
|
||
| let (hash_primary, hash_secondary) = { | ||
|
|
@@ -810,3 +812,14 @@ where | |
|
|
||
| (ck_primary, ck_secondary) | ||
| } | ||
|
|
||
| /// SuperNova helper trait, for implementors that provide sets of sub-circuits to be proved via NIVC. | ||
| pub trait CircuitSet<G: Group> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you looking for an heterogeneous list (or more likely
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, but this trait will end up doing some heavy lifting, and it's not really clear yet what it needs to look like. The above is just a first foot in the door. I will iterate in future revisions and bear your ideas in mind. |
||
| /// Initial program counter, defaults to zero. | ||
| fn initial_program_counter(&self) -> G::Scalar { | ||
| G::Scalar::ZERO | ||
| } | ||
|
|
||
| /// How many augmented circuits are provided? | ||
| fn num_augmented_circuits(&self) -> usize; | ||
| } | ||
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 a panic rather than
SynthesisError::AssignementMissing?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's because of the extremely confusing convention of how
Optionis overloaded in the bellman line of circuit-generation (phrased thus because maybe bellpepper will eventually help clean this up). Specifically, if inputs are missing (meaning we are synthesizing a blank shape), then the.get()?on line 185 will indeed result in theSynthesisError::AssignmentMissing. However, if that doesn't happen and inputs have been supplied, then those inputs are either for a primary or secondary circuit. In the secondary case, the program counter will not be present. However, in this code branch, we are specifically handling a primary circuit — so we require the actual value for the witness.