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 - RUST_BACKTRACE=1
# Enables additional cpu-specific optimizations. # Enables additional cpu-specific optimizations.
- RUSTFLAGS="-D warnings -C target-cpu=native" - RUSTFLAGS="-D warnings -C target-cpu=native"
# Note: Currently (as of 2018-07-13), `clippy-preview` is only in the nightly # Note: `beta` should be removed along with `RUST_NEXT` after the 1.28
# release. A version of `rustfmt` that supports the `--check` option # stable release on 2018-09-13.
# is also not in stable yet. - RUST_NEXT=beta
#
# 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
script: script:
- cargo +${RUST_NEXT} clippy -- --deny clippy - cargo +${RUST_NEXT} clippy -- --deny clippy
- cargo +${RUST_NEXT} clippy --tests --examples --benches -- --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 sk_share = sk_set.secret_key_share(id).unwrap();
let pk_share = pk_set.public_key_share(id); let pk_share = pk_set.public_key_share(id);
Actor::new(id, sk_share, pk_share) Actor::new(id, sk_share, pk_share)
}) }).collect();
.collect();
SecretSociety { actors, pk_set } SecretSociety { actors, pk_set }
} }

View File

@ -53,8 +53,7 @@ impl ChatNetwork {
let sk_share = sk_set.secret_key_share(id).unwrap(); let sk_share = sk_set.secret_key_share(id).unwrap();
let pk_share = pk_set.public_key_share(id); let pk_share = pk_set.public_key_share(id);
Node::new(id, sk_share, pk_share) Node::new(id, sk_share, pk_share)
}) }).collect();
.collect();
ChatNetwork { ChatNetwork {
pk_set, pk_set,
@ -94,22 +93,23 @@ impl ChatNetwork {
// signature shares (i.e. has been signed by `threshold + 1` nodes). // signature shares (i.e. has been signed by `threshold + 1` nodes).
fn run_consensus(&self) -> Option<(UserId, Msg, Signature)> { fn run_consensus(&self) -> Option<(UserId, Msg, Signature)> {
// Create a new `MsgDatabase` of every message that has been signed by a validator node. // Create a new `MsgDatabase` of every message that has been signed by a validator node.
let all_pending: MsgDatabase = self.nodes.iter().fold( let all_pending: MsgDatabase =
BTreeMap::new(), self.nodes
|mut all_pending, node| { .iter()
for (user_id, signed_msgs) in &node.pending { .fold(BTreeMap::new(), |mut all_pending, node| {
let mut user_msgs = all_pending.entry(*user_id).or_insert_with(BTreeMap::new); for (user_id, signed_msgs) in &node.pending {
for (msg, sigs) in signed_msgs.iter() { let mut user_msgs =
let sigs = sigs.iter().cloned(); all_pending.entry(*user_id).or_insert_with(BTreeMap::new);
user_msgs for (msg, sigs) in signed_msgs.iter() {
.entry(msg.to_string()) let sigs = sigs.iter().cloned();
.or_insert_with(Vec::new) user_msgs
.extend(sigs); .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 // 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 // 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 errno::errno;
use init_with::InitWith; use init_with::InitWith;
use memsec::{memzero, mlock, munlock}; 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 pairing::{CurveAffine, CurveProjective, Engine, Field};
use rand::{ChaChaRng, OsRng, Rand, Rng, SeedableRng}; use rand::{ChaChaRng, OsRng, Rand, Rng, SeedableRng};
use tiny_keccak::sha3_256; use tiny_keccak::sha3_256;
@ -795,8 +795,7 @@ mod tests {
.unwrap_or_else(|_| panic!("Failed to create `SecretKeyShare` #{}", i)) .unwrap_or_else(|_| panic!("Failed to create `SecretKeyShare` #{}", i))
.sign(msg); .sign(msg);
(i, sig) (i, sig)
}) }).collect();
.collect();
// Each of the shares is a valid signature matching its public key share. // Each of the shares is a valid signature matching its public key share.
for (i, sig) in &sigs { for (i, sig) in &sigs {
@ -816,8 +815,7 @@ mod tests {
.unwrap_or_else(|_| panic!("Failed to create `SecretKeyShare` #{}", i)) .unwrap_or_else(|_| panic!("Failed to create `SecretKeyShare` #{}", i))
.sign(msg); .sign(msg);
(i, sig) (i, sig)
}) }).collect();
.collect();
let sig2 = pk_set.combine_signatures(&sigs2).expect("signatures match"); let sig2 = pk_set.combine_signatures(&sigs2).expect("signatures match");
assert_eq!(sig, sig2); assert_eq!(sig, sig2);
} }
@ -864,8 +862,7 @@ mod tests {
.decrypt_share(&ciphertext) .decrypt_share(&ciphertext)
.expect("ciphertext is valid"); .expect("ciphertext is valid");
(i, dec_share) (i, dec_share)
}) }).collect();
.collect();
// Each of the shares is valid matching its public key share. // Each of the shares is valid matching its public key share.
for (i, share) in &shares { for (i, share) in &shares {

View File

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