mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
Remove boxes
This commit is contained in:
parent
0678e619cc
commit
127169c151
4 changed files with 10 additions and 25 deletions
|
|
@ -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 = []
|
||||
|
|
|
|||
16
src/curve.rs
16
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<EdwardsBasepointTable> {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
|||
11
src/decaf.rs
11
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<DecafBasepointTable> {
|
||||
let edwards_table = EdwardsBasepointTable::create(&basepoint.0);
|
||||
box DecafBasepointTable(*edwards_table)
|
||||
pub fn create(basepoint: &DecafPoint) -> DecafBasepointTable {
|
||||
DecafBasepointTable(EdwardsBasepointTable::create(&basepoint.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue