diff --git a/Cargo.toml b/Cargo.toml index c164472..556dd79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,12 +36,10 @@ version = "^0.6" version = "0.4" [features] -nightly = ["basepoint_table_creation", "radix_51"] +nightly = ["radix_51"] default = ["std"] std = ["rand"] yolocrypto = [] -# Needs nightly for placement new -basepoint_table_creation = [] bench = [] # Radix-51 arithmetic using u128 radix_51 = [] diff --git a/src/curve.rs b/src/curve.rs index c56dd25..3a5ab52 100644 --- a/src/curve.rs +++ b/src/curve.rs @@ -92,11 +92,6 @@ use subtle::CTAssignable; use subtle::CTEq; use subtle::CTNegatable; -#[cfg(all(not(feature = "std"), feature = "basepoint_table_creation"))] -use collections::boxed::Box; -#[cfg(all(feature = "std", feature = "basepoint_table_creation"))] -use std::boxed::Box; - // ------------------------------------------------------------------------ // Compressed points // ------------------------------------------------------------------------ @@ -877,12 +872,11 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a EdwardsBasepointTable { impl EdwardsBasepointTable { /// Create a table of precomputed multiples of `basepoint`. - #[cfg(feature="basepoint_table_creation")] - pub fn create(basepoint: &ExtendedPoint) -> Box { + pub fn create(basepoint: &ExtendedPoint) -> EdwardsBasepointTable { // Create the table storage - // XXX can we be assured that this is not allocated on the stack? // XXX can we skip the initialization without too much unsafety? - let mut table = box EdwardsBasepointTable([[AffineNielsPoint::identity(); 8]; 32]); + // stick 30K on the stack and call it a day. + let mut table = EdwardsBasepointTable([[AffineNielsPoint::identity(); 8]; 32]); let mut P = basepoint.clone(); for i in 0..32 { // P = (16^2)^i * B @@ -894,7 +888,7 @@ impl EdwardsBasepointTable { } P = P.mult_by_pow_2(8); } - return table + table } } @@ -1352,7 +1346,7 @@ mod test { fn test_precomputed_basepoint_mult() { let table = EdwardsBasepointTable::create(&constants::ED25519_BASEPOINT); let aB_1 = &constants::ED25519_BASEPOINT_TABLE * &A_SCALAR; - let aB_2 = &(*table) * &A_SCALAR; + let aB_2 = &table * &A_SCALAR; assert_eq!(aB_1.compress_edwards(), aB_2.compress_edwards()); } diff --git a/src/decaf.rs b/src/decaf.rs index 1023b26..a0514ae 100644 --- a/src/decaf.rs +++ b/src/decaf.rs @@ -32,11 +32,6 @@ use subtle::CTNegatable; use core::ops::{Add, Sub, Neg}; use core::ops::{Mul, MulAssign}; -#[cfg(all(not(feature = "std"), feature = "basepoint_table_creation"))] -use collections::boxed::Box; -#[cfg(all(feature = "std", feature = "basepoint_table_creation"))] -use std::boxed::Box; - use curve; use curve::ExtendedPoint; use curve::EdwardsBasepointTable; @@ -278,10 +273,8 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a DecafBasepointTable { impl DecafBasepointTable { /// Create a precomputed table of multiples of the given `basepoint`. - #[cfg(feature = "basepoint_table_creation")] - pub fn create(basepoint: &DecafPoint) -> Box { - let edwards_table = EdwardsBasepointTable::create(&basepoint.0); - box DecafBasepointTable(*edwards_table) + pub fn create(basepoint: &DecafPoint) -> DecafBasepointTable { + DecafBasepointTable(EdwardsBasepointTable::create(&basepoint.0)) } } diff --git a/src/lib.rs b/src/lib.rs index 31e7177..40efe8b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,10 +11,10 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), feature(collections))] -#![cfg_attr(feature = "nightly", feature(box_syntax))] #![cfg_attr(feature = "nightly", feature(i128_type))] -#![allow(unused_features)] #![cfg_attr(feature = "bench", feature(test))] + +#![allow(unused_features)] #![deny(missing_docs)] // refuse to compile if documentation is missing //! # curve25519-dalek