Skip to content

Commit

Permalink
Merge branch 'main' into relaxed-dp-feature-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
eriktaubeneck authored Sep 20, 2024
2 parents a88aa77 + 9147925 commit 13bf3c3
Show file tree
Hide file tree
Showing 11 changed files with 921 additions and 645 deletions.
Empty file removed .pre-commit.stash4zjacb
Empty file.
11 changes: 11 additions & 0 deletions ipa-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ name = "crypto_util"
required-features = ["cli", "test-fixture", "web-app"]
bench = false

[[bin]]
name = "in_the_clear"
required-features = ["cli", "test-fixture", "web-app"]
bench = false

[[bench]]
name = "criterion_arithmetic"
path = "benches/ct/arithmetic_circuit.rs"
Expand Down Expand Up @@ -262,4 +267,10 @@ required-features = [
"real-world-infra",
"test-fixture",
"relaxed-dp",

[[test]]
name = "hybrid"
required-features = [
"test-fixture",
"cli",
]
6 changes: 5 additions & 1 deletion ipa-core/benches/oneshot/ipa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ use ipa_step::StepNarrow;
use rand::{random, rngs::StdRng, SeedableRng};
use tokio::runtime::Builder;

#[cfg(all(not(target_env = "msvc"), not(feature = "dhat-heap")))]
#[cfg(all(
not(target_env = "msvc"),
not(feature = "dhat-heap"),
not(target_os = "macos")
))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

Expand Down
6 changes: 3 additions & 3 deletions ipa-core/src/bin/crypto_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::Debug;

use clap::{Parser, Subcommand};
use ipa_core::{
cli::crypto::{decrypt_and_reconstruct, encrypt, DecryptArgs, EncryptArgs},
cli::crypto::{DecryptArgs, EncryptArgs},
error::BoxError,
};

Expand All @@ -24,8 +24,8 @@ enum CryptoUtilCommand {
async fn main() -> Result<(), BoxError> {
let args = Args::parse();
match args.action {
CryptoUtilCommand::Encrypt(encrypt_args) => encrypt(&encrypt_args)?,
CryptoUtilCommand::Decrypt(decrypt_args) => decrypt_and_reconstruct(decrypt_args).await?,
CryptoUtilCommand::Encrypt(encrypt_args) => encrypt_args.encrypt()?,
CryptoUtilCommand::Decrypt(decrypt_args) => decrypt_args.decrypt_and_reconstruct().await?,
}
Ok(())
}
72 changes: 72 additions & 0 deletions ipa-core/src/bin/in_the_clear.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
use std::{error::Error, fs::File, io::Write, num::NonZeroU32, path::PathBuf};

use clap::Parser;
use ipa_core::{
cli::{playbook::InputSource, Verbosity},
test_fixture::hybrid::{hybrid_in_the_clear, TestHybridRecord},
};

#[derive(Debug, Parser)]
pub struct CommandInput {
#[arg(
long,
help = "Read the input from the provided file, instead of standard input"
)]
input_file: Option<PathBuf>,
}

impl From<&CommandInput> for InputSource {
fn from(source: &CommandInput) -> Self {
if let Some(ref file_name) = source.input_file {
InputSource::from_file(file_name)
} else {
InputSource::from_stdin()
}
}
}

#[derive(Debug, Parser)]
#[clap(name = "in_the_clear", about = "In the Clear CLI")]
#[command(about)]
struct Args {
#[clap(flatten)]
logging: Verbosity,

#[clap(flatten)]
input: CommandInput,

/// The destination file for output.
#[arg(long, value_name = "OUTPUT_FILE")]
output_file: PathBuf,

#[arg(long, default_value = "20")]
max_breakdown_key: NonZeroU32,
}

fn main() -> Result<(), Box<dyn Error>> {
let args = Args::parse();
let _handle = args.logging.setup_logging();

let input = InputSource::from(&args.input);

let input_rows = input.iter::<TestHybridRecord>().collect::<Vec<_>>();
let expected = hybrid_in_the_clear(
&input_rows,
usize::try_from(args.max_breakdown_key.get()).unwrap(),
);

let mut file = File::options()
.write(true)
.create_new(true)
.open(&args.output_file)
.map_err(|e| {
format!(
"Failed to create output file {}: {e}",
&args.output_file.display()
)
})?;

write!(file, "{}", serde_json::to_string_pretty(&expected)?)?;

Ok(())
}
Loading

0 comments on commit 13bf3c3

Please sign in to comment.