Skip to content

Commit

Permalink
Remove unused error return value
Browse files Browse the repository at this point in the history
This helper never returns an error, remove the `Result` return type.
Found by clippy.
  • Loading branch information
tcharding committed Dec 22, 2020
1 parent ed29f12 commit e42f3f8
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/schnorrsig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl<C: Signing> Secp256k1<C> {
msg: &Message,
keypair: &KeyPair,
nonce_data: *const ffi::types::c_void,
) -> Result<Signature, Error> {
) -> Signature {
unsafe {
let mut sig = [0u8; constants::SCHNORRSIG_SIGNATURE_SIZE];
assert_eq!(
Expand All @@ -399,15 +399,15 @@ impl<C: Signing> Secp256k1<C> {
)
);

Ok(Signature(sig))
Signature(sig)
}
}

/// Create a schnorr signature internally using the ThreadRng random number
/// generator to generate the auxiliary random data.
/// Requires compilation with "rand-std" feature.
#[cfg(any(test, feature = "rand-std"))]
pub fn schnorrsig_sign(&self, msg: &Message, keypair: &KeyPair) -> Result<Signature, Error> {
pub fn schnorrsig_sign(&self, msg: &Message, keypair: &KeyPair) -> Signature {
let mut rng = thread_rng();
self.schnorrsig_sign_with_rng(msg, keypair, &mut rng)
}
Expand All @@ -417,7 +417,7 @@ impl<C: Signing> Secp256k1<C> {
&self,
msg: &Message,
keypair: &KeyPair,
) -> Result<Signature, Error> {
) -> Signature {
self.schnorrsig_sign_helper(msg, keypair, ptr::null())
}

Expand All @@ -427,7 +427,7 @@ impl<C: Signing> Secp256k1<C> {
msg: &Message,
keypair: &KeyPair,
aux_rand: &[u8; 32],
) -> Result<Signature, Error> {
) -> Signature {
self.schnorrsig_sign_helper(
msg,
keypair,
Expand All @@ -444,7 +444,7 @@ impl<C: Signing> Secp256k1<C> {
msg: &Message,
keypair: &KeyPair,
rng: &mut R,
) -> Result<Signature, Error> {
) -> Signature {
let mut aux = [0u8; 32];
rng.fill_bytes(&mut aux);
self.schnorrsig_sign_helper(msg, keypair, aux.as_c_ptr() as *const ffi::types::c_void)
Expand Down Expand Up @@ -533,29 +533,27 @@ mod tests {
let mut aux_rand = [0; 32];
rng.fill_bytes(&mut aux_rand);
secp.schnorrsig_sign_with_aux_rand(msg, seckey, &aux_rand)
.unwrap()
})
}

#[test]
fn test_schnorrsig_sign_with_rng_verify() {
test_schnorrsig_sign_helper(|secp, msg, seckey, mut rng| {
secp.schnorrsig_sign_with_rng(msg, seckey, &mut rng)
.unwrap()
})
}

#[test]
fn test_schnorrsig_sign_verify() {
test_schnorrsig_sign_helper(|secp, msg, seckey, _| {
secp.schnorrsig_sign(msg, seckey).unwrap()
secp.schnorrsig_sign(msg, seckey)
})
}

#[test]
fn test_schnorrsig_sign_no_aux_rand_verify() {
test_schnorrsig_sign_helper(|secp, msg, seckey, _| {
secp.schnorrsig_sign_no_aux_rand(msg, seckey).unwrap()
secp.schnorrsig_sign_no_aux_rand(msg, seckey)
})
}

Expand All @@ -575,8 +573,7 @@ mod tests {
let expected_sig = Signature::from_str("6470FD1303DDA4FDA717B9837153C24A6EAB377183FC438F939E0ED2B620E9EE5077C4A8B8DCA28963D772A94F5F0DDF598E1C47C137F91933274C7C3EDADCE8").unwrap();

let sig = secp
.schnorrsig_sign_with_aux_rand(&msg, &sk, &aux_rand)
.unwrap();
.schnorrsig_sign_with_aux_rand(&msg, &sk, &aux_rand);

assert_eq!(expected_sig, sig);
}
Expand Down

0 comments on commit e42f3f8

Please sign in to comment.