internal void Copy(ChineseRemainder ToCopy) { for (int Count = 0; Count < DigitsArraySize; Count++) { DigitsArray[Count] = ToCopy.DigitsArray[Count]; } }
internal void Multiply(ChineseRemainder ToMul) { for (int Count = 0; Count < DigitsArraySize; Count++) { DigitsArray[Count] *= ToMul.DigitsArray[Count]; DigitsArray[Count] %= (int)IntMath.GetPrimeAt(Count); } }
// 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); } }
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); } } }
internal bool IsEqual(ChineseRemainder ToCheck) { for (int Count = 0; Count < DigitsArraySize; Count++) { if (DigitsArray[Count] != ToCheck.DigitsArray[Count]) { return(false); } } return(true); }
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; } }