refactor
coding style
only compare once and do it in constant time
rename `hash` to `nonce`