Skip to content

Commit

Permalink
Merge branch 'main' into dot_product
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminsavage committed Oct 9, 2023
2 parents 3ccef7b + bb1d517 commit 9bdff21
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 74 deletions.
5 changes: 3 additions & 2 deletions ipa-macros/src/derive_step/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,9 @@ fn get_meta_data_for(
ident,
"ipa_macros::step expects an enum with variants that match the steps in \
steps.txt. If you've made a change to steps, make sure to run `collect_steps.py` \
and replace steps.txt with the output. If the step is not a part of the protocol, \
consider removing it.",
and replace steps.txt with the output. If the step is not a part of the protocol \
yet, you can temporarily hide the step or the module containing the step with \
`#[cfg(feature = \"descriptive-gate\")]`.",
))
}
1 => {
Expand Down
33 changes: 0 additions & 33 deletions scripts/collect_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,7 @@
DEPTH_DYNAMIC_STEPS = [
"ipa::protocol::attribution::InteractionPatternStep",
]
# Same here. There are steps that are executed depending on the number of bits in the
# used field.
BIT_DYNAMIC_STEPS = [
"ipa::protocol::attribution::aggregate_credit::Step::compute_equality_checks",
"ipa::protocol::attribution::aggregate_credit::Step::check_times_credit",
]
# another one for modulus conversion
MODULUS_CONVERSION_DYNAMIC_STEPS = [
"ipa::protocol::sort::SortStep::convert",
"ipa::protocol::attribution::AttributionStep::convert_helper_bits",
"ipa::protocol::boolean::solved_bits::Step::random_bits",
"ipa::protocol::attribution::aggregate_credit::Step::mod_conv_breakdown_key_bits",
]
MAXIMUM_DEPTH = 32
MAXIMUM_BIT_LENGTH = 32
MAXIMUM_CONVERT_BIT_LENGTH = 64


def set_env():
Expand All @@ -82,8 +67,6 @@ def remove_root_step_name_from_line(l):
def collect_steps(args):
output = set()
depth_dynamic_steps = set()
bit_dynamic_steps = set()
modulus_conversion_dynamic_steps = set()

proc = subprocess.Popen(
args=args,
Expand Down Expand Up @@ -111,14 +94,6 @@ def collect_steps(args):
depth_dynamic_steps.add(remove_root_step_name_from_line(line))
# continue without adding to the `output`. we'll generate the dynamic steps later
continue
if any(s in line for s in BIT_DYNAMIC_STEPS):
line = re.sub(r"bit\d+", "bitX", line)
bit_dynamic_steps.add(remove_root_step_name_from_line(line))
continue
if any(s in line for s in MODULUS_CONVERSION_DYNAMIC_STEPS):
line = re.sub(r"mc\d+", "mcX", line)
modulus_conversion_dynamic_steps.add(remove_root_step_name_from_line(line))
continue

output.update([remove_root_step_name_from_line(line)])

Expand All @@ -132,14 +107,6 @@ def collect_steps(args):
for s in depth_dynamic_steps:
line = re.sub(r"depthX", "depth" + str(i), s)
output.add(line)
for i in range(MAXIMUM_BIT_LENGTH):
for s in bit_dynamic_steps:
line = re.sub(r"bitX", "bit" + str(i), s)
output.add(line)
for i in range(MAXIMUM_CONVERT_BIT_LENGTH):
for s in modulus_conversion_dynamic_steps:
line = re.sub(r"mcX", "mc" + str(i), s)
output.add(line)

return output

Expand Down
1 change: 1 addition & 0 deletions src/ff/prime_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ macro_rules! field_impl {
proptest! {

#[test]
#[allow(clippy::ignored_unit_patterns)]
fn serde(v in 0..$field::PRIME) {
let field_v = $field(v);
let mut buf = GenericArray::default();
Expand Down
6 changes: 5 additions & 1 deletion src/helpers/buffers/ordering_mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ mod fixture {

#[async_trait]
impl TestSender for OrderingMpscSender<Fp32BitPrime> {
// I don't understand what triggers this warning, maybe https://github.com/rust-lang/rust-clippy/issues/11403
#[allow(clippy::ignored_unit_patterns)]
async fn send_test(&self, i: usize) {
self.send(
i,
Expand Down Expand Up @@ -383,7 +385,7 @@ mod unit {
let send = async move {
tx_a.send(0, input).await.unwrap();
};
let (_, output) = join(send, rx.take_next(1)).await;
let ((), output) = join(send, rx.take_next(1)).await;
assert_eq!(
input,
Fp31::deserialize(GenericArray::from_slice(output.as_ref().unwrap()))
Expand Down Expand Up @@ -506,6 +508,7 @@ mod proptests {

proptest::proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_size_seq(cap in 2..1000_usize) {
let indices = (0..cap).collect::<Vec<_>>();
tokio::runtime::Builder::new_multi_thread()
Expand All @@ -516,6 +519,7 @@ mod proptests {
}

#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_size_shuffle(indices in shuffled(), excess in 0..10_usize) {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/buffers/ordering_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ mod test {
values.resize_with(COUNT, || rng.gen::<Fp32BitPrime>());

let sender = sender();
let (_, _, output) = join3(
let (_, (), output) = join3(
join_all(values.iter().enumerate().map(|(i, &v)| sender.send(i, v))),
sender.close(values.len()),
sender.as_stream().collect::<Vec<_>>(),
Expand Down Expand Up @@ -568,7 +568,7 @@ mod test {
let indices = shuffle_indices(COUNT);

let sender = sender();
let (_, _, output) = join3(
let (_, (), output) = join3(
join_all(indices.into_iter().map(|i| sender.send(i, values[i]))),
sender.close(values.len()),
sender.as_stream().collect::<Vec<_>>(),
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/gateway/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ mod tests {

let world = TestWorld::new_with(config);
world
.semi_honest((), |ctx, _| async move {
.semi_honest((), |ctx, ()| async move {
let fp2_ctx = ctx.narrow("fp2").set_total_records(100);
let fp32_ctx = ctx.narrow("fp32").set_total_records(100);
let role = ctx.role();
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/prss_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub async fn negotiate<T: Transport, R: RngCore + CryptoRng>(
let (send_left_pk, send_right_pk) = ep_setup.public_keys();
let record_id = RecordId::FIRST;

let (_, _, recv_left_pk, recv_right_pk) = try_join4(
let ((), (), recv_left_pk, recv_right_pk) = try_join4(
left_sender.send(record_id, send_left_pk),
right_sender.send(record_id, send_right_pk),
left_receiver.receive(record_id),
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/transport/stream/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ mod test {

proptest::proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn test_records_stream_works_with_any_chunks(
(expected_bytes, chunked_bytes, _seed) in arb_expected_and_chunked_body(30, 100)
) {
Expand Down Expand Up @@ -820,6 +821,7 @@ mod test {

proptest::proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn test_delimited_stream_works_with_any_chunks(
(expected_items, chunked_bytes, _seed) in arb_expected_and_chunked_body(100)
) {
Expand Down
3 changes: 3 additions & 0 deletions src/hpke/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ mod tests {
proptest::proptest! {
#![proptest_config(ProptestConfig::with_cases(50))]
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_ct_corruption(bad_byte in 0..23_usize, bad_bit in 0..7_usize, seed: [u8; 32]) {
let rng = StdRng::from_seed(seed);
let mut suite = EncryptionSuite::new(1, rng);
Expand All @@ -372,6 +373,7 @@ mod tests {
proptest::proptest! {
#![proptest_config(ProptestConfig::with_cases(50))]
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_enc_corruption(bad_byte in 0..32_usize, bad_bit in 0..7_usize, seed: [u8; 32]) {
let rng = StdRng::from_seed(seed);
let mut suite = EncryptionSuite::new(1, rng);
Expand Down Expand Up @@ -416,6 +418,7 @@ mod tests {
proptest::proptest! {
#![proptest_config(ProptestConfig::with_cases(50))]
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn arbitrary_info_corruption(corrupted_info_field in 1..5,
site_domain in "[a-z]{10}",
helper_origin in "[a-z]{10}",
Expand Down
2 changes: 2 additions & 0 deletions src/protocol/boolean/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ mod tests {

proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn gt_fp31_proptest(a in 0..Fp31::PRIME, c in 0..Fp31::PRIME) {
type F = Fp31;
let r = thread_rng().gen::<F>();
Expand All @@ -566,6 +567,7 @@ mod tests {
}

#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn gt_fp_32bit_prime_proptest(a in 0..Fp32BitPrime::PRIME, c in 0..Fp32BitPrime::PRIME) {
type F = Fp32BitPrime;
let r = thread_rng().gen::<F>();
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/boolean/random_bits_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ mod tests {

for _ in 0..OUTER {
let v = world
.semi_honest((), |ctx, _| async move {
.semi_honest((), |ctx, ()| async move {
let validator = ctx.validator();
let ctx = validator
.context()
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ mod tests {

let send_channel = ctx.send_channel(left_peer);
let recv_channel = ctx.recv_channel::<F>(right_peer);
let (_, right_share) = try_join!(
let ((), right_share) = try_join!(
send_channel.send(record_id, share.l() - l - seq_l),
recv_channel.receive(record_id),
)
Expand Down
1 change: 1 addition & 0 deletions src/protocol/dp/insecure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ mod test {
proptest! {
#![proptest_config(ProptestConfig::with_cases(50))]
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn output_differentially_private(
rng_seed: u64,
epsilon in 1..255_u8,
Expand Down
1 change: 1 addition & 0 deletions src/protocol/ipa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ pub mod tests {

proptest! {
#[test]
#[allow(clippy::ignored_unit_patterns)] // https://github.com/proptest-rs/proptest/issues/371
fn serde(timestamp in 0..u128::MAX, match_key in 0..u64::MAX, trigger_bit in 0..u128::MAX, breakdown_key in 0..u128::MAX, trigger_value in 0..u128::MAX, seed in 0..u128::MAX) {
serde_internal::<Fp31>(timestamp, match_key, trigger_bit, breakdown_key, trigger_value, seed);
serde_internal::<Fp32BitPrime>(timestamp, match_key, trigger_bit, breakdown_key, trigger_value, seed);
Expand Down
Loading

0 comments on commit 9bdff21

Please sign in to comment.