pub fn verify_hash_signature(
data_hash: &[u8],
signature: &[u8],
public_key_hash: &[u8],
platform_version: &PlatformVersion,
) -> Result<Result<(), Error>, ProtocolError>Expand description
Checks that signature, a 65-byte compact recoverable ECDSA signature over data_hash, was
made by the key whose HASH160 is public_key_hash, by recovering the key: an ECDSA_HASH160
identity key, a P2PKH address witness, an asset lock’s one-time key.
Recovery alone leaves a third party two ways to turn a valid signature into another valid one, and so to change the hash of the transition carrying it:
- it takes any S, so the signature stays valid with S replaced by
n - Sand the recovery id’s parity flipped; - it hashes the recovered key in its compressed form whatever the header says, so the
signature stays valid with its header rewritten from
31 + id(a compressed key) to27 + id(an uncompressed one).
§Parameters
data_hash: the 32-byte digest that was signed.signature: the compact recoverable signature.public_key_hash: the HASH160 of the compressed public key expected to have signed.platform_version: selects the rule throughdpp.state_transition_method_versions.verify_hash_signature. 0 isdashcore::signer::verify_hash_signature, which accepts both rewrites (protocol versions 1 to 14); 1 also refuses a high-S signature and a header that does not name a compressed key.
§Returns
Ok(Ok(())) when the signature is valid, Ok(Err(_)) with the reason when it is not, and
Err(ProtocolError::UnknownVersionMismatch) for a version this build does not know.