Yes, that's to compensate if a RSAerror that is caught in the rescue clause. Basically we will generate a new key until one doesn't give the error "data too large for modulus".

If you have a better solution I'd appreciate it, but I don't know exactly what's the best option here