Exemplo n.º 1
0
        /**
         * Checks whether provided data are coordinates of a point belonging to subgroup, if check has
         * been passed it returns a point, otherwise returns null
         */
        public static BN128G2 Create(byte[] a, byte[] b, byte[] c, byte[] d)
        {
            BN128 <Fp2> p = BN128Fp2.Create(a, b, c, d);

            // fails if point is invalid
            if (p == null)
            {
                return(null);
            }

            // check whether point is a subgroup member
            if (!IsGroupMember(p))
            {
                return(null);
            }

            return(new BN128G2(p));
        }
Exemplo n.º 2
0
        /**
         * Checks whether provided data are coordinates of a point on the curve, then checks if this point
         * is a member of subgroup of order "r" and if checks have been passed it returns a point,
         * otherwise returns null
         */
        public static BN128 <Fp2> Create(byte[] aa, byte[] bb, byte[] cc, byte[] dd)
        {
            Fp2 x = Fp2.Create(aa, bb);
            Fp2 y = Fp2.Create(cc, dd);

            // check for point at infinity
            if (x.IsZero() && y.IsZero())
            {
                return(ZERO);
            }

            BN128 <Fp2> p = new BN128Fp2(x, y, Fp2._1);

            // check whether point is a valid one
            if (p.IsValid())
            {
                return(p);
            }
            else
            {
                return(null);
            }
        }