Skip to content

Latest commit

 

History

History
58 lines (49 loc) · 1.42 KB

rfc7748-x25519.md

File metadata and controls

58 lines (49 loc) · 1.42 KB
/*
 * Neuroxiq 2022
 * Arctium Project / Code example
 *
 * 
 */


using Arctium.Shared.Helpers.Buffers;
using Arctium.Standards.EllipticCurves;

namespace ConsoleAppTest
{
    internal class MainProgram
    {
        private static byte[] bobPrivateKey;
        private static byte[] bobPublicKey;
        private static byte[] alicePrivateKey;
        private static byte[] alicePublicKey;

        static void Main()
        {
            BobGenerateKeyPair();
            AliceGenerateKeyPair();
            BobComputeSharedSecret();
            AliceComputeSharedSecret();
        }

        private static void AliceComputeSharedSecret()
        {
            byte[] sharedSecret = RFC7748.X25519(alicePrivateKey, bobPublicKey);
            Console.WriteLine("Alice shared secret: ");
            MemDump.HexDump(sharedSecret);
        }

        private static void BobComputeSharedSecret()
        {
            byte[] sharedSecret = RFC7748.X25519(bobPrivateKey, alicePublicKey);
            Console.WriteLine("Bob shared secret: ");
            MemDump.HexDump(sharedSecret);
        }

        private static void AliceGenerateKeyPair()
        {
            RFC7748.X25519_GeneratePrivateAndPublicKey(out alicePrivateKey, out alicePublicKey);
        }

        private static void BobGenerateKeyPair()
        {
            RFC7748.X25519_GeneratePrivateAndPublicKey(out bobPrivateKey, out bobPublicKey);
        }
    }
}
/*

 */