Skip to content

Commit

Permalink
Merge pull request #1462 from akoshelev/rust-183
Browse files Browse the repository at this point in the history
Upgrade to Rust 1.83
  • Loading branch information
akoshelev authored Nov 30, 2024
2 parents aa8077c + 4b2633a commit f5b68c6
Show file tree
Hide file tree
Showing 30 changed files with 78 additions and 88 deletions.
1 change: 0 additions & 1 deletion ipa-core/src/cli/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use crate::{error::BoxError, hpke::KeyPair};
about = "Generate keys used by an MPC helper",
next_help_heading = "Key Generation Options"
)]

pub struct KeygenArgs {
/// DNS name to use for the TLS certificate
#[arg(short, long)]
Expand Down
4 changes: 2 additions & 2 deletions ipa-core/src/ff/boolean_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ pub struct BAOwnedIterator<S: IntoIterator> {
}

///impl Iterator for all Boolean arrays
impl<'a> Iterator for BAIterator<'a> {
impl Iterator for BAIterator<'_> {
type Item = Boolean;

fn next(&mut self) -> Option<Self::Item> {
self.iterator.next().map(|v| Boolean::from(*v))
}
}

impl<'a> ExactSizeIterator for BAIterator<'a> {
impl ExactSizeIterator for BAIterator<'_> {
fn len(&self) -> usize {
self.iterator.len()
}
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/helpers/buffers/ordering_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ pub struct Close<'s> {
sender: &'s OrderingSender,
}

impl<'s> Future for Close<'s> {
impl Future for Close<'_> {
type Output = ();

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/helpers/hashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<T: Serializable> SerializeAs<T> for T {
}
}

impl<'a, T: Serializable> SerializeAs<T> for &'a T {
impl<T: Serializable> SerializeAs<T> for &T {
fn serialize(self, buf: &mut GenericArray<u8, <T as Serializable>::Size>) {
<T as Serializable>::serialize(self, buf);
}
Expand Down
6 changes: 3 additions & 3 deletions ipa-core/src/helpers/stream/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum ChunkData<'a, T, const N: usize> {
Owned(Box<[T; N]>),
}

impl<'a, T, const N: usize> Deref for ChunkData<'a, T, N> {
impl<T, const N: usize> Deref for ChunkData<'_, T, N> {
type Target = [T; N];

fn deref(&self) -> &Self::Target {
Expand Down Expand Up @@ -135,7 +135,7 @@ impl<T, const N: usize> Chunk<Vec<T>, N> {
let Self { chunk_type, data } = self;
debug_assert!(N % M == 0);
let (mut len, expected) = if let ChunkType::Partial(len) = chunk_type {
(len, Expected::Range(((len + M - 1) / M)..=(N / M)))
(len, Expected::Range(len.div_ceil(M)..=(N / M)))
} else {
(N, Expected::Exactly(N / M))
};
Expand Down Expand Up @@ -484,7 +484,7 @@ where
<Const<DIVISOR> as ToUInt>::Output: Unsigned + typenum::NonZero,
{
let divisor = <Const<DIVISOR> as ToUInt>::Output::to_usize();
(dividend + divisor - 1) / divisor
dividend.div_ceil(divisor)
}

/// Trait to flatten a stream of iterables.
Expand Down
29 changes: 14 additions & 15 deletions ipa-core/src/protocol/basics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,25 @@ pub trait BasicProtocols<C: Context, V: SharedValue + Vectorizable<N>, const N:
}

// For PRF test
impl<'a, B: ShardBinding> BasicProtocols<UpgradedSemiHonestContext<'a, B, Fp25519>, Fp25519>
impl<B: ShardBinding> BasicProtocols<UpgradedSemiHonestContext<'_, B, Fp25519>, Fp25519>
for AdditiveShare<Fp25519>
{
}

impl<'a, B: ShardBinding>
BasicProtocols<UpgradedSemiHonestContext<'a, B, Fp25519>, Fp25519, PRF_CHUNK>
impl<B: ShardBinding> BasicProtocols<UpgradedSemiHonestContext<'_, B, Fp25519>, Fp25519, PRF_CHUNK>
for AdditiveShare<Fp25519, PRF_CHUNK>
{
}

impl<'a, const N: usize> BasicProtocols<UpgradedMaliciousContext<'a, Fp25519>, Fp25519, N>
impl<const N: usize> BasicProtocols<UpgradedMaliciousContext<'_, Fp25519>, Fp25519, N>
for malicious::AdditiveShare<Fp25519, N>
where
Fp25519: FieldSimd<N>,
AdditiveShare<Fp25519, N>: FromPrss,
{
}

impl<'a, const N: usize> BasicProtocols<ShardedUpgradedMaliciousContext<'a, Fp25519>, Fp25519, N>
impl<const N: usize> BasicProtocols<ShardedUpgradedMaliciousContext<'_, Fp25519>, Fp25519, N>
for malicious::AdditiveShare<Fp25519, N>
where
Fp25519: FieldSimd<N>,
Expand All @@ -89,40 +88,40 @@ where
{
}

impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'a, B>>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'_, B>>
for AdditiveShare<Boolean>
{
}

impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedMaliciousContext<'a, B>>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedMaliciousContext<'_, B>>
for AdditiveShare<Boolean>
{
}

// Used for aggregation tests
impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'a, B>, 8>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'_, B>, 8>
for AdditiveShare<Boolean, 8>
{
}

impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'a, B>, PRF_CHUNK>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'_, B>, PRF_CHUNK>
for AdditiveShare<Boolean, PRF_CHUNK>
{
}

impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedMaliciousContext<'a, B>, PRF_CHUNK>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedMaliciousContext<'_, B>, PRF_CHUNK>
for AdditiveShare<Boolean, PRF_CHUNK>
{
}

// These implementations also implement `BooleanProtocols` for `CONV_CHUNK`
// since `CONV_CHUNK = AGG_CHUNK`
impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'a, B>, AGG_CHUNK>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'_, B>, AGG_CHUNK>
for AdditiveShare<Boolean, AGG_CHUNK>
{
}

impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedMaliciousContext<'a, B>, AGG_CHUNK>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedMaliciousContext<'_, B>, AGG_CHUNK>
for AdditiveShare<Boolean, AGG_CHUNK>
{
}
Expand All @@ -142,17 +141,17 @@ const_assert_eq!(
"Implementation for N = 16 required for num_breakdowns"
);

impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'a, B>, 3>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'_, B>, 3>
for AdditiveShare<Boolean, 3>
{
}

impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'a, B>, 32>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedSemiHonestContext<'_, B>, 32>
for AdditiveShare<Boolean, 32>
{
}

impl<'a, B: ShardBinding> BooleanProtocols<DZKPUpgradedMaliciousContext<'a, B>, 32>
impl<B: ShardBinding> BooleanProtocols<DZKPUpgradedMaliciousContext<'_, B>, 32>
for AdditiveShare<Boolean, 32>
{
}
Expand Down
1 change: 0 additions & 1 deletion ipa-core/src/protocol/basics/mul/malicious.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use crate::{
/// It's cricital that the functionality `F_mult` is secure up to an additive attack.
/// `SecureMult` is an implementation of the IKHC multiplication protocol, which has this property.
///
/// Executes two parallel multiplications;
/// `A * B`, and `rA * B`, yielding both `AB` and `rAB`
/// both `AB` and `rAB` are provided to the security validator
Expand Down
6 changes: 3 additions & 3 deletions ipa-core/src/protocol/context/dzkp_malicious.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'a, B: ShardBinding> DZKPUpgraded<'a, B> {
}

#[async_trait]
impl<'a, B: ShardBinding> DZKPContext for DZKPUpgraded<'a, B> {
impl<B: ShardBinding> DZKPContext for DZKPUpgraded<'_, B> {
async fn validate_record(&self, record_id: RecordId) -> Result<(), Error> {
let validator_inner = self.validator_inner.upgrade().expect("validator is active");

Expand All @@ -107,7 +107,7 @@ impl<'a, B: ShardBinding> DZKPContext for DZKPUpgraded<'a, B> {
}
}

impl<'a, B: ShardBinding> super::Context for DZKPUpgraded<'a, B> {
impl<B: ShardBinding> super::Context for DZKPUpgraded<'_, B> {
fn role(&self) -> Role {
self.base_ctx.role()
}
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<'a, B: ShardBinding> super::Context for DZKPUpgraded<'a, B> {
}
}

impl<'a, B: ShardBinding> SeqJoin for DZKPUpgraded<'a, B> {
impl<B: ShardBinding> SeqJoin for DZKPUpgraded<'_, B> {
fn active_work(&self) -> NonZeroUsize {
self.base_ctx.active_work()
}
Expand Down
8 changes: 4 additions & 4 deletions ipa-core/src/protocol/context/dzkp_semi_honest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl ShardConfiguration for DZKPUpgraded<'_, Sharded> {
}
}

impl<'a> super::ShardedContext for DZKPUpgraded<'a, Sharded> {
impl super::ShardedContext for DZKPUpgraded<'_, Sharded> {
fn shard_send_channel<M: Message>(&self, dest_shard: ShardIndex) -> SendingEnd<ShardIndex, M> {
self.inner.shard_send_channel(dest_shard)
}
Expand All @@ -58,7 +58,7 @@ impl<'a> super::ShardedContext for DZKPUpgraded<'a, Sharded> {
}
}

impl<'a, B: ShardBinding> super::Context for DZKPUpgraded<'a, B> {
impl<B: ShardBinding> super::Context for DZKPUpgraded<'_, B> {
fn role(&self) -> Role {
self.inner.role()
}
Expand Down Expand Up @@ -104,14 +104,14 @@ impl<'a, B: ShardBinding> super::Context for DZKPUpgraded<'a, B> {
}
}

impl<'a, B: ShardBinding> SeqJoin for DZKPUpgraded<'a, B> {
impl<B: ShardBinding> SeqJoin for DZKPUpgraded<'_, B> {
fn active_work(&self) -> NonZeroUsize {
self.inner.active_work()
}
}

#[async_trait]
impl<'a, B: ShardBinding> DZKPContext for DZKPUpgraded<'a, B> {
impl<B: ShardBinding> DZKPContext for DZKPUpgraded<'_, B> {
async fn validate_record(&self, _record_id: RecordId) -> Result<(), Error> {
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/protocol/context/dzkp_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ impl<'a, B: ShardBinding> MaliciousDZKPValidator<'a, B> {
}
}

impl<'a, B: ShardBinding> Drop for MaliciousDZKPValidator<'a, B> {
impl<B: ShardBinding> Drop for MaliciousDZKPValidator<'_, B> {
fn drop(&mut self) {
// If `validate` has not been called, and we are not unwinding, check that the
// validator is not holding unverified multiplies.
Expand Down
11 changes: 5 additions & 6 deletions ipa-core/src/protocol/context/malicious.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<'a, B: ShardBinding> Context<'a, B> {
}
}

impl<'a, B: ShardBinding> super::Context for Context<'a, B> {
impl<B: ShardBinding> super::Context for Context<'_, B> {
fn role(&self) -> Role {
self.inner.role()
}
Expand Down Expand Up @@ -185,7 +185,7 @@ impl<'a, B: ShardBinding> UpgradableContext for Context<'a, B> {
}
}

impl<'a, B: ShardBinding> SeqJoin for Context<'a, B> {
impl<B: ShardBinding> SeqJoin for Context<'_, B> {
fn active_work(&self) -> NonZeroUsize {
self.inner.active_work()
}
Expand Down Expand Up @@ -273,7 +273,7 @@ impl<'a, F: ExtendableField, B: ShardBinding> Upgraded<'a, F, B> {
}

#[async_trait]
impl<'a, F: ExtendableField, B: ShardBinding> UpgradedContext for Upgraded<'a, F, B> {
impl<F: ExtendableField, B: ShardBinding> UpgradedContext for Upgraded<'_, F, B> {
type Field = F;

async fn validate_record(&self, record_id: RecordId) -> Result<(), Error> {
Expand All @@ -289,7 +289,7 @@ impl<'a, F: ExtendableField, B: ShardBinding> UpgradedContext for Upgraded<'a, F
}
}

impl<'a, F: ExtendableField, B: ShardBinding> super::Context for Upgraded<'a, F, B> {
impl<F: ExtendableField, B: ShardBinding> super::Context for Upgraded<'_, F, B> {
fn role(&self) -> Role {
self.base_ctx.role()
}
Expand Down Expand Up @@ -341,7 +341,7 @@ impl<'a, F: ExtendableField, B: ShardBinding> super::Context for Upgraded<'a, F,
}
}

impl<'a, F: ExtendableField, B: ShardBinding> SeqJoin for Upgraded<'a, F, B> {
impl<F: ExtendableField, B: ShardBinding> SeqJoin for Upgraded<'_, F, B> {
fn active_work(&self) -> NonZeroUsize {
self.base_ctx.active_work()
}
Expand Down Expand Up @@ -410,7 +410,6 @@ where
}

/// Convenience trait implementations to upgrade test data.
#[cfg(all(test, descriptive_gate))]
#[async_trait]
impl<'a, V: ExtendableFieldSimd<N>, B: ShardBinding, const N: usize> Upgradable<Upgraded<'a, V, B>>
Expand Down
4 changes: 2 additions & 2 deletions ipa-core/src/protocol/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl ShardedContext for Base<'_, Sharded> {
}
}

impl<'a, B: ShardBinding> Context for Base<'a, B> {
impl<B: ShardBinding> Context for Base<'_, B> {
fn role(&self) -> Role {
self.inner.gateway.role()
}
Expand Down Expand Up @@ -346,7 +346,7 @@ impl ShardConfiguration for Base<'_, Sharded> {
}
}

impl<'a, B: ShardBinding> SeqJoin for Base<'a, B> {
impl<B: ShardBinding> SeqJoin for Base<'_, B> {
fn active_work(&self) -> NonZeroUsize {
self.active_work.to_non_zero_usize()
}
Expand Down
11 changes: 5 additions & 6 deletions ipa-core/src/protocol/context/prss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ impl<'a> InstrumentedIndexedSharedRandomness<'a> {
}

impl SharedRandomness for InstrumentedIndexedSharedRandomness<'_> {
type ChunkIter<'a, Z: ArrayLength> = InstrumentedChunkIter<
'a,
<IndexedSharedRandomness as SharedRandomness>::ChunkIter<'a, Z>,
>
where Self: 'a;
type ChunkIter<'a, Z: ArrayLength>
= InstrumentedChunkIter<'a, <IndexedSharedRandomness as SharedRandomness>::ChunkIter<'a, Z>>
where
Self: 'a;

fn generate_chunks_one_side<I: Into<PrssIndex>, Z: ArrayLength>(
&self,
Expand Down Expand Up @@ -72,7 +71,7 @@ pub struct InstrumentedChunkIter<'a, I: Iterator> {
inner: I,
}

impl<'a, I: Iterator> Iterator for InstrumentedChunkIter<'a, I> {
impl<I: Iterator> Iterator for InstrumentedChunkIter<'_, I> {
type Item = <I as Iterator>::Item;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
11 changes: 6 additions & 5 deletions ipa-core/src/protocol/context/semi_honest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl<'a> Context<'a, Sharded> {
}
}

#[allow(clippy::needless_lifetimes)] // Lifetime may not live long enough, if lifetime is dropped
impl<'a, B: ShardBinding> Context<'a, B> {
#[cfg(test)]
#[must_use]
Expand All @@ -103,7 +104,7 @@ impl ShardedContext for Context<'_, Sharded> {
}
}

impl<'a, B: ShardBinding> super::Context for Context<'a, B> {
impl<B: ShardBinding> super::Context for Context<'_, B> {
fn role(&self) -> Role {
self.inner.role()
}
Expand Down Expand Up @@ -175,7 +176,7 @@ impl<'a, B: ShardBinding> UpgradableContext for Context<'a, B> {
}
}

impl<'a, B: ShardBinding> SeqJoin for Context<'a, B> {
impl<B: ShardBinding> SeqJoin for Context<'_, B> {
fn active_work(&self) -> NonZeroUsize {
self.inner.active_work()
}
Expand Down Expand Up @@ -228,7 +229,7 @@ impl<F: ExtendableField> ShardedContext for Upgraded<'_, Sharded, F> {
}
}

impl<'a, B: ShardBinding, F: ExtendableField> super::Context for Upgraded<'a, B, F> {
impl<B: ShardBinding, F: ExtendableField> super::Context for Upgraded<'_, B, F> {
fn role(&self) -> Role {
self.inner.role()
}
Expand Down Expand Up @@ -274,14 +275,14 @@ impl<'a, B: ShardBinding, F: ExtendableField> super::Context for Upgraded<'a, B,
}
}

impl<'a, B: ShardBinding, F: ExtendableField> SeqJoin for Upgraded<'a, B, F> {
impl<B: ShardBinding, F: ExtendableField> SeqJoin for Upgraded<'_, B, F> {
fn active_work(&self) -> NonZeroUsize {
self.inner.active_work()
}
}

#[async_trait]
impl<'a, B: ShardBinding, F: ExtendableField> UpgradedContext for Upgraded<'a, B, F> {
impl<B: ShardBinding, F: ExtendableField> UpgradedContext for Upgraded<'_, B, F> {
type Field = F;

async fn validate_record(&self, _record_id: RecordId) -> Result<(), Error> {
Expand Down
Loading

0 comments on commit f5b68c6

Please sign in to comment.