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

Add context string to VDAF #1145

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions benches/cycle_counts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ fn prio2_client(size: usize) -> Vec<Share<FieldPrio2, 32>> {
let prio2 = Prio2::new(size).unwrap();
let input = vec![0u32; size];
let nonce = [0; 16];
prio2.shard(&black_box(input), &black_box(nonce)).unwrap().1
prio2
.shard(b"", &black_box(input), &black_box(nonce))
.unwrap()
.1
}

#[cfg(feature = "experimental")]
Expand All @@ -70,9 +73,19 @@ fn prio2_shard_and_prepare(size: usize) -> Prio2PrepareShare {
let prio2 = Prio2::new(size).unwrap();
let input = vec![0u32; size];
let nonce = [0; 16];
let (public_share, input_shares) = prio2.shard(&black_box(input), &black_box(nonce)).unwrap();
let (public_share, input_shares) = prio2
.shard(b"", &black_box(input), &black_box(nonce))
.unwrap();
prio2
.prepare_init(&[0; 32], 0, &(), &nonce, &public_share, &input_shares[0])
.prepare_init(
&[0; 32],
b"",
0,
&(),
&nonce,
&public_share,
&input_shares[0],
)
.unwrap()
.1
}
Expand All @@ -97,7 +110,7 @@ fn prio3_client_count() -> Vec<Prio3InputShare<Field64, 16>> {
let measurement = true;
let nonce = [0; 16];
prio3
.shard(&black_box(measurement), &black_box(nonce))
.shard(b"", &black_box(measurement), &black_box(nonce))
.unwrap()
.1
}
Expand All @@ -107,7 +120,7 @@ fn prio3_client_histogram_10() -> Vec<Prio3InputShare<Field128, 16>> {
let measurement = 9;
let nonce = [0; 16];
prio3
.shard(&black_box(measurement), &black_box(nonce))
.shard(b"", &black_box(measurement), &black_box(nonce))
.unwrap()
.1
}
Expand All @@ -117,7 +130,7 @@ fn prio3_client_sum_32() -> Vec<Prio3InputShare<Field128, 16>> {
let measurement = 1337;
let nonce = [0; 16];
prio3
.shard(&black_box(measurement), &black_box(nonce))
.shard(b"", &black_box(measurement), &black_box(nonce))
.unwrap()
.1
}
Expand All @@ -128,7 +141,7 @@ fn prio3_client_count_vec_1000() -> Vec<Prio3InputShare<Field128, 16>> {
let measurement = vec![0; len];
let nonce = [0; 16];
prio3
.shard(&black_box(measurement), &black_box(nonce))
.shard(b"", &black_box(measurement), &black_box(nonce))
.unwrap()
.1
}
Expand All @@ -140,7 +153,7 @@ fn prio3_client_count_vec_multithreaded_1000() -> Vec<Prio3InputShare<Field128,
let measurement = vec![0; len];
let nonce = [0; 16];
prio3
.shard(&black_box(measurement), &black_box(nonce))
.shard(b"", &black_box(measurement), &black_box(nonce))
.unwrap()
.1
}
Expand Down
117 changes: 83 additions & 34 deletions benches/speed_tests.rs
rozbb marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn prio2(c: &mut Criterion) {
.map(|i| i & 1)
.collect::<Vec<_>>();
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
},
);
}
Expand All @@ -145,10 +145,18 @@ fn prio2(c: &mut Criterion) {
.collect::<Vec<_>>();
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 32]);
let (public_share, input_shares) = vdaf.shard(&measurement, &nonce).unwrap();
let (public_share, input_shares) = vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(&verify_key, 0, &(), &nonce, &public_share, &input_shares[0])
.unwrap();
vdaf.prepare_init(
&verify_key,
b"",
0,
&(),
&nonce,
&public_share,
&input_shares[0],
)
.unwrap();
});
},
);
Expand All @@ -164,18 +172,26 @@ fn prio3(c: &mut Criterion) {
let vdaf = Prio3::new_count(num_shares).unwrap();
let measurement = black_box(true);
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
});

c.bench_function("prio3count_prepare_init", |b| {
let vdaf = Prio3::new_count(num_shares).unwrap();
let measurement = black_box(true);
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) = vdaf.shard(&measurement, &nonce).unwrap();
let (public_share, input_shares) = vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(&verify_key, 0, &(), &nonce, &public_share, &input_shares[0])
.unwrap()
vdaf.prepare_init(
&verify_key,
b"",
0,
&(),
&nonce,
&public_share,
&input_shares[0],
)
.unwrap()
});
});

