lib: reference Tonelli-Shanks implementation