Protect against A==0 or B==0 (mod N), or other non-group-elements. Closes #6.