Fix secret key encode and add secret key hash

I fixed secret key encoding and decoding becuase before the secret key encode functions encoded and decoded the public key stored inside the secret key.
I also made a secret key hash funciton based on the public key hash function.