Refactoring in order to use cs_random_key, hashed_public_key, cs-serial-no and cs-pin correctly