Exemple #1
0
        /// <summary>
        /// Generate a new KeyPair
        /// </summary>
        public KeyPair()
        {
            var sodiumKeyPair = Sodium.PublicKeyBox.GenerateKeyPair();

            Secret = new PrivateSecretKey(sodiumKeyPair.PrivateKey);
            Public = new PublicKey(sodiumKeyPair.PublicKey);
        }
Exemple #2
0
        /// <summary>
        /// Generate a new KeyPair
        /// </summary>
        public SigningKeyPair()
        {
            var sodiumKeyPair = Sodium.PublicKeyAuth.GenerateKeyPair();

            Secret = new PrivateSecretKey(sodiumKeyPair.PrivateKey);
            Public = new PublicKey(sodiumKeyPair.PublicKey);
        }
Exemple #3
0
        /// <summary>
        /// Generate a KeyPair from a given Private Key
        /// </summary>
        /// <param name="privKey">Secret Private Key</param>
        public KeyPair(IPrivateSecretKey privKey)
        {
            if (privKey == null)
            {
                throw new ArgumentNullException(nameof(privKey));
            }

            var sodiumKeyPair = Sodium.PublicKeyBox.GenerateKeyPair(privKey.Bytes);

            Secret = new PrivateSecretKey(sodiumKeyPair.PrivateKey);
            Public = new PublicKey(sodiumKeyPair.PublicKey);
        }