We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 99fba9c commit 951a1fdCopy full SHA for 951a1fd
crates/curves/src/utils.rs
@@ -65,6 +65,23 @@ pub fn biguint_from_le_words(le_words: &[u32]) -> BigUint {
65
BigUint::from_bytes_le(&bytes)
66
}
67
68
+#[inline]
69
+pub fn biguint_to_words(integer: &BigUint, num_words: usize) -> Vec<u32> {
70
+ let mut bytes = integer.to_bytes_le();
71
+ bytes.resize(num_words * 4, 0u8);
72
+ let mut words = Vec::with_capacity(num_words);
73
+ for i in 0..num_words {
74
+ let word = u32::from_le_bytes([
75
+ bytes[4 * i],
76
+ bytes[4 * i + 1],
77
+ bytes[4 * i + 2],
78
+ bytes[4 * i + 3],
79
+ ]);
80
+ words.push(word);
81
+ }
82
+ words
83
+}
84
+
85
#[inline]
86
/// Converts a slice of words to a byte vector in little endian.
87
pub fn words_to_bytes_le_vec(words: &[u32]) -> Vec<u8> {
0 commit comments