Change the way to generate and validate the nonce and state value