Honest players in ZKP proofs
In the example you mentioned, you must have an honest verifier, because a dishonest verifier would be able to extract the witness (see).
It is important to remark that there are transformations from honest to dishonest protocols, therefore studying honest protocols makes sense in practice. You may find this useful.