Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ipa-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = "0.1.0"
# 2. Update the rust version used for draft in
# https://github.com/private-attribution/draft/blob/main/sidecar/ansible/provision.yaml.
rust-version = "1.85.0"
edition = "2021"
edition = "2024"
build = "build.rs"

[features]
Expand Down
6 changes: 3 additions & 3 deletions ipa-core/benches/ct/arithmetic_circuit.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use criterion::{
black_box, criterion_group, criterion_main, measurement::Measurement, BatchSize,
BenchmarkGroup, BenchmarkId, Criterion, SamplingMode, Throughput,
BatchSize, BenchmarkGroup, BenchmarkId, Criterion, SamplingMode, Throughput, black_box,
criterion_group, criterion_main, measurement::Measurement,
};
use ipa_core::{
ff::{Field, Fp31, Fp32BitPrime, U128Conversions},
protocol::{basics::SecureMul, context::SemiHonestContext},
secret_sharing::{replicated::semi_honest::AdditiveShare as Replicated, FieldSimd, IntoShares},
secret_sharing::{FieldSimd, IntoShares, replicated::semi_honest::AdditiveShare as Replicated},
test_fixture::circuit,
};
use rand::distributions::{Distribution, Standard};
Expand Down
18 changes: 9 additions & 9 deletions ipa-core/benches/ct/dzkp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@

use std::iter::{repeat_with, zip};

use criterion::{criterion_group, criterion_main, BatchSize, Criterion, SamplingMode};
use futures::{stream::iter, TryStreamExt};
use criterion::{BatchSize, Criterion, SamplingMode, criterion_group, criterion_main};
use futures::{TryStreamExt, stream::iter};
use ipa_core::{
ff::boolean_array::BA256,
helpers::TotalRecords,
protocol::{
RecordId,
basics::BooleanArrayMul,
context::{
Context, DZKPUpgradedMaliciousContext, UpgradableContext,
dzkp_validator::{DZKPValidator, MultiplicationInputsBlock, TARGET_PROOF_SIZE},
malicious::TEST_DZKP_STEPS,
Context, DZKPUpgradedMaliciousContext, UpgradableContext,
},
RecordId,
},
secret_sharing::{replicated::semi_honest::AdditiveShare as Replicated, SharedValue},
secret_sharing::{SharedValue, replicated::semi_honest::AdditiveShare as Replicated},
sharding::NotSharded,
test_fixture::{Runner, TestWorld},
utils::non_zero_prev_power_of_two,
};
use rand::{thread_rng, Rng};
use rand::{Rng, random, thread_rng};
use tokio::runtime::Builder;

