xs_getPubkeyHash now finds key by header & footer

The function assumed that the key would be in the provided buffer with
no extra bytes before the header or after the footer. If the user called
with just one extra byte after the footer, it was calculating the wrong
hash. The new implementaion explicitly looks for the key within the
header and footer.