From c5c95513f23bfbc7db29ce9baa6068117ddc301b Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 9 Sep 2021 20:01:59 +1000 Subject: [PATCH] Move helper function below usage This is not C89. We can declare the more important things first. --- src/schnorr.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/schnorr.rs b/src/schnorr.rs index 07ac896..0441cad 100644 --- a/src/schnorr.rs +++ b/src/schnorr.rs @@ -277,25 +277,6 @@ mod tests { }}; } - fn test_schnorrsig_sign_helper( - sign: fn(&Secp256k1, &Message, &KeyPair, &mut ThreadRng) -> Signature, - ) { - let secp = Secp256k1::new(); - - let mut rng = thread_rng(); - let (seckey, pubkey) = secp.generate_schnorrsig_keypair(&mut rng); - let mut msg = [0u8; 32]; - - for _ in 0..100 { - rng.fill_bytes(&mut msg); - let msg = Message::from_slice(&msg).unwrap(); - - let sig = sign(&secp, &msg, &seckey, &mut rng); - - assert!(secp.verify_schnorr(&sig, &msg, &pubkey).is_ok()); - } - } - #[test] fn test_schnorrsig_sign_with_aux_rand_verify() { test_schnorrsig_sign_helper(|secp, msg, seckey, rng| { @@ -326,6 +307,25 @@ mod tests { }) } + fn test_schnorrsig_sign_helper( + sign: fn(&Secp256k1, &Message, &KeyPair, &mut ThreadRng) -> Signature, + ) { + let secp = Secp256k1::new(); + + let mut rng = thread_rng(); + let (seckey, pubkey) = secp.generate_schnorrsig_keypair(&mut rng); + let mut msg = [0u8; 32]; + + for _ in 0..100 { + rng.fill_bytes(&mut msg); + let msg = Message::from_slice(&msg).unwrap(); + + let sig = sign(&secp, &msg, &seckey, &mut rng); + + assert!(secp.verify_schnorr(&sig, &msg, &pubkey).is_ok()); + } + } + #[test] #[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs fn test_schnorrsig_sign() {