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

circuits: zk-circuits: valid-match-mpc: Refactor over mpc-plonk #262

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

joeykraut
Copy link
Member

Purpose

This PR refactors the VALID MATCH MPC circuit over the mpc-plonk system. This method proves validity of a match that results from an MPC or the internal matching engine.

Note that we intend to combine this circuit with VALID SETTLE, this will come in a follow up PR.

Also deferred to a follow up are more extensive unit tests -- this circuit is tested heavily in integration tests, but given the new mocking interface for MPCs, it makes sense to test them in unit as well.

Testing

  • Unit tests pass
  • Tested prove/verify

Comment on lines -315 to -318
// Ensure all orders have boolean side
for order in new_wallet.orders.iter() {
cs.enforce_bool(order.side)?;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the type of Order::side to be boolean means this constraint is automatically generated when the type is allocated

Comment on lines -132 to -141
// Constrain the min_amount_order_index to be binary
// i.e. 0 === min_amount_order_index * (1 - min_amount_order_index)
let (_, _, mul_out) = cs
.multiply(
&witness.match_res.min_amount_order_index.clone().into(),
&(MpcLinearCombination::from_scalar(Scalar::one(), fabric.clone())
- &witness.match_res.min_amount_order_index),
)
.map_err(ProverError::Collaborative)?;
cs.constrain(mul_out.into());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, changing the type to bool automatically generates this constraint

@joeykraut joeykraut force-pushed the joey/valid-match-refactor branch from 66bd583 to 9b13760 Compare November 21, 2023 17:32
@joeykraut joeykraut marked this pull request as ready for review November 21, 2023 17:32
@joeykraut joeykraut requested a review from akirillo November 21, 2023 17:32
@joeykraut joeykraut merged commit e3dc976 into joey/circuits-refactor Nov 21, 2023
1 of 4 checks passed
@joeykraut joeykraut deleted the joey/valid-match-refactor branch November 21, 2023 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants