<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.0" />

Reduce

static class Reduce
using System.Runtime.CompilerServices; namespace Org.BouncyCastle.Crypto.Kems.MLKem { internal static class Reduce { [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static short MontgomeryReduce(int a) { int num = (short)(a * 62209) * 3329; num = a - num; num >>= 16; return (short)num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static short BarrettReduce(short a) { short num = (short)(20159 * a >> 26); num = (short)(num * 3329); return (short)(a - num); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static short CondSubQ(short a) { a = (short)(a - 3329); a = (short)(a + (short)((a >> 15) & 3329)); return a; } } }