Remove cancellation-aware UInt128 ModPow overload

This commit is contained in:
Marek Lemańczyk committed 2025-10-20 11:48:14 +02:00
1 parent c892e1c30c
commit 0f51454496
2 files changed
+38 -38

No files matched your search

-37
View File
@@ -560,43 +560,6 @@ public static class UInt128Extensions
public static ulong Mod128(this UInt128 value) => (ulong)value & 127UL;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static UInt128 ModPow(this UInt128 value, UInt128 exponent, UInt128 modulus, CancellationToken ct)
{
UInt128 zero = UInt128.Zero;
UInt128 one = UInt128.One;
if (modulus <= one)
{
return zero;
}
UInt128 result = UInt128.One;
UInt128 baseValue = value % modulus;
while (exponent != zero)
{
if (ct.IsCancellationRequested)
{
return zero;
}
if ((exponent & one) != zero)
{
result = result.MulMod(baseValue, modulus);
}
if (ct.IsCancellationRequested)
{
return zero;
}
baseValue = baseValue.MulMod(baseValue, modulus);
exponent >>= 1;
}
return result;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static UInt128 ModPow(this UInt128 value, UInt128 exponent, UInt128 modulus)
{