diff --git a/benches/ed25519_benchmarks.rs b/benches/ed25519_benchmarks.rs index 45dce35..aa1087c 100644 --- a/benches/ed25519_benchmarks.rs +++ b/benches/ed25519_benchmarks.rs @@ -69,7 +69,7 @@ mod ed25519_benches { } fn verify_batch_signatures(c: &mut Criterion) { - static BATCH_SIZES: [usize; 8] = [4, 8, 16, 32, 64, 96, 128, 256]; + static BATCH_SIZES: [usize; 11] = [0, 1, 2, 4, 8, 16, 32, 64, 96, 128, 256]; c.bench_function_over_inputs( "Ed25519 batch signature verification", diff --git a/src/batch.rs b/src/batch.rs index 3a4b8e9..8c500ac 100644 --- a/src/batch.rs +++ b/src/batch.rs @@ -235,6 +235,15 @@ pub fn verify_batch( }.into()); } + // If we have been given a trivial batch size, we can exit early + // without going through the trouble of batch verification. + if signatures.len() == 0 { + return Ok(()); + } else if signatures.len() == 1 { + use crate::ed25519::signature::Verifier; + return public_keys[0].verify(messages[0], &signatures[0]); + } + // Convert all signatures to `InternalSignature` let signatures = signatures .iter()