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

fix clippy error #37

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all 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
105 changes: 52 additions & 53 deletions ipa-core/src/cli/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl DecryptedReports {
.unwrap_or_else(|e| panic!("unable to open file {filename:?}. {e}"));
let reader = BufReader::new(file);
Self {
filename: filename.to_path_buf(),
filename: filename.clone(),
reader,
key_registry,
iter_index: 0,
Expand Down Expand Up @@ -198,58 +198,57 @@ pub async fn decrypt_and_reconstruct(args: DecryptArgs) -> Result<(), BoxError>
for (dec_report1, (dec_report2, dec_report3)) in
decrypted_reports1.zip(decrypted_reports2.zip(decrypted_reports3))
{
match (dec_report1, dec_report2, dec_report3) {
(Ok(dec_report1), Ok(dec_report2), Ok(dec_report3)) => {
let timestamp = [
dec_report1.timestamp,
dec_report2.timestamp,
dec_report3.timestamp,
]
.reconstruct()
.as_u128();

let match_key = [
dec_report1.match_key,
dec_report2.match_key,
dec_report3.match_key,
]
.reconstruct()
.as_u128();

// these aren't reconstucted, so we explictly make sure
// they are consistent across all three files, then set
// it to the first one (without loss of generality)
assert_eq!(dec_report1.event_type, dec_report2.event_type);
assert_eq!(dec_report2.event_type, dec_report3.event_type);
let is_trigger_report = dec_report1.event_type == EventType::Trigger;

let breakdown_key = [
dec_report1.breakdown_key,
dec_report2.breakdown_key,
dec_report3.breakdown_key,
]
.reconstruct()
.as_u128();

let trigger_value = [
dec_report1.trigger_value,
dec_report2.trigger_value,
dec_report3.trigger_value,
]
.reconstruct()
.as_u128();

writeln!(
writer,
"{},{},{},{},{}",
timestamp,
match_key,
u8::from(is_trigger_report),
breakdown_key,
trigger_value,
)?;
}
(_, _, _) => {}
if let (Ok(dec_report1), Ok(dec_report2), Ok(dec_report3)) =
(dec_report1, dec_report2, dec_report3)
{
let timestamp = [
dec_report1.timestamp,
dec_report2.timestamp,
dec_report3.timestamp,
]
.reconstruct()
.as_u128();

let match_key = [
dec_report1.match_key,
dec_report2.match_key,
dec_report3.match_key,
]
.reconstruct()
.as_u128();

// these aren't reconstucted, so we explictly make sure
// they are consistent across all three files, then set
// it to the first one (without loss of generality)
assert_eq!(dec_report1.event_type, dec_report2.event_type);
assert_eq!(dec_report2.event_type, dec_report3.event_type);
let is_trigger_report = dec_report1.event_type == EventType::Trigger;

let breakdown_key = [
dec_report1.breakdown_key,
dec_report2.breakdown_key,
dec_report3.breakdown_key,
]
.reconstruct()
.as_u128();

let trigger_value = [
dec_report1.trigger_value,
dec_report2.trigger_value,
dec_report3.trigger_value,
]
.reconstruct()
.as_u128();

writeln!(
writer,
"{},{},{},{},{}",
timestamp,
match_key,
u8::from(is_trigger_report),
breakdown_key,
trigger_value,
)?;
}
}
Ok(())
Expand Down