The vulnerability is a denial of service in the gnark-crypto library, which is a dependency of gnark. The issue stems from the HalfGCD function, used for scalar decomposition in the fake-GLV algorithm, entering a near-infinite loop for specific inputs.
The root cause of this non-terminating loop was a flawed implementation of the QuoRem function, which performs division with remainder on Eisenstein integers. The Euclidean algorithm, on which HalfGCD is based, requires that the remainder of a division is always 'smaller' (in this case, has a smaller norm) than the divisor to guarantee that it terminates. The original QuoRem function did not provide this guarantee.
The patch addresses the vulnerability by replacing the implementation of QuoRem with a correct one that ensures the Euclidean property holds. This, in turn, guarantees the convergence of the HalfGCD algorithm.
During an exploit, a profiler would likely highlight the eisenstein.HalfGCD function as the primary consumer of CPU time, as it contains the non-converging loop. However, the actual bug lies within eisenstein.(*ComplexNumber).QuoRem, which is called by HalfGCD. Therefore, both functions are critical to understanding and identifying the vulnerability.