/// Benchmark for the table_indices_prover function in dzkp_field.rs.
fn benchmark_table_indices_prover(c: &mut Criterion) {
let mut group = c.benchmark_group("benches");
group.bench_function("table_indices_prover", |b| {
b.iter_batched_ref(
|| thread_rng().gen(),
|| random(),
|input: &mut MultiplicationInputsBlock| input.table_indices_prover(),
BatchSize::SmallInput,
)
Expand Down Expand Up @@ -60,8 +60,8 @@ fn benchmark_proof(c: &mut Criterion) {
|| {
let mut rng = thread_rng();

let a = repeat_with(|| rng.gen()).take(COUNT).collect::<Vec<BA>>();
let b = repeat_with(|| rng.gen()).take(COUNT).collect::<Vec<BA>>();
let a = repeat_with(|| rng.r#gen()).take(COUNT).collect::<Vec<BA>>();
let b = repeat_with(|| rng.r#gen()).take(COUNT).collect::<Vec<BA>>();

(a, b)
},
Expand Down
6 changes: 3 additions & 3 deletions ipa-core/benches/ct/prss.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::sync::Arc;

use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
use criterion::{Criterion, Throughput, black_box, criterion_group, criterion_main};
use ipa_core::{
ff::boolean_array::{BA256, BA64, BA8},
ff::boolean_array::{BA8, BA64, BA256},
protocol::{
prss::{Endpoint, IndexedSharedRandomness, KeyExchange, SharedRandomness},
Gate,
prss::{Endpoint, IndexedSharedRandomness, KeyExchange, SharedRandomness},
},
};
use rand::thread_rng;
Expand Down
4 changes: 3 additions & 1 deletion ipa-core/benches/oneshot/arithmetic_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ pub async fn main() {
let field_size = Fp31::BITS;
let width = args.width;
let depth = args.depth;
println!("benchmark parameters: Field size: {field_size} bits, circuit width: {width}, depth: {depth}");
println!(
"benchmark parameters: Field size: {field_size} bits, circuit width: {width}, depth: {depth}"
);
}

let input = circuit::arithmetic_setup(args.width, args.depth);
Expand Down
9 changes: 5 additions & 4 deletions ipa-core/benches/transpose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@

use std::{array, iter::repeat_with, time::Duration};

use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput};
use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use ipa_core::{
error::UnwrapInfallible,
ff::boolean_array::BA64,
secret_sharing::{
vector::{transpose_16x16, transpose_8x8},
SharedValue, TransposeFrom,
vector::{transpose_8x8, transpose_16x16},
},
};
use rand::{
Rng,
distributions::{Distribution, Standard},
thread_rng, Rng,
thread_rng,
};

fn random_array<T, const N: usize>() -> [T; N]
where
Standard: Distribution<T>,
{
let mut rng = thread_rng();
array::from_fn(|_| rng.gen())
array::from_fn(|_| rng.r#gen())
}

struct Params {
Expand Down
8 changes: 4 additions & 4 deletions ipa-core/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
cli::LoggingHandle,
executor::IpaRuntime,
helpers::{
query::{CompareStatusRequest, PrepareQuery, QueryConfig, QueryInput},
routing::{Addr, RouteId},
ApiError, BodyStream, HandlerBox, HandlerRef, HelperIdentity, HelperResponse,
MpcTransportImpl, RequestHandler, ShardTransportImpl, Transport, TransportIdentity,
query::{CompareStatusRequest, PrepareQuery, QueryConfig, QueryInput},
routing::{Addr, RouteId},
},
hpke::{KeyRegistry, PrivateKeyOnly},
protocol::QueryId,
Expand Down Expand Up @@ -222,7 +222,7 @@
return Err(ApiError::BadRequest(
format!("{r:?} request must not be handled by shard query processing flow")
.into(),
))
));

Check warning on line 225 in ipa-core/src/app.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/app.rs#L225

Added line #L225 was not covered by tests
}
})
}
Expand All @@ -241,7 +241,7 @@
return Err(ApiError::BadRequest(
format!("{r:?} request must not be handled by MPC query processing flow")
.into(),
))
));

Check warning on line 244 in ipa-core/src/app.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/app.rs#L244

