modified MessageKeysGen