Skip to content

Commit

Permalink
chore: upgrade rust toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
joyqvq committed Oct 24, 2023
1 parent 802c1ac commit 416e965
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 28 deletions.
2 changes: 0 additions & 2 deletions fastcrypto-tbls/benches/tbls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod tbls_benches {
const WEIGHTS: [usize; 5] = [10, 20, 30, 40, 50];
for w in WEIGHTS {
let shares = (1..=w)
.into_iter()
.map(|i| private_poly.eval(NonZeroU32::new(i as u32).unwrap()))
.collect::<Vec<_>>();

Expand All @@ -37,7 +36,6 @@ mod tbls_benches {
for w in TOTAL_WEIGHTS {
let private_poly = Poly::<bls12381::Scalar>::rand(w as u32, &mut thread_rng());
let shares = (1..=w)
.into_iter()
.map(|i| private_poly.eval(NonZeroU32::new(i as u32).unwrap()))
.collect::<Vec<_>>();

Expand Down
6 changes: 0 additions & 6 deletions fastcrypto-tbls/src/nidkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,11 @@ where

// Precompute the dual code coefficients.
let ids_as_scalars = (1..=n)
.into_iter()
.map(|i| (i, G::ScalarType::from(i as u64)))
.collect::<HashMap<_, _>>();
let precomputed_dual_code_coefficients = (1..=n)
.into_iter()
.map(|i| {
(1..=n)
.into_iter()
.filter(|j| i != *j)
.map(|j| ids_as_scalars[&i] - ids_as_scalars[&j])
.fold(G::ScalarType::generator(), |acc, x| acc * x)
Expand Down Expand Up @@ -160,7 +157,6 @@ where
.share_id_to_node(&share_id)
.expect("using valid share id");
let encryptions = (0..NUM_OF_ENCRYPTIONS_PER_SHARE)
.into_iter()
.map(|_| {
let r = G::ScalarType::rand(rng);
let msg = bcs::to_bytes(&r).expect("serialization should work");
Expand Down Expand Up @@ -201,7 +197,6 @@ where
.map(|(share_id, chal, &values)| {
let share = self.vss_sk.eval(share_id).value;
let infos = (0..NUM_OF_ENCRYPTIONS_PER_SHARE)
.into_iter()
.map(|i| {
if chal[i] {
EncryptionInfo::ForVerification { k_x_g: values[i].1 }
Expand Down Expand Up @@ -321,7 +316,6 @@ where
assert!(self.is_above_t(messages).is_ok());

let partial_pks = (0..self.nodes.n())
.into_iter()
.map(|i| {
messages
.iter()
Expand Down
8 changes: 4 additions & 4 deletions fastcrypto-tbls/src/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use fastcrypto::traits::AllowedRng;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;

//// Types
/// Types
pub type Eval<A> = IndexedValue<A>;

Expand All @@ -24,7 +24,7 @@ pub struct Poly<C>(Vec<C>);
pub type PrivatePoly<C> = Poly<<C as GroupElement>::ScalarType>;
pub type PublicPoly<C> = Poly<C>;

//// Vector related operations.
/// Vector related operations.
impl<C> Poly<C> {
/// Returns the degree of the polynomial
Expand All @@ -47,7 +47,7 @@ impl<C> From<Poly<C>> for Vec<C> {
}
}

//// GroupElement operations.
/// GroupElement operations.
impl<C: GroupElement> Poly<C> {
/// Returns a polynomial with the zero element.
Expand Down Expand Up @@ -148,7 +148,7 @@ impl<C: GroupElement> Poly<C> {
}
}

//// Scalar operations.
/// Scalar operations.
impl<C: Scalar> Poly<C> {
/// Returns a new polynomial of the given degree where each coefficients is
Expand Down
1 change: 0 additions & 1 deletion fastcrypto-tbls/src/tests/ecies_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ fn test_recovery_package() {
fn test_multi_rec() {
let ro = RandomOracle::new("test");
let keys_and_msg = (0..10u32)
.into_iter()
.map(|i| {
let sk = PrivateKey::<Group>::new(&mut thread_rng());
let pk = PublicKey::<Group>::from_private_key(&sk);
Expand Down
1 change: 0 additions & 1 deletion fastcrypto-tbls/src/tests/nidkg_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type G = G1Element;

pub fn gen_ecies_keys(n: u16) -> Vec<(u16, ecies::PrivateKey<G>, ecies::PublicKey<G>)> {
(0..n)
.into_iter()
.map(|id| {
let sk = ecies::PrivateKey::<G>::new(&mut thread_rng());
let pk = ecies::PublicKey::<G>::from_private_key(&sk);
Expand Down
3 changes: 1 addition & 2 deletions fastcrypto-tbls/src/tests/nodes_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ fn test_reduce() {
let pk = ecies::PublicKey::<RistrettoPoint>::from_private_key(&sk);
for number_of_nodes in [10, 50, 100, 150, 200, 250, 300, 350, 400] {
let node_vec = (0..number_of_nodes)
.into_iter()
.map(|i| Node {
id: i,
pk: pk.clone(),
weight: 5 + i as u16,
weight: 5 + i,
})
.collect();
let nodes = Nodes::new(node_vec).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions fastcrypto-vdf/src/class_group/gmp/compressed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ impl QuadraticForm {
/// length in bits.
pub fn serialized_length(discriminant_in_bits: usize) -> usize {
// The number of 32 bit words needed to represent the discriminant rounded up,
((discriminant_in_bits + 31) / 32
(discriminant_in_bits + 31) / 32
* 3 // a' is two words and t' is one word. Both is divided by g, so the length of g is subtracted from both.
+ 1 // Flags for special forms (identity or generator) and the sign of b and t'.
+ 1 // The size of g - 1 = g_size.
// Two extra bytes for g and b0 (which has the same length). Note that 2 * g_size was already counted.
+ 2) as usize
+ 2
}

/// Serialize a quadratic form. The length of the serialization in bytes depends on the bit-length
Expand Down
4 changes: 2 additions & 2 deletions fastcrypto-zkp/src/bn254/zk_login_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn insecure_pvk() -> PreparedVerifyingKey<Bn254> {

// Create a vector of G1Affine elements from the IC
let mut vk_gamma_abc_g1 = Vec::new();
for e in vec![
for e in [
vec![
"20701306374481714853949730154526815782802808896228594855451770849676897643964"
.to_string(),
Expand Down Expand Up @@ -190,7 +190,7 @@ fn global_pvk() -> PreparedVerifyingKey<Bn254> {

// Create a vector of G1Affine elements from the IC
let mut vk_gamma_abc_g1 = Vec::new();
for e in vec![
for e in [
vec![
"1607694606386445293170795095076356565829000940041894770459712091642365695804"
.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion fastcrypto/benches/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ mod signature_benches {
BenchmarkId::new(name.to_string(), size),
&(test_data.msgs, test_data.public_keys, test_data.signatures),
|b, (m, pks, sigs)| {
let sigs_ref = sigs.iter().map(|m| m.borrow()).collect::<Vec<_>>();
let sigs_ref = sigs.iter().collect::<Vec<_>>();
let msgs_ref = m.iter().map(|m| m.borrow()).collect::<Vec<_>>();
let cloned_pks = pks.clone();
b.iter(|| {
Expand Down
2 changes: 1 addition & 1 deletion fastcrypto/src/bls12381/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Eq for BLS12381PublicKey {}

impl PartialOrd for BLS12381PublicKey {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.as_ref().partial_cmp(other.as_ref())
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion fastcrypto/src/bulletproofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Eq for PedersenCommitment {}

impl PartialOrd for PedersenCommitment {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.as_ref().partial_cmp(other.as_ref())
Some(self.cmp(other))
}
}

Expand Down
4 changes: 2 additions & 2 deletions fastcrypto/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl Debug for Ed25519PublicKey {
}
}

#[allow(clippy::derive_hash_xor_eq)] // ed25519_consensus's PartialEq is compatible
#[allow(clippy::derived_hash_with_manual_eq)] // ed25519_consensus's PartialEq is compatible
impl std::hash::Hash for Ed25519PublicKey {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.as_bytes().hash(state);
Expand All @@ -304,7 +304,7 @@ impl std::hash::Hash for Ed25519PublicKey {

impl PartialOrd for Ed25519PublicKey {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.0.as_bytes().partial_cmp(other.0.as_bytes())
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion fastcrypto/src/secp256k1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl std::hash::Hash for Secp256k1PublicKey {

impl PartialOrd for Secp256k1PublicKey {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.pubkey.partial_cmp(&other.pubkey)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion fastcrypto/src/secp256r1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl std::hash::Hash for Secp256r1PublicKey {

impl PartialOrd for Secp256r1PublicKey {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.pubkey.partial_cmp(&other.pubkey)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.65.0
1.73

0 comments on commit 416e965

Please sign in to comment.