diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.PowMod.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.PowMod.cs index 7e59c6dd00260..c5efe4151d270 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.PowMod.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.PowMod.cs @@ -464,7 +464,7 @@ private static Span PowCore(Span value, int valueLength, power >>= 1; } - return result.Slice(0, resultLength); + return result; } private static Span PowCore(Span value, int valueLength, diff --git a/src/libraries/System.Runtime.Numerics/tests/BigInteger/modpow.cs b/src/libraries/System.Runtime.Numerics/tests/BigInteger/modpow.cs index 54af681215170..fe6169e5d91f7 100644 --- a/src/libraries/System.Runtime.Numerics/tests/BigInteger/modpow.cs +++ b/src/libraries/System.Runtime.Numerics/tests/BigInteger/modpow.cs @@ -274,6 +274,18 @@ public static void ModPowAxiom() } } + [Fact] + public static void RegressionIssue70330() + { + byte[] tempByteArray1 = { 226, 32 }; + byte[] tempByteArray2 = { 113 }; + byte[] tempByteArray3 = { 15, 8, 201, 158, 96, 200, 233, 243, 184, 0, 33, 203, 210, 80, 174, 198, 244, 177, 223, 221, 168, 243, 233, 133, 103, 252, 219, 195, 187, 227, 215, 54, 66, 248, 37, 186, 232, 45, 227, 147, 100, 14, 121, 244, 56, 89, 181, 120, 205, 4, 59, 48, 65, 239, 221, 28, 30, 68, 55, 99, 237, 38, 56, 213, 40, 234, 136, 218, 42, 244, 222, 198, 205 }; + VerifyIdentityString( + Print(tempByteArray3) + Print(tempByteArray2) + Print(tempByteArray1) + "tModPow", + Print(tempByteArray3) + Print(tempByteArray2) + Print(tempByteArray1) + "bPow" + " bRemainder" + ); + } + [Fact] public static void ModPowBoundary() {