mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
Feature-gate basepoint table creation on a nightly feature
This commit is contained in:
parent
049556147f
commit
2610ab872a
3 changed files with 9 additions and 4 deletions
|
|
@ -33,9 +33,12 @@ version = "^0.6"
|
|||
version = "0.4"
|
||||
|
||||
[features]
|
||||
nightly = ["basepoint_table_creation"]
|
||||
default = ["std"]
|
||||
std = ["rand"]
|
||||
yolocrypto = []
|
||||
# Needs nightly for placement new
|
||||
basepoint_table_creation = []
|
||||
|
||||
# The development profile, used for `cargo build`.
|
||||
[profile.dev]
|
||||
|
|
|
|||
|
|
@ -81,9 +81,6 @@ use core::fmt::Debug;
|
|||
use core::iter::Iterator;
|
||||
use core::ops::{Add, Sub, Neg};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::boxed::Box;
|
||||
|
||||
use constants;
|
||||
use field::FieldElement;
|
||||
use scalar::Scalar;
|
||||
|
|
@ -95,6 +92,8 @@ use subtle::CTNegatable;
|
|||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use collections::boxed::Box;
|
||||
#[cfg(feature = "std")]
|
||||
use std::boxed::Box;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Compressed points
|
||||
|
|
@ -831,6 +830,7 @@ pub struct EdwardsBasepointTable(pub [[AffineNielsPoint; 8]; 32]);
|
|||
|
||||
impl EdwardsBasepointTable {
|
||||
/// Create a table of precomputed multiples of `basepoint`.
|
||||
#[cfg(feature="basepoint_table_creation")]
|
||||
pub fn create(basepoint: &ExtendedPoint) -> Box<EdwardsBasepointTable> {
|
||||
// Create the table storage
|
||||
// XXX can we be assured that this is not allocated on the stack?
|
||||
|
|
@ -1312,6 +1312,7 @@ mod test {
|
|||
|
||||
/// Test precomputed basepoint mult
|
||||
#[test]
|
||||
#[cfg(feature="basepoint_table_creation")]
|
||||
fn test_precomputed_basepoint_mult() {
|
||||
let table = EdwardsBasepointTable::create(&constants::ED25519_BASEPOINT);
|
||||
let aB_1 = ExtendedPoint::basepoint_mult(&A_SCALAR);
|
||||
|
|
@ -1487,6 +1488,7 @@ mod bench {
|
|||
b.iter(|| p1.mult_by_cofactor() );
|
||||
}
|
||||
|
||||
#[cfg(feature="basepoint_table_creation")]
|
||||
#[bench]
|
||||
fn create_basepoint_table(b: &mut Bencher) {
|
||||
let aB = ExtendedPoint::basepoint_mult(&A_SCALAR);
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![cfg_attr(not(feature = "std"), feature(collections))]
|
||||
#![cfg_attr(feature = "nightly", feature(box_syntax))]
|
||||
#![allow(unused_features)]
|
||||
#![feature(test)]
|
||||
#![feature(box_syntax)]
|
||||
#![deny(missing_docs)] // refuse to compile if documentation is missing
|
||||
|
||||
//! # curve25519-dalek
|
||||
|
|
|
|||
Loading…
Reference in a new issue