diff --git a/src/field.rs b/src/field.rs
index 9ed0aea..7d5bc44 100644
--- a/src/field.rs
+++ b/src/field.rs
@@ -29,6 +29,8 @@ use subtle::byte_is_nonzero;
use subtle::CTAssignable;
use subtle::CTEq;
+use utils::{load3, load4};
+
/// FieldElements are represented as an array of ten "Limbs", which are radix
/// 25.5, that is, each Limb of a FieldElement alternates between being
/// represented as a factor of 2^25 or 2^26 more than the last corresponding
@@ -193,25 +195,6 @@ impl CTAssignable for FieldElement {
}
}
-/// Convert an array of (at least) three bytes into an i64.
-#[inline]
-#[allow(dead_code)]
-pub fn load3(input: &[u8]) -> i64 {
- (input[0] as i64)
- | ((input[1] as i64) << 8)
- | ((input[2] as i64) << 16)
-}
-
-/// Convert an array of (at least) four bytes into an i64.
-#[inline]
-#[allow(dead_code)]
-pub fn load4(input: &[u8]) -> i64 {
- (input[0] as i64)
- | ((input[1] as i64) << 8)
- | ((input[2] as i64) << 16)
- | ((input[3] as i64) << 24)
-}
-
impl FieldElement {
/// Invert the sign of this field element
pub fn negate(&mut self) {
diff --git a/src/lib.rs b/src/lib.rs
index 2007ada..7855923 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -50,6 +50,7 @@ pub mod scalar;
// Constant-time functions and other miscelaneous utilities.
pub mod subtle;
+pub mod utils;
// Low-level curve and point constants, as well as pre-computed curve group elements.
diff --git a/src/scalar.rs b/src/scalar.rs
index a1ec8d0..85c77be 100644
--- a/src/scalar.rs
+++ b/src/scalar.rs
@@ -36,9 +36,8 @@ use core::ops::{Neg};
#[cfg(feature = "std")]
use rand::Rng;
-// XXX should these be in a utility module ?
use constants;
-use field::{load3, load4};
+use utils::{load3, load4};
use subtle::CTAssignable;
use subtle::CTEq;
use subtle::arrays_equal_ct;
diff --git a/src/utils.rs b/src/utils.rs
new file mode 100644
index 0000000..ad53166
--- /dev/null
+++ b/src/utils.rs
@@ -0,0 +1,31 @@
+// -*- mode: rust; -*-
+//
+// To the extent possible under law, the authors have waived all copyright and
+// related or neighboring rights to curve25519-dalek, using the Creative
+// Commons "CC0" public domain dedication. See
+// for full details.
+//
+// Authors:
+// - Isis Agora Lovecruft
+// - Henry de Valence
+
+//! Miscellaneous common utility function.
+
+/// Convert an array of (at least) three bytes into an i64.
+#[inline]
+//#[allow(dead_code)]
+pub fn load3(input: &[u8]) -> i64 {
+ (input[0] as i64)
+ | ((input[1] as i64) << 8)
+ | ((input[2] as i64) << 16)
+}
+
+/// Convert an array of (at least) four bytes into an i64.
+#[inline]
+//#[allow(dead_code)]
+pub fn load4(input: &[u8]) -> i64 {
+ (input[0] as i64)
+ | ((input[1] as i64) << 8)
+ | ((input[2] as i64) << 16)
+ | ((input[3] as i64) << 24)
+}