From 2cc861837656212a39f9180cda231e7061a3ed68 Mon Sep 17 00:00:00 2001 From: vnprc Date: Wed, 13 Nov 2024 10:56:51 -0500 Subject: [PATCH] fix: remove unit test and fix nut13::derive_path_from_keyset_id --- crates/cdk/src/nuts/nut02.rs | 11 ----------- crates/cdk/src/nuts/nut13.rs | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/crates/cdk/src/nuts/nut02.rs b/crates/cdk/src/nuts/nut02.rs index c01c9b36..934be23f 100644 --- a/crates/cdk/src/nuts/nut02.rs +++ b/crates/cdk/src/nuts/nut02.rs @@ -495,17 +495,6 @@ mod test { assert_eq!(864559728, id_int) } - #[test] - fn test_to_u64_and_back() { - let id = Id::from_str("009a1f293253e41e").unwrap(); - - let id_long = u64::try_from(id).unwrap(); - assert_eq!(43381408211919902, id_long); - - let new_id = Id::try_from(id_long).unwrap(); - assert_eq!(id, new_id); - } - #[test] fn test_id_from_invalid_byte_length() { let three_bytes = [0x01, 0x02, 0x03]; diff --git a/crates/cdk/src/nuts/nut13.rs b/crates/cdk/src/nuts/nut13.rs index 4383ba13..9cef31ca 100644 --- a/crates/cdk/src/nuts/nut13.rs +++ b/crates/cdk/src/nuts/nut13.rs @@ -170,7 +170,7 @@ impl PreMintSecrets { } fn derive_path_from_keyset_id(id: Id) -> Result { - let index = (u64::try_from(id)? % (2u64.pow(31) - 1)) as u32; + let index = u32::try_from(id)? % (2u32.pow(31) - 1); let keyset_child_number = ChildNumber::from_hardened_idx(index)?; Ok(DerivationPath::from(vec![ ChildNumber::from_hardened_idx(129372)?,