Esempio n. 1
0
        /// <summary>
        /// Constructs an ECCGroup.
        /// <param name="p">The p parameter, representing the prime field domain for the
        /// x and y coordinate spaces.</param>
        /// <param name="a">The a parameter for the eliptic curve.</param>
        /// <param name="b">The b parameter for the eliptic curve.</param>
        /// <param name="g_x">The x coordinate of the generator point.</param>
        /// <param name="g_y">The y coordinate of the generator point.</param>
        /// <param name="n">The order of the group.</param>
        /// <param name="groupName">The known name of the group, or null.</param>
        /// <param name="curveName">The known name of the curve, or null.</param>
        /// </summary>
        public ECGroupBCImpl(
            byte[] p,
            byte[] a,
            byte[] b,
            byte[] g_x,
            byte[] g_y,
            byte[] n,
            string groupName,
            string curveName)
            : base(p, a, b, g_x, g_y, n, groupName, curveName)
        {
            this.curve = new BouncyCastle.FpCurve(
                new BCBigInt(1, p),
                new BCBigInt(1, a),
                new BCBigInt(1, b));

            BouncyCastle.ECPoint generator = this.curve.CreatePoint(
                new BCBigInt(1, g_x),
                new BCBigInt(1, g_y),
                false);

            this.domainParams = new BouncyCastle.ECDomainParameters(
                this.curve,
                generator,
                new BCBigInt(1, n));

            this.g = new ECGroupElementBCImpl(
                this.domainParams.G as BouncyCastle.FpPoint);
        }
        /// <summary>
        /// Constructs an ECCGroup.
        /// <param name="p">The p parameter, representing the prime field domain for the 
        /// x and y coordinate spaces.</param>
        /// <param name="a">The a parameter for the eliptic curve.</param>
        /// <param name="b">The b parameter for the eliptic curve.</param>
        /// <param name="g_x">The x coordinate of the generator point.</param>
        /// <param name="g_y">The y coordinate of the generator point.</param>
        /// <param name="n">The order of the group.</param>
        /// <param name="groupName">The known name of the group, or null.</param>
        /// <param name="curveName">The known name of the curve, or null.</param>
        /// </summary>
        public ECGroupBCImpl(
            byte[] p, 
            byte[] a, 
            byte[] b, 
            byte[] g_x, 
            byte[] g_y, 
            byte[] n, 
            string groupName, 
            string curveName)
            : base(p, a, b, g_x, g_y, n, groupName, curveName)
        {
            this.curve = new BouncyCastle.FpCurve(
                new BCBigInt(1, p), 
                new BCBigInt(1, a), 
                new BCBigInt(1, b));

            BouncyCastle.ECPoint generator = this.curve.CreatePoint(
                new BCBigInt(1, g_x), 
                new BCBigInt(1, g_y), 
                false);

            this.domainParams = new BouncyCastle.ECDomainParameters(
                                    this.curve,
                                    generator,
                                    new BCBigInt(1, n));

            this.g = new ECGroupElementBCImpl(
                this.domainParams.G as BouncyCastle.FpPoint);
        }