diff --git a/ipa-core/src/bin/report_collector.rs b/ipa-core/src/bin/report_collector.rs index 69f72cdea..d0e7deb13 100644 --- a/ipa-core/src/bin/report_collector.rs +++ b/ipa-core/src/bin/report_collector.rs @@ -182,16 +182,14 @@ impl KeyRegistries { network: &NetworkConfig, ) -> Option<(KeyIdentifier, [&KeyRegistry; 3])> { // Get the configs, if all three peers have one - let Some(configs) = network.peers().iter().try_fold(Vec::new(), |acc, peer| { + let configs = network.peers().iter().try_fold(Vec::new(), |acc, peer| { if let (mut vec, Some(hpke_config)) = (acc, peer.hpke_config.as_ref()) { vec.push(hpke_config); Some(vec) } else { None } - }) else { - return None; - }; + })?; // Create key registries self.0 = configs diff --git a/ipa-core/src/net/server/mod.rs b/ipa-core/src/net/server/mod.rs index 6d86ad96b..1bbbdfaa3 100644 --- a/ipa-core/src/net/server/mod.rs +++ b/ipa-core/src/net/server/mod.rs @@ -351,9 +351,7 @@ impl ClientCertRecognizingAcceptor { network_config: &NetworkConfig, cert_option: Option<&Certificate>, ) -> Option { - let Some(cert) = cert_option else { - return None; - }; + let cert = cert_option?; // We currently require an exact match with the peer cert (i.e. we don't support verifying // the certificate against a truststore and identifying the peer by the certificate // subject). This could be changed if the need arises. diff --git a/ipa-core/src/protocol/basics/mod.rs b/ipa-core/src/protocol/basics/mod.rs index 7e0ba176f..7314af874 100644 --- a/ipa-core/src/protocol/basics/mod.rs +++ b/ipa-core/src/protocol/basics/mod.rs @@ -19,7 +19,7 @@ pub use sum_of_product::SumOfProducts; use crate::{ ff::Field, - protocol::{context::Context, RecordId}, + protocol::context::Context, secret_sharing::{ replicated::semi_honest::AdditiveShare, SecretSharing, SharedValue, Vectorizable, }, @@ -34,7 +34,7 @@ use crate::{ pub trait BasicProtocols, const N: usize = 1>: SecretSharing - + Reshare + + Reshare + Reveal>::Array> + SecureMul + ShareKnownValue diff --git a/ipa-core/src/protocol/basics/reshare.rs b/ipa-core/src/protocol/basics/reshare.rs index e2bdec483..1a26b9ad0 100644 --- a/ipa-core/src/protocol/basics/reshare.rs +++ b/ipa-core/src/protocol/basics/reshare.rs @@ -1,5 +1,3 @@ -use std::iter::{repeat, zip}; - use async_trait::async_trait; use embed_doc_image::embed_doc_image; @@ -7,7 +5,7 @@ use crate::{ error::Error, ff::Field, helpers::{Direction, Role}, - protocol::{context::Context, prss::SharedRandomness, NoRecord, RecordBinding, RecordId}, + protocol::{context::Context, prss::SharedRandomness, RecordId}, secret_sharing::replicated::{ semi_honest::AdditiveShare as Replicated, ReplicatedSecretSharing, }, @@ -39,11 +37,11 @@ use crate::{ /// `to_helper` = (`rand_left`, `rand_right`) = (r0, r1) /// `to_helper.right` = (`rand_right`, part1 + part2) = (r0, part1 + part2) #[async_trait] -pub trait Reshare: Sized + 'static { +pub trait Reshare: Sized + 'static { async fn reshare<'fut>( &self, ctx: C, - record_binding: B, + record_id: RecordId, to_helper: Role, ) -> Result where @@ -55,7 +53,7 @@ pub trait Reshare: Sized + 'static { /// This implements semi-honest reshare algorithm of "Efficient Secure Three-Party Sorting Protocol with an Honest Majority" at communication cost of 2R. /// Input: Pi-1 and Pi+1 know their secret shares /// Output: At the end of the protocol, all 3 helpers receive their shares of a new, random secret sharing of the secret value -impl Reshare for Replicated { +impl Reshare for Replicated { async fn reshare<'fut>( &self, ctx: C, @@ -108,9 +106,7 @@ impl Reshare for Replicated { /// For malicious reshare, we run semi honest reshare protocol twice, once for x and another for rx and return the results /// # Errors /// If either of reshares fails -impl<'a, F: ExtendableField> Reshare, RecordId> - for MaliciousReplicated -{ +impl<'a, F: ExtendableField> Reshare> for MaliciousReplicated { async fn reshare<'fut>( &self, ctx: UpgradedMaliciousContext<'a, F>, @@ -137,30 +133,6 @@ impl<'a, F: ExtendableField> Reshare, RecordId> } } -#[async_trait] -impl Reshare for Vec -where - S: Reshare + Send + Sync, -{ - #[tracing::instrument(name = "reshare", skip_all, fields(to = ?to_helper))] - async fn reshare<'fut>( - &self, - ctx: C, - _record_binding: NoRecord, - to_helper: Role, - ) -> Result, Error> - where - C: 'fut, - { - ctx.try_join( - zip(repeat(ctx.set_total_records(self.len())), self.iter()) - .enumerate() - .map(|(i, (c, x))| async move { x.reshare(c, RecordId::from(i), to_helper).await }), - ) - .await - } -} - #[cfg(all(test, unit_test))] mod tests { mod semi_honest { diff --git a/ipa-core/src/protocol/modulus_conversion/convert_shares.rs b/ipa-core/src/protocol/modulus_conversion/convert_shares.rs index 0ab10aba3..829c8410b 100644 --- a/ipa-core/src/protocol/modulus_conversion/convert_shares.rs +++ b/ipa-core/src/protocol/modulus_conversion/convert_shares.rs @@ -365,9 +365,7 @@ where let stream = unfold( (ctx, locally_converted, first_record), |(ctx, mut locally_converted, record_id)| async move { - let Some((triple, residual)) = locally_converted.next().await else { - return None; - }; + let (triple, residual) = locally_converted.next().await?; let bit_contexts = (0..).map(|i| ctx.narrow(&ConvertSharesStep::ConvertBit(i))); let converted = ctx.parallel_join(zip(bit_contexts, triple).map(|(ctx, triple)| async move {