Search in sources :

Example 1 with Key

use of com.sparrowwallet.drongo.crypto.Key in project drongo by sparrowwallet.

the class WalletTest method encryptTest.

@Test
public void encryptTest() throws MnemonicException {
    String words = "absent essay fox snake vast pumpkin height crouch silent bulb excuse razor";
    DeterministicSeed seed = new DeterministicSeed(words, "pp", 0, DeterministicSeed.Type.BIP39);
    Wallet wallet = new Wallet();
    wallet.setPolicyType(PolicyType.SINGLE);
    wallet.setScriptType(ScriptType.P2PKH);
    Keystore keystore = Keystore.fromSeed(seed, wallet.getScriptType().getDefaultDerivation());
    wallet.getKeystores().add(keystore);
    wallet.setDefaultPolicy(Policy.getPolicy(PolicyType.SINGLE, ScriptType.P2PKH, wallet.getKeystores(), 1));
    KeyDeriver keyDeriver = new Argon2KeyDeriver();
    Key key = keyDeriver.deriveKey("pass");
    wallet.encrypt(key);
    wallet.decrypt("pass");
}
Also used : Argon2KeyDeriver(com.sparrowwallet.drongo.crypto.Argon2KeyDeriver) KeyDeriver(com.sparrowwallet.drongo.crypto.KeyDeriver) Argon2KeyDeriver(com.sparrowwallet.drongo.crypto.Argon2KeyDeriver) ExtendedKey(com.sparrowwallet.drongo.ExtendedKey) Key(com.sparrowwallet.drongo.crypto.Key) Test(org.junit.Test)

Aggregations

ExtendedKey (com.sparrowwallet.drongo.ExtendedKey)1 Argon2KeyDeriver (com.sparrowwallet.drongo.crypto.Argon2KeyDeriver)1 Key (com.sparrowwallet.drongo.crypto.Key)1 KeyDeriver (com.sparrowwallet.drongo.crypto.KeyDeriver)1 Test (org.junit.Test)1