示例#1
0
		public virtual Number Pow (Number x, Number y)
		{
			if (y.IsZero ())
				return ToElement (Number.One);
			if (y.IsOne ())
				return x;

			Number a = x;
			Number b = ToElement (Number.One);
			if (y.GetBit (0) == 1)
				b = a;
			for (int i = 1; i < y.BitCount (); i ++) {
				a = Multiply (a, a);
				if (y.GetBit (i) == 1)
					b = Multiply (a, b);
			}
			return b;
		}
示例#2
0
		public virtual ECPoint ExportECPoint (Number x, Number y, Number z, ECGroup group)
		{
			if (z.IsOne ())
				return new ECPoint (group, x, y, z);
			Number iz = Invert (z);
			Number z2 = Multiply (iz, iz);
			return new ECPoint (group, Multiply (x, z2), Multiply (y, Multiply (z2, iz)), Number.One);
		}