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

Malicious sharded shuffle #1394

Conversation

andyleiserson
Copy link
Collaborator

No description provided.

@@ -92,7 +92,7 @@ where
let mut x_2 = x_1.clone();
add_single_shares_in_place(&mut x_2, z_31);
x_2.shuffle(&mut rng_perm_l);
send_to_peer(&x_2, ctx, &OPRFShuffleStep::TransferX2, Direction::Right).await?;
send_to_peer(&x_2, ctx, &OPRFShuffleStep::TransferXY, Direction::Right).await?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To allow interceptor reuse between the sharded and non-sharded tests, steps are renamed to make TransferXY and TransferC have the same names for OPRFShuffleStep and ShardedShuffleStep.

// The `From` and `Into` bounds are necessary to work with routines that have not been
// updated to use the `Shuffleable` trait.
pub trait Shuffleable:
From<AdditiveShare<Self::Share>> + Into<AdditiveShare<Self::Share>> + Send + 'static
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The From and Into bounds are necessary to interoperate with the malicious shuffle routines that don't understand Shuffleable yet. I have a future change that updates things to use Shuffleable and gets rid of these bounds.

(At the moment, Shuffleable is only implemented for AdditiveShare<V: BooleanArray>, so these bounds are trivially satisfied. But we want to implement Shuffleable for other types.)

@@ -288,11 +265,11 @@ where
// shared with the left helper.
let x2: Vec<S::Share> = ctx
.narrow(&ShuffleStep::Permute31)
.mask_and_shuffle(Direction::Left, &x1)
.mask_and_shuffle(Direction::Left, x1.iter().copied())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With ShuffleShare restricted to BooleanArray, it acquires Copy, which makes the Borrow generic on mask_and_shuffle that I recently added unnecessary.

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 88.44985% with 38 lines in your changes missing coverage. Please review.

Project coverage is 93.49%. Comparing base (b8a5fd1) to head (7731424).
Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
ipa-core/src/protocol/ipa_prf/shuffle/mod.rs 15.38% 22 Missing ⚠️
ipa-core/src/protocol/context/malicious.rs 0.00% 12 Missing ⚠️
ipa-core/src/protocol/ipa_prf/shuffle/malicious.rs 98.26% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1394      +/-   ##
==========================================
- Coverage   93.68%   93.49%   -0.20%     
==========================================
  Files         223      223              
  Lines       37737    38471     +734     
==========================================
+ Hits        35353    35967     +614     
- Misses       2384     2504     +120     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ipa-core/src/protocol/ipa_prf/shuffle/malicious.rs Outdated Show resolved Hide resolved
@@ -100,7 +104,7 @@ trait ShuffleContext: ShardedContext {
Direction::Right => r,
};

item.borrow().clone() + mask
item + mask
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

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 works here, but with the revised bounds in #1397 (which remove the implication that ShuffleShare is Copy), it comes back in a slightly different form.

@@ -234,12 +198,16 @@ impl<C: ShardedContext> ShuffleContext for C {}
///
/// [`ShuffleShare`] and [`Shuffleable`] are added to bridge the gap. They can be implemented for
/// arbitrary structs as long as `Add` operation can be defined on them.
pub trait ShuffleShare: Sendable + Clone + FromRandom + Add<Output = Self> {}
pub trait ShuffleShare: BooleanArray + Serializable + FromRandom {}
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 BooleanArray bound may be problematic for structs like HybridReport, would it work if we ask implementors to give us bit representation of their data? something like fn as_bytes_iter(&self) -> impl Iterator<Item = [u8; 32]>. iirc we only need it to compute MACs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that these are the trait bounds for ShuffleShare, not for Shuffleable itself (i.e. it is saying that any Shuffleable type needs to support conversion to boolean arrays, not that only boolean arrays are shuffleable). That said, after some back-and-forth with myself in #1395, I was able to arrive at a more precise set of bounds for ShuffleShare, which you can see in #1397 at line 209 of sharded.rs.

#1397 also has the implementations of Shuffleable for AttributionOutputs and OPRFIPAInputRow.

@andyleiserson andyleiserson merged commit d5cc8f8 into private-attribution:main Nov 4, 2024
12 checks passed
@andyleiserson andyleiserson deleted the malicious-sharded-shuffle branch November 4, 2024 22:54
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