-
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
Fix the saturated addition panic inside IPA #1286
Changes from all commits
1374efd
2facdcb
3da73c9
952e277
6d7c1d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ track_steps!( | |
dp::step, | ||
step, | ||
}, | ||
test_fixture::step | ||
); | ||
|
||
fn main() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -721,3 +721,109 @@ pub mod tests { | |
}); | ||
} | ||
} | ||
|
||
#[cfg(all(test, all(feature = "compact-gate", feature = "in-memory-infra")))] | ||
mod compact_gate_tests { | ||
|
||
use ipa_step::StepNarrow; | ||
|
||
use crate::{ | ||
ff::{ | ||
boolean_array::{BA20, BA5, BA8}, | ||
U128Conversions, | ||
}, | ||
helpers::query::DpMechanism, | ||
protocol::{ | ||
ipa_prf::{oprf_ipa, oprf_padding::PaddingParameters}, | ||
step::{ProtocolGate, ProtocolStep}, | ||
}, | ||
test_executor::run, | ||
test_fixture::{ipa::TestRawDataRecord, Reconstruct, Runner, TestWorld, TestWorldConfig}, | ||
}; | ||
|
||
#[test] | ||
fn saturated_agg() { | ||
const EXPECTED: &[u128] = &[0, 255, 255, 0, 0, 0, 0, 0]; | ||
|
||
run(|| async { | ||
let world = TestWorld::new_with(TestWorldConfig { | ||
initial_gate: Some(ProtocolGate::default().narrow(&ProtocolStep::IpaPrf)), | ||
..Default::default() | ||
}); | ||
|
||
let records: Vec<TestRawDataRecord> = vec![ | ||
TestRawDataRecord { | ||
timestamp: 0, | ||
user_id: 12345, | ||
is_trigger_report: false, | ||
breakdown_key: 1, | ||
trigger_value: 0, | ||
}, | ||
TestRawDataRecord { | ||
timestamp: 5, | ||
user_id: 12345, | ||
is_trigger_report: false, | ||
breakdown_key: 2, | ||
trigger_value: 0, | ||
}, | ||
TestRawDataRecord { | ||
timestamp: 10, | ||
user_id: 12345, | ||
is_trigger_report: true, | ||
breakdown_key: 0, | ||
trigger_value: 255, | ||
}, | ||
TestRawDataRecord { | ||
timestamp: 20, | ||
user_id: 12345, | ||
is_trigger_report: true, | ||
breakdown_key: 0, | ||
eriktaubeneck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
trigger_value: 255, | ||
}, | ||
TestRawDataRecord { | ||
timestamp: 30, | ||
user_id: 12345, | ||
is_trigger_report: true, | ||
breakdown_key: 0, | ||
trigger_value: 255, | ||
}, | ||
TestRawDataRecord { | ||
timestamp: 0, | ||
user_id: 68362, | ||
is_trigger_report: false, | ||
breakdown_key: 1, | ||
trigger_value: 0, | ||
}, | ||
TestRawDataRecord { | ||
timestamp: 20, | ||
user_id: 68362, | ||
is_trigger_report: true, | ||
breakdown_key: 1, | ||
trigger_value: 255, | ||
}, | ||
]; | ||
let dp_params = DpMechanism::NoDp; | ||
let padding_params = PaddingParameters::relaxed(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't this happen by default when testing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure what you mean by that. We have to supply this padding_params parameter for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it. I was thinking this was gated by feature flags, but I suppose that just means this is unavailable without that flag. |
||
|
||
let mut result: Vec<_> = world | ||
.semi_honest(records.into_iter(), |ctx, input_rows| async move { | ||
oprf_ipa::<_, BA5, BA8, BA8, BA20, 5, 32>( | ||
ctx, | ||
input_rows, | ||
None, | ||
dp_params, | ||
padding_params, | ||
) | ||
.await | ||
.unwrap() | ||
}) | ||
.await | ||
.reconstruct(); | ||
result.truncate(EXPECTED.len()); | ||
assert_eq!( | ||
result.iter().map(|&v| v.as_u128()).collect::<Vec<_>>(), | ||
EXPECTED, | ||
); | ||
}); | ||
} | ||
} |
This file was deleted.
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.
if we're trying to test going from 2 bytes to 4, shouldn't we test some much bigger numbers?
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.
the histogram value is 1 byte wide, so we definitely hit overflow with this test data which was our goal for this test. Any deviation from "standard" 8 bit trigger values requires transpose plumbing which seemed unnecessary here