setting phase key and grain