From bd082f2cda0d43e6d8e9e24d71153f061a045b27 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 3 Feb 2021 21:57:49 -0600 Subject: [PATCH] Add a better error message for bypassing the curve25519 feature --- src/lib.rs | 6 ++++++ src/traits.rs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3e7719f..36d3d32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,12 @@ //! For complete examples, look at //! [the tests directory](https://github.com/PlasmaPower/brute-force/tree/master/src/tests). +#[cfg(feature = "curve25519-dalek")] +#[cfg(not(feature = "curve25519"))] +compile_error!( + "Enable brute-force curve25519 support via the `curve25519` feature, not `curve25519-dalek`", +); + use log::warn; use std::{ sync::atomic::{self, AtomicBool}, diff --git a/src/traits.rs b/src/traits.rs index f463b99..d33020d 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -50,14 +50,14 @@ impl_for_primitive!(u32, i32); impl_for_primitive!(u64, i64); impl_for_primitive!(u128, i128); -#[cfg(feature = "curve25519-dalek")] +#[cfg(feature = "curve25519")] impl Start for curve25519_dalek::scalar::Scalar { fn start_for_thread(_thread: usize, _thread_count: usize) -> Self { Self::random(&mut rand::rngs::OsRng) } } -#[cfg(feature = "curve25519-dalek")] +#[cfg(feature = "curve25519")] impl Advance for curve25519_dalek::scalar::Scalar { fn advance(&mut self) { *self += curve25519_dalek::scalar::Scalar::one();