Does my annulment mean that my ex and I were living in sin, and are our children illegitimate?
If by “living in sin” you mean fornication–a mortal sin–the answer is no. One requirement of mortal sin is full knowledge of the sin being committed. In a situation where the spouses are unaware of the invalidity of their union–what the Church calls a “putative marriage”–there is no sin of fornication, because this condition is not met.
The Church teaches that children born of a putative marriage (which exists when at least one spouse is convinced of the validity of a marriage and lasts until both are convinced of its invalidity) are considered legitimate, even if the marriage is later declared null (CIC 1137).
Illegitimacy is not a moral or spiritual state. It has no bearing on a child’s soul or salvation. Historically, legitimacy impinged only upon canonical matters, being required for ordination or appointment as a prelate or abbot.