Answered by Shaykh Muhammad ibn Adam al-Kawthari
Unfortunately, a number of years ago I was involved in a sin which I later found out also breaks a fast. I have no idea how many fasts were broken by this sin as I never use to commit the sin on a daily basis.
In the name of Allah, Most Compassionate, Most Merciful,
Acts that nullify the fast are of two kinds. Some nullifying acts not only make one liable to make up for them later (qadha), but also make one responsible to an expiation (kaffara). These acts are only three:
1) Eating something,
2) Drinking something,
3) Engaging in sexual intercourse.
These three acts make one liable to a Kaffara when they are committed deliberately and intentionally, and after one has already started the fast, provided the person committing these acts has the knowledge that they nullify the fast, and that one was not forced into committing this due to some reason, such as illness. (See: Maraqi al-Falah, p. 663-664)
There are other nullifying acts that only make Qadha necessary and not Kaffara. Examples of such acts are:
1) Eating or drinking unintentionally, e.g. water entering into the throat unintentionally whilst performing ablution,
3) Emission of semen whilst touching, kissing or caressing a woman,
5) Eating or drinking under the wrong impression that the sun has set or the dawn has not yet set in. (Maraqi al-Falah)
Keeping the above in mind, if the sin (you mention that you committed) is from the first category, then you will have to make up for all of the fasts, plus a Kaffara, which is fasting for sixty days continuously.
However, if the sin is from the second set of examples, then you only need to make up for the actual fasts that were broken. If you are unaware of how many fasts were broken, then make a precautionary estimation and then start making up for them. Also repent to Allah Almighty and seek His forgiveness.
Finally, the fasts you kept in the recent years after abstaining from the sin will not be affected due to the sin, unless there was something else wrong that nullified them. You don’t need to worry too much, rather repent to Allah Most High, and then start making up for the missed fasts.
And Allah knows best
Muhammad ibn Adam al-Kawthari