コード例 #1
0
ファイル: EthSignServiceTest.cs プロジェクト: SP8DE/protocol
        public void EthSignTest2()
        {
            string message = "test";

            var generator = new EthKeySecretManager();
            var key       = generator.LoadKeySecret("d3a7d42d881a9b59ccefcac0f5bcc69f85e68fdf0bfb6fcbbe42373320de420f");

            Assert.NotNull(key);

            var service   = new EthCryptoService();
            var signature = service.SignMessage(message, key.PrivateKey);

            Assert.NotNull(signature);

            var rs = service.VerifySignature(message, signature, key.PublicAddress);

            Assert.True(rs);
        }
コード例 #2
0
ファイル: EthSignServiceTest.cs プロジェクト: SP8DE/protocol
        public void EthSignTests(string pk)
        {
            var generator = new EthKeySecretManager();

            var    key     = generator.LoadKeySecret(pk); //sp8de
            string message = $"{key.PublicAddress.ToLowerInvariant()};1;1";

            Assert.NotNull(key);

            var service   = new EthCryptoService();
            var signature = service.SignMessage(message, key.PrivateKey);

            Assert.NotNull(signature);

            var rs = service.VerifySignature(message, signature, key.PublicAddress);

            Assert.True(rs);
        }
コード例 #3
0
ファイル: EthSignServiceTest.cs プロジェクト: SP8DE/protocol
        public void EthSignTest3()
        {
            var signature = "0xdb46c6be4b1ee0ef670625630d38899213ea5d63d749954d82a4651b81f7d44f6d16e2e4903038c022b71d11baa26b08142c6b9f5db106d7b96b57d1836ce10e1b";
            var text      = "test";

            var generator = new EthKeySecretManager();
            var key       = generator.LoadKeySecret("0xd3a7d42d881a9b59ccefcac0f5bcc69f85e68fdf0bfb6fcbbe42373320de420f");

            var service = new EthCryptoService();
            var rs      = service.VerifySignature(text, signature, key.PublicAddress);

            Assert.True(rs);

            //Assert.NotNull(key);

            //
            //var signature2 = service.SignMessage(message, key.PrivateKey, key.PublicAddress);
            //Assert.NotNull(signature);
        }