Added line #L244 was not covered by tests
}
RouteId::ReceiveQuery => {
let req = req.into::<QueryConfig>()?;
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/bin/crypto_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::fmt::Debug;
use clap::{Parser, Subcommand};
use ipa_core::{
cli::{
crypto::{HybridDecryptArgs, HybridEncryptArgs},
Verbosity,
crypto::{HybridDecryptArgs, HybridEncryptArgs},
},
error::BoxError,
};
Expand Down
8 changes: 4 additions & 4 deletions ipa-core/src/bin/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ use clap::{self, Parser, Subcommand};
use futures::future::join;
use hyper::http::uri::Scheme;
use ipa_core::{
AppConfig, AppSetup, NonZeroU32PowerOfTwo,
cli::{
ConfGenArgs, KeygenArgs, LoggingHandle, ShardedConfGenArgs, TestSetupArgs, Verbosity,
client_config_setup, keygen, sharded_client_config_setup, sharded_server_from_toml_str,
test_setup, ConfGenArgs, KeygenArgs, LoggingHandle, ShardedConfGenArgs, TestSetupArgs,
Verbosity,
test_setup,
},
config::{hpke_registry, HpkeServerConfig, ServerConfig, TlsConfig},
config::{HpkeServerConfig, ServerConfig, TlsConfig, hpke_registry},
error::BoxError,
executor::IpaRuntime,
helpers::HelperIdentity,
Expand All @@ -25,7 +26,6 @@ use ipa_core::{
ShardHttpTransport,
},
sharding::ShardIndex,
AppConfig, AppSetup, NonZeroU32PowerOfTwo,
};
use tokio::runtime::Runtime;
use tracing::{error, info};
Expand Down
4 changes: 2 additions & 2 deletions ipa-core/src/bin/in_the_clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ 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},
cli::{Verbosity, playbook::InputSource},
test_fixture::hybrid::{TestHybridRecord, hybrid_in_the_clear},
};

#[derive(Debug, Parser)]
Expand Down
4 changes: 2 additions & 2 deletions ipa-core/src/bin/ipa_bench/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use clap::Parser;
use ipa_core::cli::Verbosity;
use rand::{rngs::StdRng, SeedableRng};
use rand::{SeedableRng, rngs::StdRng};
use tracing::{debug, error, info};

use crate::{gen_events::generate_events, sample::Sample};
Expand Down Expand Up @@ -159,7 +159,7 @@

fn get_input(path: &Option<PathBuf>) -> Result<Box<dyn io::Read>, io::Error> {
match path {
Some(ref path) => File::open(path).map(|f| Box::new(f) as Box<dyn io::Read>),
Some(path) => File::open(path).map(|f| Box::new(f) as Box<dyn io::Read>),

Check warning on line 162 in ipa-core/src/bin/ipa_bench/cmd.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/bin/ipa_bench/cmd.rs#L162

Added line #L162 was not covered by tests
None => Ok(Box::new(io::stdin())),
}
}
Expand Down
10 changes: 5 additions & 5 deletions ipa-core/src/bin/ipa_bench/gen_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::io;

use bitvec::view::BitViewSized;
use rand::{
distributions::{Bernoulli, Distribution},
CryptoRng, Rng, RngCore,
distributions::{Bernoulli, Distribution},
};
use tracing::{debug, info, trace};

