let public key decode failure return an error

instead of throwing an exception
add a test for authenticate with bad pubkey
add a test for registration with broken public key inside