move edit_key generation to models