Expand All @@ -185,7 +201,7 @@ fn prio3(c: &mut Criterion) {
let vdaf = Prio3::new_sum(num_shares, *bits).unwrap();
let measurement = (1 << bits) - 1;
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
});
}
group.finish();
Expand All @@ -197,10 +213,18 @@ fn prio3(c: &mut Criterion) {
let measurement = (1 << bits) - 1;
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) = vdaf.shard(&measurement, &nonce).unwrap();
let (public_share, input_shares) = vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(&verify_key, 0, &(), &nonce, &public_share, &input_shares[0])
.unwrap()
vdaf.prepare_init(
&verify_key,
b"",
0,
&(),
&nonce,
&public_share,
&input_shares[0],
)
.unwrap()
});
});
}
Expand All @@ -217,7 +241,7 @@ fn prio3(c: &mut Criterion) {
.map(|i| i & 1)
.collect::<Vec<_>>();
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
},
);
}
Expand All @@ -240,7 +264,7 @@ fn prio3(c: &mut Criterion) {
.map(|i| i & 1)
.collect::<Vec<_>>();
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
},
);
}
Expand All @@ -259,10 +283,18 @@ fn prio3(c: &mut Criterion) {
.collect::<Vec<_>>();
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) = vdaf.shard(&measurement, &nonce).unwrap();
let (public_share, input_shares) = vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(&verify_key, 0, &(), &nonce, &public_share, &input_shares[0])
.unwrap()
vdaf.prepare_init(
&verify_key,
b"",
0,
&(),
&nonce,
&public_share,
&input_shares[0],
)
.unwrap()
});
},
);
Expand All @@ -287,7 +319,8 @@ fn prio3(c: &mut Criterion) {
.collect::<Vec<_>>();
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) = vdaf.shard(&measurement, &nonce).unwrap();
let (public_share, input_shares) =
vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(
&verify_key,
Expand Down Expand Up @@ -323,7 +356,7 @@ fn prio3(c: &mut Criterion) {
let vdaf = Prio3::new_histogram(num_shares, *input_length, *chunk_length).unwrap();
let measurement = black_box(0);
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
},
);
}
Expand Down Expand Up @@ -352,7 +385,7 @@ fn prio3(c: &mut Criterion) {
.unwrap();
let measurement = black_box(0);
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
},
);
}
Expand All @@ -378,10 +411,18 @@ fn prio3(c: &mut Criterion) {
let measurement = black_box(0);
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) = vdaf.shard(&measurement, &nonce).unwrap();
let (public_share, input_shares) = vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(&verify_key, 0, &(), &nonce, &public_share, &input_shares[0])
.unwrap()
vdaf.prepare_init(
&verify_key,
b"",
0,
&(),
&nonce,
&public_share,
&input_shares[0],
)
.unwrap()
});
},
);
Expand Down Expand Up @@ -412,7 +453,8 @@ fn prio3(c: &mut Criterion) {
let measurement = black_box(0);
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) = vdaf.shard(&measurement, &nonce).unwrap();
let (public_share, input_shares) =
vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(
&verify_key,
Expand Down Expand Up @@ -448,7 +490,7 @@ fn prio3(c: &mut Criterion) {
let mut measurement = vec![FP16_ZERO; *dimension];
measurement[0] = FP16_HALF;
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
},
);
}
Expand All @@ -468,7 +510,7 @@ fn prio3(c: &mut Criterion) {
let mut measurement = vec![FP16_ZERO; *dimension];
measurement[0] = FP16_HALF;
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
},
);
}
Expand All @@ -487,10 +529,12 @@ fn prio3(c: &mut Criterion) {
measurement[0] = FP16_HALF;
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) = vdaf.shard(&measurement, &nonce).unwrap();
let (public_share, input_shares) =
vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(
&verify_key,
b"",
0,
&(),
&nonce,
Expand Down Expand Up @@ -520,10 +564,11 @@ fn prio3(c: &mut Criterion) {
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) =
vdaf.shard(&measurement, &nonce).unwrap();
vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(
&verify_key,
b"",
0,
&(),
&nonce,
Expand All @@ -549,7 +594,7 @@ fn prio3(c: &mut Criterion) {
let mut measurement = vec![FP32_ZERO; *dimension];
measurement[0] = FP32_HALF;
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
},
);
}
Expand All @@ -569,7 +614,7 @@ fn prio3(c: &mut Criterion) {
let mut measurement = vec![FP32_ZERO; *dimension];
measurement[0] = FP32_HALF;
let nonce = black_box([0u8; 16]);
b.iter(|| vdaf.shard(&measurement, &nonce).unwrap());
b.iter(|| vdaf.shard(b"", &measurement, &nonce).unwrap());
},
);
}
Expand All @@ -588,10 +633,12 @@ fn prio3(c: &mut Criterion) {
measurement[0] = FP32_HALF;
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) = vdaf.shard(&measurement, &nonce).unwrap();
let (public_share, input_shares) =
vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(
&verify_key,
b"",
0,
&(),
&nonce,
Expand Down Expand Up @@ -621,10 +668,11 @@ fn prio3(c: &mut Criterion) {
let nonce = black_box([0u8; 16]);
let verify_key = black_box([0u8; 16]);
let (public_share, input_shares) =
vdaf.shard(&measurement, &nonce).unwrap();
vdaf.shard(b"", &measurement, &nonce).unwrap();
b.iter(|| {
vdaf.prepare_init(
&verify_key,
b"",
0,
&(),
&nonce,
Expand Down Expand Up @@ -724,7 +772,7 @@ fn poplar1(c: &mut Criterion) {
let measurement = IdpfInput::from_bools(&bits);

b.iter(|| {
vdaf.shard(&measurement, &nonce).unwrap();
vdaf.shard(b"", &measurement, &nonce).unwrap();
});
});
}
Expand Down Expand Up @@ -753,7 +801,7 @@ fn poplar1(c: &mut Criterion) {
// We are benchmarking preparation of a single report. For this test, it doesn't matter
// which measurement we generate a report for, so pick the first measurement
// arbitrarily.
let (public_share, input_shares) = vdaf.shard(&measurements[0], &nonce).unwrap();
let (public_share, input_shares) = vdaf.shard(b"", &measurements[0], &nonce).unwrap();
let input_share = input_shares.into_iter().next().unwrap();

// For the aggregation paramter, we use the candidate prefixes from the prefix tree for
Expand All @@ -765,6 +813,7 @@ fn poplar1(c: &mut Criterion) {
b.iter(|| {
vdaf.prepare_init(
&verify_key,
b"",
0,
&agg_param,
&nonce,
Expand Down
Loading
Loading