Beispiel #1
0
        public void SharedSecretGenerationBasedOnEthKeyImportTest()
        {
            EthECKey  ecKey1 = EthECKey.GenerateKey();
            EthECKey  ecKey2 = EthECKey.GenerateKey();
            X25519Key alice  = X25519Key.ImportKey(ecKey1.GetPrivateKey());
            X25519Key bob    = X25519Key.ImportKey(ecKey2.GetPrivateKey());

            var shared1 = alice.GenerateSharedSecretHex(bob.PublicKey);
            var shared2 = bob.GenerateSharedSecretHex(alice.PublicKey);

            Assert.Equal(shared1, shared2);
        }
Beispiel #2
0
        public void SharedSecretGenerationBasedOnEthKeyImportTest()
        {
            EthECKey  ecKey1 = EthECKey.GenerateKey();
            EthECKey  ecKey2 = EthECKey.GenerateKey();
            X25519Key alice  = X25519Key.ImportKey(ecKey1.GetPrivateKey());
            X25519Key bob    = X25519Key.ImportKey(ecKey2.GetPrivateKey());

            var s1 = alice.GenerateSharedSecretHex(ecKey2.GetPubKey().ToHex(true));
            var s2 = bob.GenerateSharedSecretHex(ecKey1.GetPubKey().ToHex(true));

            var shared1 = alice.GenerateSharedSecretHex(bob.PublicKey);
            var shared2 = bob.GenerateSharedSecretHex(alice.PublicKey);

            Assert.Equal(shared1, shared2);

            testOutputHelper.WriteLine(shared1);
            testOutputHelper.WriteLine(shared2);
        }