public void EncryptPassword()
        {
            RawKeyPair keyPair  = RawKeyPair.Generate();
            string     password = "******";

            byte[] privateBinary   = keyPair.ConcatenatedPrivateKey;
            byte[] encryptedBinary = client.EncryptPrivateKey(password, privateBinary);
            byte[] decryptedBinary = client.DecryptPrivateKey(password, encryptedBinary);
            CollectionAssert.AreEqual(privateBinary, decryptedBinary);
            byte[] publicBinary = keyPair.PublicKey;
            encryptedBinary = client.EncryptPublicKey(password, publicBinary);
            decryptedBinary = client.DecryptPublicKey(password, encryptedBinary);
            CollectionAssert.AreEqual(publicBinary, decryptedBinary);
        }
Пример #2
0
        public void Recover()
        {
            string walletFileSecret = "my_super_safe_password";

            Configuration cfg = ServiceProvider.GetService <Configuration>();
            // generate Keypair
            RawKeyPair keypair = RawKeyPair.Generate();
            Keystore   stor    = Keystore.Generate(cfg, keypair, walletFileSecret, null);

            Assert.IsNotNull(stor);

            // recover Keypair
            byte[]     recoveredPrivateKey = stor.RecoverPrivateKey(cfg.Argon2Mode, walletFileSecret);
            RawKeyPair recoveredRawKeypair = new RawKeyPair(Hex.ToHexString(recoveredPrivateKey));

            Assert.IsNotNull(recoveredRawKeypair);

            // compare generated and recovered keypair
            CollectionAssert.AreEqual(keypair.ConcatenatedPrivateKey, recoveredRawKeypair.ConcatenatedPrivateKey);
        }