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