Example #1
0
        public static X25519Key ImportKey(string privateKeyHex)
        {
            X25519PrivateKeyParameters privateKey = new X25519PrivateKeyParameters(privateKeyHex.HexToByteArray(), 0);
            X25519PublicKeyParameters  publicKey  = privateKey.GeneratePublicKey();
            var importedKey = new AsymmetricCipherKeyPair(publicKey, privateKey);
            var key         = new X25519Key(importedKey);

            return(key);
        }
Example #2
0
        public static X25519Key GenerateKey()
        {
            var random    = new SecureRandom();
            var generator = GeneratorUtilities.GetKeyPairGenerator("X25519");

            generator.Init(new X25519KeyGenerationParameters(random));
            var generatedKey = generator.GenerateKeyPair();
            var key          = new X25519Key(generatedKey);

            return(key);
        }