From 3b0f5cee4bf9204fa17c292750c3bc9cd3dc032d Mon Sep 17 00:00:00 2001 From: Filipe Casal Date: Tue, 24 Feb 2026 23:33:10 +0000 Subject: [PATCH] fix: use correct byte order in `NonZero::from_le_byte_array` --- src/non_zero.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/non_zero.rs b/src/non_zero.rs index feb8299ce..8657d8b7c 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -387,9 +387,9 @@ where Self::new(T::from_be_byte_array(bytes)) } - /// Decode a non-zero integer from big endian bytes. + /// Decode a non-zero integer from little endian bytes. pub fn from_le_byte_array(bytes: ByteArray) -> CtOption { - Self::new(T::from_be_byte_array(bytes)) + Self::new(T::from_le_byte_array(bytes)) } } @@ -721,4 +721,14 @@ mod tests { NonZero::::one() ); } + + #[cfg(feature = "hybrid-array")] + #[test] + fn from_le_byte_array() { + assert_eq!( + NonZero::::from_le_byte_array(hex!("01000000000000000000000000000000").into()) + .unwrap(), + NonZero::::ONE + ); + } }