Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with batch and batch_deterministic feature combo #240

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ pub use curve25519_dalek::digest::Digest;

use merlin::Transcript;

#[cfg(all(feature = "batch", not(feature = "batch_deterministic")))]
#[cfg(not(feature = "batch_deterministic"))]
use rand::thread_rng;
use rand::Rng;
#[cfg(all(not(feature = "batch"), feature = "batch_deterministic"))]
#[cfg(feature = "batch_deterministic")]
use rand_core;

use sha2::Sha512;
Expand Down Expand Up @@ -75,10 +75,10 @@ impl BatchTranscript for Transcript {
/// An implementation of `rand_core::RngCore` which does nothing, to provide
/// purely deterministic transcript-based nonces, rather than synthetically
/// random nonces.
#[cfg(all(not(feature = "batch"), feature = "batch_deterministic"))]
#[cfg(feature = "batch_deterministic")]
struct ZeroRng {}

#[cfg(all(not(feature = "batch"), feature = "batch_deterministic"))]
#[cfg(feature = "batch_deterministic")]
impl rand_core::RngCore for ZeroRng {
fn next_u32(&mut self) -> u32 {
rand_core::impls::next_u32_via_fill(self)
Expand All @@ -104,10 +104,10 @@ impl rand_core::RngCore for ZeroRng {
}
}

#[cfg(all(not(feature = "batch"), feature = "batch_deterministic"))]
#[cfg(feature = "batch_deterministic")]
impl rand_core::CryptoRng for ZeroRng {}

#[cfg(all(not(feature = "batch"), feature = "batch_deterministic"))]
#[cfg(feature = "batch_deterministic")]
fn zero_rng() -> ZeroRng {
ZeroRng {}
}
Expand Down Expand Up @@ -261,9 +261,9 @@ pub fn verify_batch(
transcript.append_message_lengths(&message_lengths);
transcript.append_scalars(&scalars);

#[cfg(all(feature = "batch", not(feature = "batch_deterministic")))]
#[cfg(not(feature = "batch_deterministic"))]
let mut prng = transcript.build_rng().finalize(&mut thread_rng());
#[cfg(all(not(feature = "batch"), feature = "batch_deterministic"))]
#[cfg(feature = "batch_deterministic")]
let mut prng = transcript.build_rng().finalize(&mut zero_rng());

// Select a random 128-bit scalar for each signature.
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ mod signature;

pub use curve25519_dalek::digest::Digest;

#[cfg(all(feature = "batch", feature = "batch_deterministic"))]
compile_error!("Features batch and batch_deterministic are mutually exclusive.");

#[cfg(any(feature = "batch", feature = "batch_deterministic"))]
pub use crate::batch::*;
pub use crate::constants::*;
Expand Down