fix(crypto): Use the from constructor for some maps with known values

This commit is contained in:
Damir Jelić
2021-11-23 11:30:36 +01:00
parent 1e70b4f804
commit be70d38e2a
2 changed files with 12 additions and 15 deletions

View File

@@ -746,17 +746,16 @@ impl ReadOnlyAccount {
pub(crate) fn unsigned_device_keys(&self) -> DeviceKeys {
let identity_keys = self.identity_keys();
let mut keys = BTreeMap::new();
keys.insert(
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Curve25519, &self.device_id),
identity_keys.curve25519().to_owned(),
);
keys.insert(
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, &self.device_id),
identity_keys.ed25519().to_owned(),
);
let keys = BTreeMap::from([
(
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Curve25519, &self.device_id),
identity_keys.curve25519().to_owned(),
),
(
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, &self.device_id),
identity_keys.ed25519().to_owned(),
),
]);
DeviceKeys::new(
(*self.user_id).clone(),

View File

@@ -397,13 +397,11 @@ impl Signing {
}
pub fn cross_signing_key(&self, user_id: UserId, usage: KeyUsage) -> CrossSigningKey {
let mut keys = BTreeMap::new();
keys.insert(
let keys = BTreeMap::from([(
DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, self.public_key().as_str().into())
.to_string(),
self.public_key().to_string(),
);
)]);
CrossSigningKey::new(user_id, vec![usage], keys, BTreeMap::new())
}