Skip to content
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

Make closure of challenge phase FnOnce. #276

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/r1cs/constraint_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub trait RandomizableConstraintSystem: ConstraintSystem {
/// ```
fn specify_randomized_constraints<F>(&mut self, callback: F) -> Result<(), R1CSError>
where
F: 'static + Fn(&mut Self::RandomizedCS) -> Result<(), R1CSError>;
F: 'static + FnOnce(&mut Self::RandomizedCS) -> Result<(), R1CSError>;
}

/// Represents a constraint system in the second phase:
Expand Down
5 changes: 3 additions & 2 deletions src/r1cs/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ pub struct Prover<'g, T: BorrowMut<Transcript>> {

/// This list holds closures that will be called in the second phase of the protocol,
/// when non-randomized variables are committed.
deferred_constraints: Vec<Box<dyn Fn(&mut RandomizingProver<'g, T>) -> Result<(), R1CSError>>>,
deferred_constraints:
Vec<Box<dyn FnOnce(&mut RandomizingProver<'g, T>) -> Result<(), R1CSError>>>,

/// Index of a pending multiplier that's not fully assigned yet.
pending_multiplier: Option<usize>,
Expand Down Expand Up @@ -182,7 +183,7 @@ impl<'g, T: BorrowMut<Transcript>> RandomizableConstraintSystem for Prover<'g, T

fn specify_randomized_constraints<F>(&mut self, callback: F) -> Result<(), R1CSError>
where
F: 'static + Fn(&mut Self::RandomizedCS) -> Result<(), R1CSError>,
F: 'static + FnOnce(&mut Self::RandomizedCS) -> Result<(), R1CSError>,
{
self.deferred_constraints.push(Box::new(callback));
Ok(())
Expand Down
5 changes: 3 additions & 2 deletions src/r1cs/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ pub struct Verifier<T: BorrowMut<Transcript>> {
/// when non-randomized variables are committed.
/// After that, the option will flip to None and additional calls to `randomize_constraints`
/// will invoke closures immediately.
deferred_constraints: Vec<Box<dyn Fn(&mut RandomizingVerifier<T>) -> Result<(), R1CSError>>>,
deferred_constraints:
Vec<Box<dyn FnOnce(&mut RandomizingVerifier<T>) -> Result<(), R1CSError>>>,

/// Index of a pending multiplier that's not fully assigned yet.
pending_multiplier: Option<usize>,
Expand Down Expand Up @@ -134,7 +135,7 @@ impl<T: BorrowMut<Transcript>> RandomizableConstraintSystem for Verifier<T> {

fn specify_randomized_constraints<F>(&mut self, callback: F) -> Result<(), R1CSError>
where
F: 'static + Fn(&mut Self::RandomizedCS) -> Result<(), R1CSError>,
F: 'static + FnOnce(&mut Self::RandomizedCS) -> Result<(), R1CSError>,
{
self.deferred_constraints.push(Box::new(callback));
Ok(())
Expand Down