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

feature: pre-garbling #79

Merged
merged 5 commits into from
Oct 24, 2023
Merged

feature: pre-garbling #79

merged 5 commits into from
Oct 24, 2023

Conversation

sinui0
Copy link
Collaborator

@sinui0 sinui0 commented Oct 19, 2023

This PR implements "pre-garbling", aka the offline-online paradigm, for garbled circuits.

Changes

  • Adds the Load trait, an abstraction of this feature
  • Modifies the Generator and Evaluator to support transferring of the encrypted gates prior to execution
  • Implements Load for DEAPVM

@sinui0 sinui0 requested review from themighty1 and th4s October 19, 2023 01:51
@sinui0 sinui0 linked an issue Oct 19, 2023 that may be closed by this pull request
Copy link
Member

@th4s th4s left a comment

Choose a reason for hiding this comment

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

Nice 🚀

@@ -60,6 +61,10 @@ struct State {
received_values: HashMap<ValueId, ValueType>,
/// Values which have been decoded
decoded_values: HashSet<ValueId>,
/// Pre-transferred garbled circuits
///
/// (inputs, outputs) => garbled circuit
Copy link
Member

Choose a reason for hiding this comment

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

I do not understand this comment line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is just indicating that the inputs + outputs are used to map to the garbled circuit if it exists

Copy link
Member

Choose a reason for hiding this comment

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

Ok, then maybe

Suggested change
/// (inputs, outputs) => garbled circuit
/// inputs and outputs from `receive_garbled_circuit` are used for one of the circuits from `garbled_circuits`

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is pretty verbose 🙃

Copy link
Member

Choose a reason for hiding this comment

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

That's true. Do you have a shorter but more understandable idea? I do not think that the current comment is easily understandable, because I looked for input and output in the state variables, could not find them and was confused.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe worth emphaizing that (inputs, outputs) is unique to each circuit by making the comment

// A map used to look up a garbled circuit by its unique (inputs, outputs) reference.

garble/mpz-garble/src/evaluator/mod.rs Outdated Show resolved Hide resolved
garble/mpz-garble/src/generator/mod.rs Show resolved Hide resolved
@sinui0 sinui0 force-pushed the feature/pre-garble-2 branch 2 times, most recently from 7168ba5 to 7669232 Compare October 19, 2023 22:58
garble/mpz-garble/src/generator/mod.rs Show resolved Hide resolved
@@ -60,6 +61,10 @@ struct State {
received_values: HashMap<ValueId, ValueType>,
/// Values which have been decoded
decoded_values: HashSet<ValueId>,
/// Pre-transferred garbled circuits
///
/// (inputs, outputs) => garbled circuit
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe worth emphaizing that (inputs, outputs) is unique to each circuit by making the comment

// A map used to look up a garbled circuit by its unique (inputs, outputs) reference.

garble/mpz-garble/src/generator/mod.rs Show resolved Hide resolved
@@ -229,8 +242,29 @@ impl Generator {
sink: &mut S,
hash: bool,
) -> Result<(Vec<EncodedValue<encoding_state::Full>>, Option<Hash>), GeneratorError> {
let refs = CircuitRefs {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like for the same inputs/outputs we may be getting different 'CircuitRefs' if they are passed in a different order.

Copy link
Collaborator Author

@sinui0 sinui0 Oct 24, 2023

Choose a reason for hiding this comment

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

Yes that is true, this order dependence exists elsewhere in the codebase as well. I'm going to punt that out of scope of this PR tho. This is not a security issue but could cause a "cache-miss" or a deadlock

garble/mpz-garble/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@themighty1 themighty1 left a comment

Choose a reason for hiding this comment

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

lgtm, a fix maybe needed

Base automatically changed from refactor/vm-memory to dev October 24, 2023 19:48
@sinui0 sinui0 force-pushed the feature/pre-garble-2 branch from 7669232 to c1e39f9 Compare October 24, 2023 19:55
@sinui0 sinui0 merged commit af36089 into dev Oct 24, 2023
3 checks passed
@sinui0 sinui0 deleted the feature/pre-garble-2 branch October 24, 2023 20:00
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.

Support pre-transferring garbled circuit gates
3 participants