示例#1
0
 internal void Copy(ChineseRemainder ToCopy)
 {
     for (int Count = 0; Count < DigitsArraySize; Count++)
     {
         DigitsArray[Count] = ToCopy.DigitsArray[Count];
     }
 }
示例#2
0
 internal void Multiply(ChineseRemainder ToMul)
 {
     for (int Count = 0; Count < DigitsArraySize; Count++)
     {
         DigitsArray[Count] *= ToMul.DigitsArray[Count];
         DigitsArray[Count] %= (int)IntMath.GetPrimeAt(Count);
     }
 }
示例#3
0
 // Copyright Eric Chauvin.
 internal void Multiply(ChineseRemainder ToMul)
 {
     for (int Count = 0; Count < DigitsArraySize; Count++)
     {
         // There is no Diffusion here either, like the
         // kind that Claude Shannon wrote about in
         // A Mathematical Theory of Cryptography.
         DigitsArray[Count] *= ToMul.DigitsArray[Count];
         DigitsArray[Count] %= (int)IntMath.GetPrimeAt(Count);
     }
 }
示例#4
0
 internal void Subtract(ChineseRemainder ToSub)
 {
     for (int Count = 0; Count < DigitsArraySize; Count++)
     {
         DigitsArray[Count] -= ToSub.DigitsArray[Count];
         if (DigitsArray[Count] < 0)
         {
             DigitsArray[Count] += (int)IntMath.GetPrimeAt(Count);
         }
     }
 }
示例#5
0
        internal bool IsEqual(ChineseRemainder ToCheck)
        {
            for (int Count = 0; Count < DigitsArraySize; Count++)
            {
                if (DigitsArray[Count] != ToCheck.DigitsArray[Count])
                {
                    return(false);
                }
            }

            return(true);
        }
示例#6
0
 internal void Add(ChineseRemainder ToAdd)
 {
     for (int Count = 0; Count < DigitsArraySize; Count++)
     {
         // Operations like this could be very fast if
         // they were done on a GPU processor.
         // They could be done in parallel, which would
         // make it a lot faster than the way this is
         // done, one digit at a time.  Notice that
         // there is no carry operation here.
         DigitsArray[Count] += ToAdd.DigitsArray[Count];
         int Prime = (int)IntMath.GetPrimeAt(Count);
         if (DigitsArray[Count] >= Prime)
         {
             DigitsArray[Count] -= Prime;
         }
         // DigitsArray[Count] = DigitsArray[Count] % Prime;
     }
 }