-
Notifications
You must be signed in to change notification settings - Fork 23
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
Conversation
src/protocol/mod.rs
Outdated
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"), |
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.
ModulusConversionStep::ResultXORShare2 => write!(f, "Result XOR Share 2"), | |
ModulusConversionStep::ResultXORShare2 => write!(f, "Share 0 XOR Share 1 XOR Share 2"), |
let world: TestWorld<ModulusConversionTestStep> = make_world(QueryId); | ||
let context = make_contexts(&world); |
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.
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
let b0 = rng.gen::<u8>() >= 128; | ||
let b1 = rng.gen::<u8>() >= 128; | ||
let b2 = rng.gen::<u8>() >= 128; |
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.
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>(); |
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.
ah... that's much better =)
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); |
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.
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); |
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.
let output_share = validate_and_reconstruct(f); | |
let output_share: Fp31 = validate_and_reconstruct(f); |
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); |
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.
let h1_future = gen_random1.execute(&context[1], record_id, step1, step2);
d7aa684
to
7fc29c1
Compare
7fc29c1
to
8a1d162
Compare
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`
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`
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.