public void TestHs1()
        {
            var ns = new byte[]
            {
                0x04, 0x60, 0x41, 0x90, 0xea, 0xe3, 0x03, 0x48,
                0xc4, 0x67, 0xa2, 0x56, 0xaa, 0x20, 0xf0, 0xe1,
                0x22, 0xfd, 0x4c, 0x54, 0xb0, 0x2a, 0x03, 0x26,
                0x84, 0xf1, 0x22, 0x11, 0xfc, 0x9a, 0x8e, 0xe3,
            };

            var expectedX = "17908376941582875772307252089828253420307082915473361881522058301944387204152";
            var expectedY = "33408333837140987002065754540391028444871058307081963101365044681462597430369";
            var phe       = new PheCrypto();
            var point     = phe.HashToPoint(Domains.Dhs1, ns);

            Assert.Equal(new BigInteger(expectedX, 10), point.XCoord.ToBigInteger());
            Assert.Equal(new BigInteger(expectedY, 10), point.YCoord.ToBigInteger());
        }
        public void TestHs0()
        {
            var ns = new byte[]
            {
                0x8e, 0x48, 0xac, 0x4b, 0x4a, 0x0c, 0x3f, 0x87,
                0x83, 0x69, 0x6f, 0x5d, 0x1f, 0x77, 0xd4, 0x25,
                0x64, 0x84, 0xd5, 0xb0, 0x7f, 0xd3, 0x8a, 0xf6,
                0xb2, 0xbf, 0x2d, 0x7b, 0x34, 0x57, 0x8a, 0x24,
            };

            var expectedX = "25300858746488398178355367558777222618482687866522608982770829435057272700048";
            var expectedY = "110446173948945874058011275277660983270153244227256872727234408438424462761061";
            var phe       = new PheCrypto();
            var point     = phe.HashToPoint(Domains.Dhs0, ns);

            Assert.Equal(new BigInteger(expectedX, 10), point.XCoord.ToBigInteger());
            Assert.Equal(new BigInteger(expectedY, 10), point.YCoord.ToBigInteger());
        }
        public void TestHashToPoint()
        {
            byte[] mockedRandomBytes = new byte[]
            {
                0x80, 0x39, 0x05, 0x31, 0x49, 0x44, 0x70, 0xbe,
                0x0b, 0x29, 0x65, 0x01, 0x58, 0x6b, 0xfc, 0xd9,
                0xe1, 0x31, 0xc3, 0x9e, 0x2d, 0xec, 0xc7, 0x53,
                0xd4, 0xf2, 0x5f, 0xef, 0xd2, 0x28, 0x1e, 0xea,
                0xe0, 0x92, 0x7d, 0x0e, 0xd0, 0x57, 0x2e, 0x7f,
                0xe7, 0x7b, 0x60, 0x93, 0x15, 0xbc, 0x86, 0x5e,
                0xd4, 0x38, 0x92, 0xcd, 0x6c, 0xda, 0xf5, 0x65,
                0x18, 0x1a, 0x3d, 0xf9, 0x2b, 0x13, 0x80, 0xdc,
                0xc4, 0x08, 0x93, 0xc8, 0xdf, 0x19, 0x7b, 0x6b,
                0x8f, 0x74, 0x8f, 0x39, 0x23, 0xa1, 0x8a, 0x6d,
                0xd4, 0xdd, 0xb5, 0xc3, 0x01, 0x66, 0xa9, 0x5a,
                0xb8, 0xbc, 0x14, 0xde, 0x83, 0x26, 0xdb, 0x32,
                0xf3, 0x1d, 0xa8, 0xef, 0x0b, 0xdd, 0x38, 0x5f,
                0x83, 0xb3, 0x6c, 0xf8, 0x89, 0x48, 0xc3, 0xee,
                0xb3, 0x97, 0x4d, 0x04, 0x08, 0x12, 0x53, 0xf5,
                0x60, 0x44, 0x67, 0x91, 0xc1, 0x9e, 0x03, 0xab,
                0x4b, 0x70, 0x0b, 0xcb, 0x4e, 0x03, 0x81, 0x7d,
                0x40, 0x96, 0xa2, 0x60, 0x5a, 0x80, 0xb2, 0x23,
                0x6d, 0x62, 0x3c, 0x5a, 0x5e, 0xd2, 0x45, 0xdb,
                0x36, 0x56, 0xda, 0xb9, 0x2e, 0x6e, 0xe1, 0xe6,
                0x10, 0x27, 0x97, 0x3b, 0xbc, 0x2e, 0x04, 0x8d,
                0x21, 0xce, 0x4c, 0xf0, 0x29, 0x03, 0x7e, 0x17,
                0x0c, 0x34, 0x81, 0x8d, 0xaa, 0x25, 0x33, 0xe6,
                0xf8, 0x77, 0xe1, 0x59, 0x65, 0x89, 0x16, 0xa2,
            };

            var crypto = new PheCrypto();
            var m      = crypto.HashToPoint(null, mockedRandomBytes.Take(32).ToArray());

            var expectedM = (FpPoint)crypto.Curve.CreatePoint(
                new BigInteger("47919986077532098346505903401676113443327441655946536745084881296990002308999", 10),
                new BigInteger("83980225500589559999287763767838231751053639306927585927546932471768986795515", 10));
            var xcoord = m.XCoord.ToBigInteger();
            var ycoord = m.YCoord.ToBigInteger();

            Assert.Equal(expectedM, m);
        }
        public void TestHc1()
        {
            var ns = new byte[]
            {
                0x91, 0xd2, 0x04, 0x0b, 0x8e, 0x52, 0x7e, 0x8a,
                0xe3, 0x40, 0xf6, 0x89, 0xda, 0x01, 0x7c, 0xd6,
                0x1e, 0x20, 0x25, 0xd0, 0xbc, 0xc4, 0xd1, 0x24,
                0x92, 0x5c, 0x87, 0xc3, 0xe9, 0x59, 0xc7, 0x54,
            };

            var pwd = new byte[]
            {
                0xb8, 0xce, 0xc3, 0xde, 0xfd, 0xfc, 0x80, 0x3c, 0x18,
                0x5d,
            };

            var expectedX = "49501362177553120463897295920682327704465381738906627606535872853621035764254";
            var expectedY = "47270509952559745766619070899406283523267398868407265017727132307696482921539";
            var phe       = new PheCrypto();
            var point     = phe.HashToPoint(Domains.Dhc1, ns, pwd);

            Assert.Equal(new BigInteger(expectedX, 10), point.XCoord.ToBigInteger());
            Assert.Equal(new BigInteger(expectedY, 10), point.YCoord.ToBigInteger());
        }
        public void TestHc0()
        {
            var ns = new byte[]
            {
                0xdb, 0x59, 0x4e, 0x9a, 0x53, 0xeb, 0x35, 0x39,
                0x84, 0x63, 0x67, 0xf1, 0x4c, 0x15, 0xa1, 0x9b,
                0x4b, 0xee, 0x1d, 0x27, 0x13, 0xf3, 0xaa, 0xb5,
                0x3b, 0x11, 0x72, 0xd6, 0x02, 0x51, 0x63, 0x36,
            };

            var pwd = new byte[]
            {
                0x5a, 0xf6, 0xf9, 0x9a, 0xc2, 0x0d, 0x0d, 0x54,
                0x52, 0xa2,
            };

            var expectedX = "71581924212971445159021410682851786422010928474259399013091051697427945751880";
            var expectedY = "82599985433400511569162075253342037148256984798119669265653399740244502620726";
            var phe       = new PheCrypto();
            var point     = phe.HashToPoint(Domains.Dhc0, ns, pwd);

            Assert.Equal(new BigInteger(expectedX, 10), point.XCoord.ToBigInteger());
            Assert.Equal(new BigInteger(expectedY, 10), point.YCoord.ToBigInteger());
        }