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

Mod conversion [Part 1] #110

Merged
merged 9 commits into from
Oct 14, 2022
Merged

Mod conversion [Part 1] #110

merged 9 commits into from
Oct 14, 2022

Conversation

benjaminsavage
Copy link
Collaborator

To convert from XOR secret shares of match keys, the lists of replicated secret sharings of each bit in Z_p, we will need to generate pairs of secret sharings of "r", a random number not known to any of the helpers.

This diff introduces code that given a binary replicated secret sharing of "r" (which can be locally generated using PRSS), converts that into a replicated secret sharing of the same value in Z_p. This is the main work involved in the modulus conversion.

There are additional optimisations to add later.

src/protocol/context.rs Show resolved Hide resolved
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
ModulusConversionStep::Share0XORShare1 => write!(f, "Share 0 XOR Share 1"),
ModulusConversionStep::ResultXORShare2 => write!(f, "Result XOR Share 2"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ModulusConversionStep::ResultXORShare2 => write!(f, "Result XOR Share 2"),
ModulusConversionStep::ResultXORShare2 => write!(f, "Share 0 XOR Share 1 XOR Share 2"),

Comment on lines 134 to 135
let world: TestWorld<ModulusConversionTestStep> = make_world(QueryId);
let context = make_contexts(&world);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this what causes this test to run for 5 secs on my M1. You could move this initialization outside of the main loop and that would significantly speed up the runtime without sacrificing correctness

Comment on lines 146 to 148
let b0 = rng.gen::<u8>() >= 128;
let b1 = rng.gen::<u8>() >= 128;
let b2 = rng.gen::<u8>() >= 128;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let b0 = rng.gen::<u8>() >= 128;
let b1 = rng.gen::<u8>() >= 128;
let b2 = rng.gen::<u8>() >= 128;
let b0 = rng.gen::<bool>();
let b1 = rng.gen::<bool>();
let b2 = rng.gen::<bool>();

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah... that's much better =)

src/protocol/modulus_conversion/gen_random.rs Show resolved Hide resolved
let gen_random2 = GenRandom::new(ReplicatedBinary::new(b2, b0));

let h0_future = gen_random0.execute(&context[0], record_id, step1, step2);
let h1_future = gen_random1.execute::<Fp31, TestMesh<ModulusConversionTestStep>, TestHelperGateway<ModulusConversionTestStep>, ModulusConversionTestStep>(&context[1], record_id, step1, step2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let h1_future = gen_random1.execute::<Fp31, TestMesh<ModulusConversionTestStep>, TestHelperGateway<ModulusConversionTestStep>, ModulusConversionTestStep>(&context[1], record_id, step1, step2);
let h1_future = gen_random1.execute(&context[1], record_id, step1, step2);

I think the only parameter that is ambiguous is the field type, so if we explicitly set it on the line 161, we don't need to specify all the types here

let h2_future = gen_random2.execute(&context[2], record_id, step1, step2);

let f = try_join!(h0_future, h1_future, h2_future).unwrap();
let output_share = validate_and_reconstruct(f);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let output_share = validate_and_reconstruct(f);
let output_share: Fp31 = validate_and_reconstruct(f);

src/protocol/modulus_conversion/gen_random.rs Outdated Show resolved Hide resolved
src/protocol/modulus_conversion/gen_random.rs Show resolved Hide resolved
src/protocol/modulus_conversion/gen_random.rs Show resolved Hide resolved
src/protocol/modulus_conversion/gen_random.rs Show resolved Hide resolved
let gen_random2 = GenRandom::new(ReplicatedBinary::new(b2, b0));

let h0_future = gen_random0.execute(&context[0], record_id, step1, step2);
let h1_future = gen_random1.execute::<Fp31, TestMesh<ModulusConversionTestStep>, TestHelperGateway<ModulusConversionTestStep>, ModulusConversionTestStep>(&context[1], record_id, step1, step2);
Copy link
Contributor

Choose a reason for hiding this comment

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

let h1_future = gen_random1.execute(&context[1], record_id, step1, step2);

src/protocol/modulus_conversion/gen_random.rs Show resolved Hide resolved
@benjaminsavage benjaminsavage merged commit 5b820f7 into main Oct 14, 2022
@benjaminsavage benjaminsavage deleted the mod_conversion branch October 14, 2022 00:36
akoshelev added a commit to akoshelev/raw-ipa that referenced this pull request Oct 16, 2022
Given the conversation in private-attribution#110 [comment](https://github.com/martinthomson/raw-ipa/pull/110/files#r992706026) we don't seem to need to dynamically change the identities of helpers dynamically. Therefore we don't need to force client code to obtain a reference to the channel first.

The standard way to access helper identity should be via `ProtocolContext` and, in some cases, via `Gateway`
akoshelev added a commit to akoshelev/raw-ipa that referenced this pull request Oct 16, 2022
Given the conversation in private-attribution#110 [comment](https://github.com/martinthomson/raw-ipa/pull/110/files#r992706026) we don't seem to need to dynamically change the identities of helpers dynamically. Therefore we don't need to force client code to obtain a reference to the channel first.

The standard way to access helper identity should be via `ProtocolContext` and, in some cases, via `Gateway`
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.

None yet

4 participants