Update to Rust `beta` channel.

This commit is contained in:
Marc Brinkmann 2018-08-31 15:35:27 +02:00
parent 02109b586e
commit a7cd6e0529
5 changed files with 31 additions and 45 deletions

View File

@ -20,14 +20,9 @@ env:
- RUST_BACKTRACE=1
# Enables additional cpu-specific optimizations.
- RUSTFLAGS="-D warnings -C target-cpu=native"
# Note: Currently (as of 2018-07-13), `clippy-preview` is only in the nightly
# release. A version of `rustfmt` that supports the `--check` option
# is also not in stable yet.
#
# A Clear migration path is swapping out `nightly-2018-07-13` with
# `beta` after the stable release of Rust 1.28; and finally migrating
# everything to `stable` at Rust 1.29.
- RUST_NEXT=nightly-2018-07-13
# Note: `beta` should be removed along with `RUST_NEXT` after the 1.28
# stable release on 2018-09-13.
- RUST_NEXT=beta
script:
- cargo +${RUST_NEXT} clippy -- --deny clippy
- cargo +${RUST_NEXT} clippy --tests --examples --benches -- --deny clippy

View File

@ -35,8 +35,7 @@ impl SecretSociety {
let sk_share = sk_set.secret_key_share(id).unwrap();
let pk_share = pk_set.public_key_share(id);
Actor::new(id, sk_share, pk_share)
})
.collect();
}).collect();
SecretSociety { actors, pk_set }
}

View File

@ -53,8 +53,7 @@ impl ChatNetwork {
let sk_share = sk_set.secret_key_share(id).unwrap();
let pk_share = pk_set.public_key_share(id);
Node::new(id, sk_share, pk_share)
})
.collect();
}).collect();
ChatNetwork {
pk_set,
@ -94,22 +93,23 @@ impl ChatNetwork {
// signature shares (i.e. has been signed by `threshold + 1` nodes).
fn run_consensus(&self) -> Option<(UserId, Msg, Signature)> {
// Create a new `MsgDatabase` of every message that has been signed by a validator node.
let all_pending: MsgDatabase = self.nodes.iter().fold(
BTreeMap::new(),
|mut all_pending, node| {
for (user_id, signed_msgs) in &node.pending {
let mut user_msgs = all_pending.entry(*user_id).or_insert_with(BTreeMap::new);
for (msg, sigs) in signed_msgs.iter() {
let sigs = sigs.iter().cloned();
user_msgs
.entry(msg.to_string())
.or_insert_with(Vec::new)
.extend(sigs);
let all_pending: MsgDatabase =
self.nodes
.iter()
.fold(BTreeMap::new(), |mut all_pending, node| {
for (user_id, signed_msgs) in &node.pending {
let mut user_msgs =
all_pending.entry(*user_id).or_insert_with(BTreeMap::new);
for (msg, sigs) in signed_msgs.iter() {
let sigs = sigs.iter().cloned();
user_msgs
.entry(msg.to_string())
.or_insert_with(Vec::new)
.extend(sigs);
}
}
}
all_pending
},
);
all_pending
});
// Iterate over the `MsgDatabase` numerically by user ID, then iterate over each user's
// messages alphabetically. Try to combine the validator signatures. The first message that

View File

@ -38,7 +38,7 @@ use byteorder::{BigEndian, ByteOrder};
use errno::errno;
use init_with::InitWith;
use memsec::{memzero, mlock, munlock};
use pairing::bls12_381::{Bls12, Fr, G1, G1Affine, G2, G2Affine};
use pairing::bls12_381::{Bls12, Fr, G1Affine, G2Affine, G1, G2};
use pairing::{CurveAffine, CurveProjective, Engine, Field};
use rand::{ChaChaRng, OsRng, Rand, Rng, SeedableRng};
use tiny_keccak::sha3_256;
@ -795,8 +795,7 @@ mod tests {
.unwrap_or_else(|_| panic!("Failed to create `SecretKeyShare` #{}", i))
.sign(msg);
(i, sig)
})
.collect();
}).collect();
// Each of the shares is a valid signature matching its public key share.
for (i, sig) in &sigs {
@ -816,8 +815,7 @@ mod tests {
.unwrap_or_else(|_| panic!("Failed to create `SecretKeyShare` #{}", i))
.sign(msg);
(i, sig)
})
.collect();
}).collect();
let sig2 = pk_set.combine_signatures(&sigs2).expect("signatures match");
assert_eq!(sig, sig2);
}
@ -864,8 +862,7 @@ mod tests {
.decrypt_share(&ciphertext)
.expect("ciphertext is valid");
(i, dec_share)
})
.collect();
}).collect();
// Each of the shares is valid matching its public key share.
for (i, share) in &shares {

View File

@ -24,7 +24,7 @@ use std::{cmp, iter, ops};
use errno::errno;
use memsec::{memzero, mlock, munlock};
use pairing::bls12_381::{Fr, G1, G1Affine};
use pairing::bls12_381::{Fr, G1Affine, G1};
use pairing::{CurveAffine, CurveProjective, Field};
use rand::Rng;
@ -221,8 +221,7 @@ impl<'a, B: Borrow<Poly>> ops::Mul<B> for &'a Poly {
c.add_assign(&s);
}
c
})
.collect();
}).collect();
match Poly::new(coeff) {
Ok(poly) => poly,
@ -803,8 +802,7 @@ impl BivarPoly {
result.add_assign(&summand);
}
result
})
.collect();
}).collect();
Poly::new(coeff)
}
@ -887,8 +885,7 @@ impl BivarCommitment {
result.add_assign(&summand);
}
result
})
.collect();
}).collect();
Commitment { coeff }
}
@ -906,8 +903,7 @@ fn powers<T: IntoFr>(into_x: T, degree: usize) -> Vec<Fr> {
.chain((0..degree).map(|_| {
x_pow_i.mul_assign(&x);
x_pow_i
}))
.collect()
})).collect()
}
/// Returns the position of coefficient `(i, j)` in the vector describing a symmetric bivariate
@ -977,8 +973,7 @@ mod tests {
.map(|_| {
BivarPoly::random(faulty_num, &mut rng)
.expect("Failed to create random `BivarPoly`")
})
.collect();
}).collect();
let pub_bi_commits: Vec<_> = bi_polys.iter().map(BivarPoly::commitment).collect();
let mut sec_keys = vec![Fr::zero(); node_num];