Org.BouncyCastle.Math.EC.F2mFieldElement.Multiply C# (CSharp) Method

Multiply() public method

public Multiply ( ECFieldElement b ) : ECFieldElement
b ECFieldElement
return ECFieldElement
		public override ECFieldElement Multiply(
			ECFieldElement b)
		{
			// Right-to-left comb multiplication in the IntArray
			// Input: Binary polynomials a(z) and b(z) of degree at most m-1
			// Output: c(z) = a(z) * b(z) mod f(z)

			// No check performed here for performance reasons. Instead the
			// elements involved are checked in ECPoint.F2m
			// checkFieldElements(this, b);
			F2mFieldElement bF2m = (F2mFieldElement) b;
			IntArray mult = x.Multiply(bF2m.x, m);
			mult.Reduce(m, new int[]{k1, k2, k3});
			return new F2mFieldElement(m, k1, k2, k3, mult);
		}

Usage Example

示例#1
0
        /* (non-Javadoc)
         * @see Org.BouncyCastle.Math.EC.ECPoint#add(Org.BouncyCastle.Math.EC.ECPoint)
         */
        public override ECPoint Add(
            ECPoint b)
        {
            // Check, if points are on the same curve
            if (!curve.Equals(b.Curve))
            {
                throw new ArgumentException("Only points on the same curve can be added");
            }

            if (this.IsInfinity)
            {
                return(b);
            }

            if (b.IsInfinity)
            {
                return(this);
            }

            F2mFieldElement.CheckFieldElements(this.x, b.X);
            F2mFieldElement x2 = (F2mFieldElement)b.X;
            F2mFieldElement y2 = (F2mFieldElement)b.Y;

            // Check if b = this or b = -this
            if (this.x.Equals(x2))
            {
                // this = b, i.e. this must be doubled
                if (this.y.Equals(y2))
                {
                    return(this.Twice());
                }

                // this = -b, i.e. the result is the point at infinity
                return(this.curve.Infinity);
            }

            F2mFieldElement lambda
                = (F2mFieldElement)(this.y.Add(y2)).Divide(this.x.Add(x2));

            F2mFieldElement x3
                = (F2mFieldElement)lambda.Square().Add(lambda).Add(this.x).Add(x2).Add(this.curve.A);

            F2mFieldElement y3
                = (F2mFieldElement)lambda.Multiply(this.x.Add(x3)).Add(x3).Add(this.y);

            return(new F2mPoint(curve, x3, y3, withCompression));
        }
All Usage Examples Of Org.BouncyCastle.Math.EC.F2mFieldElement::Multiply