Expand Down Expand Up @@ -38,7 +38,7 @@ pub fn generate_events<R: RngCore + CryptoRng, W: io::Write>(
debug!("ad: {}", ad_count);

// For now, we'll do 1 ad = 1 breakdown key
let ad_id: u32 = rng.gen();
let ad_id: u32 = rng.r#gen();

// Number of unique people who saw the ad
let reach = sample.reach_per_ad(rng);
Expand Down Expand Up @@ -93,7 +93,7 @@ fn gen_reports<R: RngCore + CryptoRng>(
) -> Vec<GenericReport> {
let mut reports: Vec<GenericReport> = Vec::new();

let matchkey = rng.gen::<MatchKey>();
let matchkey = rng.r#gen::<MatchKey>();

// Randomly choose a datetime (plus the given base timestamp) as the first impression
let mut last_impression =
Expand Down Expand Up @@ -177,9 +177,9 @@ mod tests {
io::{Cursor, Write},
};

use rand::{rngs::StdRng, SeedableRng};
use rand::{SeedableRng, rngs::StdRng};

use super::{gen_reports, generate_events, EventTimestamp, GenericReport};
use super::{EventTimestamp, GenericReport, gen_reports, generate_events};
use crate::{gen_events::add_event_timestamps, models::Epoch, sample::Sample};

const DATA: &str = r#"
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/bin/ipa_bench/sample.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::time::Duration;

use rand::{
distributions::{Distribution, WeightedIndex},
CryptoRng, Rng, RngCore,
distributions::{Distribution, WeightedIndex},
};

use crate::config::Config;
Expand Down
18 changes: 9 additions & 9 deletions ipa-core/src/bin/report_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
fmt::Debug,
fs::{File, OpenOptions},
io,
io::{stdout, BufRead, BufReader, Write},
io::{BufRead, BufReader, Write, stdout},
iter::zip,
ops::Deref,
path::{Path, PathBuf},
};

use clap::{Parser, Subcommand};
use hyper::{http::uri::Scheme, Uri};
use hyper::{Uri, http::uri::Scheme};
use ipa_core::{
cli::{
CsvSerializer, Verbosity,
playbook::{
make_clients, make_sharded_clients, run_hybrid_query_and_validate,
BufferedRoundRobinSubmission, HybridQueryResult, InputSource, StreamingSubmission,
make_clients, make_sharded_clients, run_hybrid_query_and_validate,
},
CsvSerializer, Verbosity,
},
ff::{boolean_array::BA32, FieldType},
ff::{FieldType, boolean_array::BA32},
helpers::{
query::{HybridQueryParams, QueryConfig, QueryInput, QuerySize, QueryType},
BodyStream,
query::{HybridQueryParams, QueryConfig, QueryInput, QuerySize, QueryType},
},
net::{Helper, IpaHttpClient},
protocol::QueryId,
test_fixture::{HybridEventGenerator, HybridGeneratorConfig},
};
use rand::{distributions::Alphanumeric, rngs::StdRng, thread_rng, Rng};
use rand::{Rng, distributions::Alphanumeric, rngs::StdRng, thread_rng};
use rand_core::SeedableRng;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -181,9 +181,9 @@
hybrid_query_config,
clients,
|query_id| {
if let Some(ref url_file_list) = url_file_list {
if let Some(url_file_list) = url_file_list {

Check warning on line 184 in ipa-core/src/bin/report_collector.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/bin/report_collector.rs#L184

Added line #L184 was not covered by tests
inputs_from_url_file(url_file_list, query_id, args.shard_count)
} else if let Some(ref encrypted_inputs) = encrypted_inputs {
} else if let Some(encrypted_inputs) = encrypted_inputs {

Check warning on line 186 in ipa-core/src/bin/report_collector.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/bin/report_collector.rs#L186

Added line #L186 was not covered by tests
Ok(inputs_from_encrypted_inputs(
encrypted_inputs,
query_id,
Expand Down
10 changes: 5 additions & 5 deletions ipa-core/src/bin/test_mpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ use generic_array::ArrayLength;
use hyper::http::uri::Scheme;
use ipa_core::{
cli::{
Verbosity,
playbook::{
make_clients, make_sharded_clients, secure_add, secure_mul, secure_shuffle, validate,
InputSource,
InputSource, make_clients, make_sharded_clients, secure_add, secure_mul,
secure_shuffle, validate,
},
Verbosity,
},
ff::{
boolean_array::BA64, Field, FieldType, Fp31, Fp32BitPrime, Serializable, U128Conversions,
Field, FieldType, Fp31, Fp32BitPrime, Serializable, U128Conversions, boolean_array::BA64,
},
helpers::query::{
QueryConfig,
QueryType::{TestAddInPrimeField, TestMultiply, TestShardedShuffle},
},
net::{Helper, IpaHttpClient},
secret_sharing::{replicated::semi_honest::AdditiveShare, IntoShares},
secret_sharing::{IntoShares, replicated::semi_honest::AdditiveShare},
};
use tiny_http::{Response, ResponseBox, Server, StatusCode};
use tracing::{error, info};
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/cli/clientconf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clap::Args;

use crate::{
cli::{
config_parse::{gen_client_config, HelperClientConf},
config_parse::{HelperClientConf, gen_client_config},
paths::PathExt,
},
error::BoxError,
Expand Down
Loading