Beispiel #1
0
        internal static void VerifyMultiplication(long a, long b)
        {
            LongLong   ll = LongLong.Multiplication(new LongLong(), a, b);
            BigInteger bi = BigInteger.ValueOf(a).Multiply(BigInteger.ValueOf(b));
            string     s  = string.Format("\na = %x\nb = %x\nll= " + ll + "\nbi= " + bi.ToString(16
                                                                                                 ) + "\n", a, b);

            //System.out.println(s);
            NUnit.Framework.Assert.AreEqual(s, bi, ll.ToBigInteger());
        }
Beispiel #2
0
            internal virtual long M(long c, long d)
            {
                LongLong.Multiplication(this.x, c, d);
                // a = (x * N')&(R - 1) = ((x & R_1) * N') & R_1
                long a = LongLong.Multiplication(this.xN_I, this.x.And(this._enclosing.R1), this.
                                                 _enclosing.NI).And(this._enclosing.R1);

                LongLong.Multiplication(this.aN, a, this._enclosing.N);
                long z = this.aN.PlusEqual(this.x).ShiftRight(this._enclosing.s);

                return(z < this._enclosing.N ? z : z - this._enclosing.N);
            }