cnfy-uint 0.2.3

Zero-dependency 256-bit unsigned integer arithmetic for cryptographic applications
Documentation
//! Returns the six `u64` limbs in big-endian order.
use super::U384;

impl U384 {
    /// Returns the six `u64` limbs in big-endian order.
    ///
    /// The returned array is `[w0, w1, w2, w3, w4, w5]` where `w0` is the most
    /// significant limb and `w5` is the least significant limb.
    ///
    /// # Examples
    ///
    /// ```
    /// use cnfy_uint::u384::U384;
    ///
    /// let v = U384::from_be_limbs([1, 2, 3, 4, 5, 6]);
    /// assert_eq!(v.to_be_limbs(), [1, 2, 3, 4, 5, 6]);
    /// ```
    #[inline]
    pub const fn to_be_limbs(&self) -> [u64; 6] {
        [
            self.0[5], self.0[4], self.0[3], self.0[2], self.0[1], self.0[0],
        ]
    }
}

#[cfg(test)]
mod ai_tests {
    use super::*;

    /// Round-trip: from_be_limbs then to_be_limbs returns the original array.
    #[test]
    fn round_trip() {
        let arr = [0xA, 0xB, 0xC, 0xD, 0xE, 0xF];
        assert_eq!(U384::from_be_limbs(arr).to_be_limbs(), arr);
    }

    /// Zero round-trip.
    #[test]
    fn zero_round_trip() {
        assert_eq!(U384::from_be_limbs([0; 6]).to_be_limbs(), [0; 6]);
    }
}