Use `verify_raw` rather than `verify` to check signatures

`verify` cannot handle illegally padded signatures because it takes an object
of type `Signature`, which is a fixed-size type. This should have been part
of the previous commit --- an important lesson about running the unit tests
before every push!
This commit is contained in:
Andrew Poelstra 2014-09-04 20:34:58 -05:00
parent 20ce3721b7
commit 331e555e4c
1 changed files with 1 additions and 3 deletions

View File

@ -36,7 +36,6 @@ use crypto::sha1::Sha1;
use crypto::sha2::Sha256;
use secp256k1::Secp256k1;
use secp256k1::Signature;
use secp256k1::key::PublicKey;
use blockdata::opcodes;
@ -1466,8 +1465,7 @@ fn check_signature(sig_slice: &[u8], pk_slice: &[u8], script: Vec<u8>,
serialize(&Sha256dHash::from_data(data_to_sign.as_slice())).unwrap()
};
let sig = try!(Signature::from_slice(sig_slice).map_err(EcdsaError));
Secp256k1::verify(signature_hash.as_slice(), &sig, &pubkey).map_err(EcdsaError)
Secp256k1::verify_raw(signature_hash.as_slice(), sig_slice, &pubkey).map_err(EcdsaError)
}
// Macro to translate English stack instructions into Rust code.