本文整理汇总了C#中Lidgren.Network.NetBigInteger.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# NetBigInteger.Equals方法的具体用法?C# NetBigInteger.Equals怎么用?C# NetBigInteger.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetBigInteger
的用法示例。
在下文中一共展示了NetBigInteger.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModPow
public NetBigInteger ModPow(
NetBigInteger exponent,
NetBigInteger m)
{
if (m.m_sign < 1)
throw new ArithmeticException("Modulus must be positive");
if (m.Equals(One))
return Zero;
if (exponent.m_sign == 0)
return One;
if (m_sign == 0)
return Zero;
int[] zVal = null;
int[] yAccum = null;
int[] yVal;
// Montgomery exponentiation is only possible if the modulus is odd,
// but AFAIK, this is always the case for crypto algo's
bool useMonty = ((m.m_magnitude[m.m_magnitude.Length - 1] & 1) == 1);
long mQ = 0;
if (useMonty)
{
mQ = m.GetMQuote();
// tmp = this * R mod m
NetBigInteger tmp = ShiftLeft(32 * m.m_magnitude.Length).Mod(m);
zVal = tmp.m_magnitude;
useMonty = (zVal.Length <= m.m_magnitude.Length);
if (useMonty)
{
yAccum = new int[m.m_magnitude.Length + 1];
if (zVal.Length < m.m_magnitude.Length)
{
int[] longZ = new int[m.m_magnitude.Length];
zVal.CopyTo(longZ, longZ.Length - zVal.Length);
zVal = longZ;
}
}
}
if (!useMonty)
{
if (m_magnitude.Length <= m.m_magnitude.Length)
{
//zAccum = new int[m.magnitude.Length * 2];
zVal = new int[m.m_magnitude.Length];
m_magnitude.CopyTo(zVal, zVal.Length - m_magnitude.Length);
}
else
{
//
// in normal practice we'll never see ..
//
NetBigInteger tmp = Remainder(m);
//zAccum = new int[m.magnitude.Length * 2];
zVal = new int[m.m_magnitude.Length];
tmp.m_magnitude.CopyTo(zVal, zVal.Length - tmp.m_magnitude.Length);
}
yAccum = new int[m.m_magnitude.Length * 2];
}
yVal = new int[m.m_magnitude.Length];
//
// from LSW to MSW
//
for (int i = 0; i < exponent.m_magnitude.Length; i++)
{
int v = exponent.m_magnitude[i];
int bits = 0;
if (i == 0)
{
while (v > 0)
{
v <<= 1;
bits++;
}
//
// first time in initialise y
//
zVal.CopyTo(yVal, 0);
v <<= 1;
bits++;
}
while (v != 0)
{
if (useMonty)
{
//.........这里部分代码省略.........