コード例 #1
0
        public FastECPoint Multiply(FastInteger b)
        {
            if (b.Sign == -1)
            {
                throw new FormatException("The multiplicator cannot be negative");
            }

            //b = b % Secp256k1.N;
            FastInteger exp      = (b * 3) ^ b;
            FastECPoint result   = FastECPoint.Infinity;
            FastECPoint affine   = this.Normalize();
            FastECPoint negative = affine.Negate();

            int         high = exp.BitsCount;
            FastInteger bit  = FastInteger.One << high;

            for (int i = high; --i >= 0; bit >>= 1)
            {
                result = result.Twice();
                if (!(exp & bit).IsZero)
                {
                    result = result.Add(!(b & bit).IsZero ? negative : affine);
                }
            }

            result = result.Normalize();
            return(result);
        }
コード例 #2
0
 public FastECPoint Subtract(FastECPoint b)
 {
     return(Add(b.Negate()));
 }