From eca2d9e1ea2a5e7a80941227f76551b538fe3198 Mon Sep 17 00:00:00 2001 From: Marvin Jones Date: Mon, 1 Jun 2026 15:23:06 -0400 Subject: [PATCH] clippy and fmt fixes --- .../key_management/key_tree/keys_public.rs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/key_protocol/src/key_management/key_tree/keys_public.rs b/key_protocol/src/key_management/key_tree/keys_public.rs index 322dd66a..de4fb726 100644 --- a/key_protocol/src/key_management/key_tree/keys_public.rs +++ b/key_protocol/src/key_management/key_tree/keys_public.rs @@ -14,7 +14,7 @@ pub struct ChildKeysPublic { pub pk: nssa::PublicKey, pub cc: [u8; 32], /// Can be [`None`] if root. - pub ci: Option, + pub cci: Option, } impl ChildKeysPublic { @@ -40,13 +40,13 @@ impl ChildKeysPublic { ssk, pk, cc, - ci: None, + cci: None, } } #[must_use] - pub fn nth_child(&self, ci: u32) -> Self { - let hash_value = self.compute_hash_value(ci); + pub fn nth_child(&self, cci: u32) -> Self { + let hash_value = self.compute_hash_value(cci); let lhs = k256::Scalar::from_repr( (*hash_value @@ -55,8 +55,8 @@ impl ChildKeysPublic { .into(), ) .expect("Expect a valid k256 scalar"); - let rhs = k256::Scalar::from_repr((*self.sk.value()).into()) - .expect("Expect a valid k256 scalar"); + let rhs = + k256::Scalar::from_repr((*self.sk.value()).into()).expect("Expect a valid k256 scalar"); let sk = nssa::PrivateKey::try_new(lhs.add(&rhs).to_bytes().into()) .expect("Expect a valid private key"); @@ -74,7 +74,7 @@ impl ChildKeysPublic { ssk, pk, cc, - ci: Some(ci), + cci: Some(cci), } } @@ -83,7 +83,7 @@ impl ChildKeysPublic { nssa::AccountId::from(&self.pk) } - fn compute_hash_value(&self, ci: u32) -> [u8; 64] { + fn compute_hash_value(&self, cci: u32) -> [u8; 64] { let mut hash_input = vec![]; // Simplified key logic by only supporting harden keys. // Non-harden keys would require access to untweaked public keys associated to `sk`s. @@ -92,7 +92,7 @@ impl ChildKeysPublic { hash_input.extend_from_slice(self.sk.value()); #[expect(clippy::big_endian_bytes, reason = "BIP-032 uses big endian")] - hash_input.extend_from_slice(&ci.to_be_bytes()); + hash_input.extend_from_slice(&cci.to_be_bytes()); hmac_sha512::HMAC::mac(hash_input, self.cc) } @@ -113,8 +113,8 @@ impl KeyTreeNode for ChildKeysPublic { Self::root(seed) } - fn derive_child(&self, ci: u32) -> Self { - self.nth_child(ci) + fn derive_child(&self, cci: u32) -> Self { + self.nth_child(cci) } fn account_ids(&self) -> impl Iterator { @@ -176,8 +176,8 @@ mod tests { 187, 148, 92, 44, 253, 210, 37, ]; let root_keys = ChildKeysPublic::root(seed); - let ci = (2_u32).pow(31) + 13; - let child_keys = ChildKeysPublic::nth_child(&root_keys, ci); + let cci = (2_u32).pow(31) + 13; + let child_keys = ChildKeysPublic::nth_child(&root_keys, cci); let expected_cc = [ 149, 226, 13, 4, 194, 12, 69, 29, 9, 234, 209, 119, 98, 4, 128, 91, 37, 103, 192, 31,