mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-05 20:30:57 +00:00
Remove catchall 'utils' module
This commit is contained in:
parent
e4f5f23b8d
commit
6ce7a4ee2d
4 changed files with 11 additions and 52 deletions
2
build.rs
2
build.rs
|
|
@ -48,8 +48,6 @@ mod montgomery;
|
||||||
mod edwards;
|
mod edwards;
|
||||||
#[path="src/ristretto.rs"]
|
#[path="src/ristretto.rs"]
|
||||||
mod ristretto;
|
mod ristretto;
|
||||||
#[path="src/utils.rs"]
|
|
||||||
mod utils;
|
|
||||||
|
|
||||||
#[path="src/constants.rs"]
|
#[path="src/constants.rs"]
|
||||||
mod constants;
|
mod constants;
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,6 @@ use core::ops::Neg;
|
||||||
|
|
||||||
use subtle::ConditionallyAssignable;
|
use subtle::ConditionallyAssignable;
|
||||||
|
|
||||||
use utils::load8;
|
|
||||||
|
|
||||||
/// In the 64-bit implementation, field elements are represented in
|
/// In the 64-bit implementation, field elements are represented in
|
||||||
/// radix 2^51 as five `u64`s.
|
/// radix 2^51 as five `u64`s.
|
||||||
pub type Limb = u64;
|
pub type Limb = u64;
|
||||||
|
|
@ -247,6 +245,17 @@ impl FieldElement64 {
|
||||||
/// canonical.
|
/// canonical.
|
||||||
///
|
///
|
||||||
pub fn from_bytes(bytes: &[u8; 32]) -> FieldElement64 {
|
pub fn from_bytes(bytes: &[u8; 32]) -> FieldElement64 {
|
||||||
|
let load8 = |input: &[u8]| -> u64 {
|
||||||
|
(input[0] as u64)
|
||||||
|
| ((input[1] as u64) << 8)
|
||||||
|
| ((input[2] as u64) << 16)
|
||||||
|
| ((input[3] as u64) << 24)
|
||||||
|
| ((input[4] as u64) << 32)
|
||||||
|
| ((input[5] as u64) << 40)
|
||||||
|
| ((input[6] as u64) << 48)
|
||||||
|
| ((input[7] as u64) << 56)
|
||||||
|
};
|
||||||
|
|
||||||
let low_51_bit_mask = (1u64 << 51) - 1;
|
let low_51_bit_mask = (1u64 << 51) - 1;
|
||||||
FieldElement64(
|
FieldElement64(
|
||||||
// load bits [ 0, 64), no shift
|
// load bits [ 0, 64), no shift
|
||||||
|
|
|
||||||
|
|
@ -80,10 +80,6 @@ pub mod montgomery;
|
||||||
|
|
||||||
pub mod ristretto;
|
pub mod ristretto;
|
||||||
|
|
||||||
// Other miscelaneous utilities.
|
|
||||||
|
|
||||||
mod utils;
|
|
||||||
|
|
||||||
// Low-level curve and point constants, as well as pre-computed curve group elements.
|
// Low-level curve and point constants, as well as pre-computed curve group elements.
|
||||||
|
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
|
|
|
||||||
44
src/utils.rs
44
src/utils.rs
|
|
@ -1,44 +0,0 @@
|
||||||
// -*- mode: rust; -*-
|
|
||||||
//
|
|
||||||
// This file is part of curve25519-dalek.
|
|
||||||
// Copyright (c) 2016-2017 Isis Lovecruft, Henry de Valence
|
|
||||||
// See LICENSE for licensing information.
|
|
||||||
//
|
|
||||||
// Authors:
|
|
||||||
// - Isis Agora Lovecruft <isis@patternsinthevoid.net>
|
|
||||||
// - Henry de Valence <hdevalence@hdevalence.ca>
|
|
||||||
|
|
||||||
//! Miscellaneous common utility functions.
|
|
||||||
|
|
||||||
/// 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert an array of (at least) eight bytes into a u64.
|
|
||||||
#[inline]
|
|
||||||
//#[allow(dead_code)]
|
|
||||||
pub fn load8(input: &[u8]) -> u64 {
|
|
||||||
(input[0] as u64)
|
|
||||||
| ((input[1] as u64) << 8)
|
|
||||||
| ((input[2] as u64) << 16)
|
|
||||||
| ((input[3] as u64) << 24)
|
|
||||||
| ((input[4] as u64) << 32)
|
|
||||||
| ((input[5] as u64) << 40)
|
|
||||||
| ((input[6] as u64) << 48)
|
|
||||||
| ((input[7] as u64) << 56)
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue