scripts
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Math.Prime.Generator
|
||||
{
|
||||
// Token: 0x02000094 RID: 148
|
||||
internal class NextPrimeFinder : SequentialSearchPrimeGeneratorBase
|
||||
{
|
||||
// Token: 0x0600083E RID: 2110 RVA: 0x0001E2E0 File Offset: 0x0001C4E0
|
||||
protected override BigInteger GenerateSearchBase(int bits, object Context)
|
||||
{
|
||||
if (Context == null)
|
||||
{
|
||||
throw new ArgumentNullException("Context");
|
||||
}
|
||||
BigInteger bigInteger = new BigInteger((BigInteger)Context);
|
||||
bigInteger.SetBit(0U);
|
||||
return bigInteger;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Math.Prime.Generator
|
||||
{
|
||||
// Token: 0x02000095 RID: 149
|
||||
internal abstract class PrimeGeneratorBase
|
||||
{
|
||||
// Token: 0x170000E3 RID: 227
|
||||
// (get) Token: 0x06000840 RID: 2112 RVA: 0x0001E31C File Offset: 0x0001C51C
|
||||
public virtual ConfidenceFactor Confidence
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConfidenceFactor.Medium;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000E4 RID: 228
|
||||
// (get) Token: 0x06000841 RID: 2113 RVA: 0x0001E320 File Offset: 0x0001C520
|
||||
public virtual PrimalityTest PrimalityTest
|
||||
{
|
||||
get
|
||||
{
|
||||
return new PrimalityTest(PrimalityTests.RabinMillerTest);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000E5 RID: 229
|
||||
// (get) Token: 0x06000842 RID: 2114 RVA: 0x0001E330 File Offset: 0x0001C530
|
||||
public virtual int TrialDivisionBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
return 4000;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000843 RID: 2115 RVA: 0x0001E338 File Offset: 0x0001C538
|
||||
protected bool PostTrialDivisionTests(BigInteger bi)
|
||||
{
|
||||
return this.PrimalityTest(bi, this.Confidence);
|
||||
}
|
||||
|
||||
// Token: 0x06000844 RID: 2116
|
||||
public abstract BigInteger GenerateNewPrime(int bits);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Math.Prime.Generator
|
||||
{
|
||||
// Token: 0x02000096 RID: 150
|
||||
internal class SequentialSearchPrimeGeneratorBase : PrimeGeneratorBase
|
||||
{
|
||||
// Token: 0x06000846 RID: 2118 RVA: 0x0001E354 File Offset: 0x0001C554
|
||||
protected virtual BigInteger GenerateSearchBase(int bits, object context)
|
||||
{
|
||||
BigInteger bigInteger = BigInteger.GenerateRandom(bits);
|
||||
bigInteger.SetBit(0U);
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000847 RID: 2119 RVA: 0x0001E370 File Offset: 0x0001C570
|
||||
public override BigInteger GenerateNewPrime(int bits)
|
||||
{
|
||||
return this.GenerateNewPrime(bits, null);
|
||||
}
|
||||
|
||||
// Token: 0x06000848 RID: 2120 RVA: 0x0001E37C File Offset: 0x0001C57C
|
||||
public virtual BigInteger GenerateNewPrime(int bits, object context)
|
||||
{
|
||||
BigInteger bigInteger = this.GenerateSearchBase(bits, context);
|
||||
uint num = bigInteger % 3234846615U;
|
||||
int trialDivisionBounds = this.TrialDivisionBounds;
|
||||
uint[] smallPrimes = BigInteger.smallPrimes;
|
||||
for (;;)
|
||||
{
|
||||
if (num % 3U != 0U)
|
||||
{
|
||||
if (num % 5U != 0U)
|
||||
{
|
||||
if (num % 7U != 0U)
|
||||
{
|
||||
if (num % 11U != 0U)
|
||||
{
|
||||
if (num % 13U != 0U)
|
||||
{
|
||||
if (num % 17U != 0U)
|
||||
{
|
||||
if (num % 19U != 0U)
|
||||
{
|
||||
if (num % 23U != 0U)
|
||||
{
|
||||
if (num % 29U != 0U)
|
||||
{
|
||||
int num2 = 10;
|
||||
while (num2 < smallPrimes.Length && (ulong)smallPrimes[num2] <= (ulong)((long)trialDivisionBounds))
|
||||
{
|
||||
if (bigInteger % smallPrimes[num2] == 0U)
|
||||
{
|
||||
goto IL_105;
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
if (this.IsPrimeAcceptable(bigInteger, context))
|
||||
{
|
||||
if (this.PrimalityTest(bigInteger, this.Confidence))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
IL_105:
|
||||
num += 2U;
|
||||
if (num >= 3234846615U)
|
||||
{
|
||||
num -= 3234846615U;
|
||||
}
|
||||
bigInteger.Incr2();
|
||||
}
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000849 RID: 2121 RVA: 0x0001E4B0 File Offset: 0x0001C6B0
|
||||
protected virtual bool IsPrimeAcceptable(BigInteger bi, object context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user