Fix bunch of warnings on latest rustc beta (#4161)

This commit is contained in:
Jon Häggblad
2023-11-21 09:02:48 +01:00
committed by GitHub
parent 53fcebfd86
commit 1728de57b9
12 changed files with 16 additions and 24 deletions
@@ -142,7 +142,7 @@ pub fn funds_from_cosmos_msgs(msgs: Vec<CosmosMsg>) -> Option<Coin> {
contract_addr: _,
msg,
funds: _,
})) = msgs.get(0)
})) = msgs.first()
{
if let Ok(ExecuteMsg::ReleaseFunds { funds }) = from_binary::<ExecuteMsg>(msg) {
return Some(funds);
@@ -62,7 +62,7 @@ pub fn owner_from_cosmos_msgs(msgs: &[CosmosMsg]) -> Option<Addr> {
contract_addr: _,
msg,
funds: _,
})) = msgs.get(0)
})) = msgs.first()
{
if let Ok(ExecuteMsg::VerifyVerificationKeyShare { owner, .. }) =
from_binary::<ExecuteMsg>(msg)
@@ -49,7 +49,7 @@ impl Account {
pub fn period_duration(&self) -> Result<u64, VestingContractError> {
self.periods
.get(0)
.first()
.ok_or(VestingContractError::UnpopulatedVestingPeriods {
owner: self.owner_address.clone(),
})
+1 -5
View File
@@ -115,11 +115,7 @@ impl Dealing {
.map(|&node_index| polynomial.evaluate_at(&Scalar::from(node_index)).into())
.collect::<Vec<_>>();
let remote_share_key_pairs = shares
.iter()
.zip(receivers.values())
.map(|(share, key)| (share, key))
.collect::<Vec<_>>();
let remote_share_key_pairs = shares.iter().zip(receivers.values()).collect::<Vec<_>>();
let ordered_public_keys = receivers.values().copied().collect::<Vec<_>>();
let (ciphertexts, hazmat) = encrypt_shares(&remote_share_key_pairs, params, &mut rng);
+1 -1
View File
@@ -50,7 +50,7 @@ where
impl Aggregatable for PartialSignature {
fn aggregate(sigs: &[PartialSignature], indices: Option<&[u64]>) -> Result<Signature> {
let h = sigs
.get(0)
.first()
.ok_or_else(|| CoconutError::Aggregation("Empty set of signatures".to_string()))?
.sig1();
+2 -4
View File
@@ -93,8 +93,7 @@ impl GatewayClient {
) -> Self {
// convert from 1.0 x25519-dalek private key into 2.0 x25519-dalek
#[allow(clippy::expect_used)]
let static_secret = boringtun::x25519::StaticSecret::try_from(local_secret.to_bytes())
.expect("conversion between x25519 private keys is infallible");
let static_secret = boringtun::x25519::StaticSecret::from(local_secret.to_bytes());
let local_public: boringtun::x25519::PublicKey = (&static_secret).into();
let remote_public = boringtun::x25519::PublicKey::from(remote_public.to_bytes());
@@ -123,8 +122,7 @@ impl GatewayClient {
pub fn verify(&self, gateway_key: &PrivateKey, nonce: u64) -> Result<(), Error> {
// convert from 1.0 x25519-dalek private key into 2.0 x25519-dalek
#[allow(clippy::expect_used)]
let static_secret = boringtun::x25519::StaticSecret::try_from(gateway_key.to_bytes())
.expect("conversion between x25519 private keys is infallible");
let static_secret = boringtun::x25519::StaticSecret::from(gateway_key.to_bytes());
let dh = static_secret.diffie_hellman(&self.pub_key);
+2 -2
View File
@@ -31,7 +31,7 @@ fn decode_base64_key(base64_key: &str) -> [u8; 32] {
pub fn server_static_private_key() -> x25519::StaticSecret {
// TODO: this is a temporary solution for development
let static_private_bytes: [u8; 32] = decode_base64_key(PRIVATE_KEY);
let static_private = x25519::StaticSecret::try_from(static_private_bytes).unwrap();
let static_private = x25519::StaticSecret::from(static_private_bytes);
let static_public = x25519::PublicKey::from(&static_private);
info!(
"wg public key: {}",
@@ -47,7 +47,7 @@ pub fn peer_static_public_key() -> x25519::PublicKey {
let peer = std::env::var("NYM_PEER_PUBLIC_KEY").expect("NYM_PEER_PUBLIC_KEY must be set");
let peer_static_public_bytes: [u8; 32] = decode_base64_key(&peer);
let peer_static_public = x25519::PublicKey::try_from(peer_static_public_bytes).unwrap();
let peer_static_public = x25519::PublicKey::from(peer_static_public_bytes);
info!(
"Adding wg peer public key: {}",
general_purpose::STANDARD.encode(peer_static_public)
+1 -1
View File
@@ -136,7 +136,7 @@ pub enum Error {
NotFound(String),
#[error("Configuration file does not exist")]
/// This is returned if IoError happens during configuration file read/write.
IoError(#[from] std::io::Error),
Io(#[from] std::io::Error),
/// This is returned if configuration file is invalid.
#[error("Configuration file is invalid: '{0}'")]
InvalidFormat(String),
+1
View File
@@ -164,6 +164,7 @@ impl Config {
save_formatted_config_to_file(self, config_save_location)
}
#[allow(unused)]
pub fn try_save(&self) -> io::Result<()> {
if let Some(save_location) = &self.save_path {
save_formatted_config_to_file(self, save_location)
+1 -1
View File
@@ -46,7 +46,7 @@ pub async fn extract_encryption_key(
.ok_or(CoconutError::DepositValueNotFound)?
.value
.as_ref();
let deposit_value_plain = public_attributes_plain.get(0).cloned().unwrap_or_default();
let deposit_value_plain = public_attributes_plain.first().cloned().unwrap_or_default();
if deposit_value != deposit_value_plain {
return Err(CoconutError::DifferentPublicAttributes(
deposit_value.to_string(),
@@ -144,13 +144,10 @@ mod test {
.unwrap();
let client_key_pair = encryption::KeyPair::new(&mut rng);
let gateway_static_public =
PublicKey::try_from(gateway_key_pair.public_key().to_bytes()).unwrap();
let gateway_static_public = PublicKey::from(gateway_key_pair.public_key().to_bytes());
let client_static_private =
StaticSecret::try_from(client_key_pair.private_key().to_bytes()).unwrap();
let client_static_public =
PublicKey::try_from(client_key_pair.public_key().to_bytes()).unwrap();
let client_static_private = StaticSecret::from(client_key_pair.private_key().to_bytes());
let client_static_public = PublicKey::from(client_key_pair.public_key().to_bytes());
let client_dh = client_static_private.diffie_hellman(&gateway_static_public);
+1 -1
View File
@@ -302,7 +302,7 @@ impl MixStageParameters {
&nonce.into(),
&[],
&mut buffer[self.header_range()],
tag.as_slice().try_into().unwrap(),
tag.as_slice().into(),
)
.map_err(|e| OutfoxError::ChaCha20Poly1305Error(e.to_string()))?;