public boolean isEncrypted() { lock.lock(); try { return rootKey.isEncrypted(); } finally { lock.unlock(); } }
public boolean isEncrypted() { lock.lock(); try { return masterKey.isEncrypted(); } finally { lock.unlock(); } }
public boolean isEncrypted() { lock.lock(); try { return masterKey.isEncrypted(); } finally { lock.unlock(); } }
public boolean isEncrypted() { lock.lock(); try { return rootKey.isEncrypted(); } finally { lock.unlock(); } }
/** * A deterministic key is considered to be encrypted if it has access to encrypted private key bytes, OR if its * parent does. The reason is because the parent would be encrypted under the same key and this key knows how to * rederive its own private key bytes from the parent, if needed. */ @Override public boolean isEncrypted() { return priv == null && (super.isEncrypted() || (parent != null && parent.isEncrypted())); }
/** * A deterministic key is considered to be encrypted if it has access to encrypted private key bytes, OR if its * parent does. The reason is because the parent would be encrypted under the same key and this key knows how to * rederive its own private key bytes from the parent, if needed. */ @Override public boolean isEncrypted() { return priv == null && (super.isEncrypted() || (parent != null && parent.isEncrypted())); }
@Override public String toString() { final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this).omitNullValues(); helper.add("pub", Utils.HEX.encode(pub.getEncoded())); helper.add("chainCode", HEX.encode(chainCode)); helper.add("path", getPathAsString()); if (creationTimeSeconds > 0) helper.add("creationTimeSeconds", creationTimeSeconds); helper.add("isEncrypted", isEncrypted()); helper.add("isPubKeyOnly", isPubKeyOnly()); return helper.toString(); }
@Override public String toString() { final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this).omitNullValues(); helper.add("pub", Utils.HEX.encode(pub.getEncoded())); helper.add("chainCode", HEX.encode(chainCode)); helper.add("path", getPathAsString()); if (creationTimeSeconds > 0) helper.add("creationTimeSeconds", creationTimeSeconds); helper.add("isEncrypted", isEncrypted()); helper.add("isPubKeyOnly", isPubKeyOnly()); return helper.toString(); }
@Override public NxtFamilyKey toEncrypted(CharSequence password) { checkNotNull(password, "Attempt to encrypt with a null password."); checkArgument(password.length() > 0, "Attempt to encrypt with an empty password."); checkState(!entropy.isEncrypted(), "Attempt to encrypt a key that is already encrypted."); KeyCrypter scrypt = new KeyCrypterScrypt(); KeyParameter derivedKey = scrypt.deriveKey(password); return toEncrypted(scrypt, derivedKey); }
@Override public NxtFamilyKey toEncrypted(CharSequence password) { checkNotNull(password, "Attempt to encrypt with a null password."); checkArgument(password.length() > 0, "Attempt to encrypt with an empty password."); checkState(!entropy.isEncrypted(), "Attempt to encrypt a key that is already encrypted."); KeyCrypter scrypt = new KeyCrypterScrypt(); KeyParameter derivedKey = scrypt.deriveKey(password); return toEncrypted(scrypt, derivedKey); }
@Override public NxtFamilyKey toEncrypted(KeyCrypter keyCrypter, KeyParameter aesKey) { checkState(!entropy.isEncrypted(), "Attempt to encrypt a key that is already encrypted."); return new NxtFamilyKey(entropy.encrypt(keyCrypter, aesKey, null), publicKey); }
SimpleHDKeyChain(DeterministicKey rootkey, @Nullable KeyCrypter crypter) { this.rootKey = rootkey; simpleKeyChain = new SimpleKeyChain(crypter); if (!rootkey.isEncrypted()) { initializeHierarchyUnencrypted(rootKey); } // Else... // We can't initialize ourselves with just an encrypted seed, so we expected deserialization code to do the // rest of the setup (loading the root key). }
@Override public SimpleHDKeyChain toEncrypted(CharSequence password) { checkNotNull(password, "Attempt to encrypt with a null password."); checkArgument(password.length() > 0, "Attempt to encrypt with an empty password."); checkState(!rootKey.isEncrypted(), "Attempt to encrypt a root key that is already encrypted."); checkState(!rootKey.isPubKeyOnly(), "Attempt to encrypt a watching chain."); KeyCrypter scrypt = new KeyCrypterScrypt(); KeyParameter derivedKey = scrypt.deriveKey(password); return toEncrypted(scrypt, derivedKey); }
SimpleHDKeyChain(DeterministicKey rootkey, @Nullable KeyCrypter crypter, @Nullable KeyParameter key) { simpleKeyChain = new SimpleKeyChain(crypter); if (crypter != null && !rootkey.isEncrypted()) { this.rootKey = rootkey.encrypt(crypter, key, null); } else { this.rootKey = rootkey; } initializeHierarchyUnencrypted(rootKey); }
SimpleHDKeyChain(DeterministicKey rootkey, @Nullable KeyCrypter crypter, @Nullable KeyParameter key) { simpleKeyChain = new SimpleKeyChain(crypter); if (crypter != null && !rootkey.isEncrypted()) { this.rootKey = rootkey.encrypt(crypter, key, null); } else { this.rootKey = rootkey; } initializeHierarchyUnencrypted(rootKey); }
public NxtFamilyKey(DeterministicKey entropy, @Nullable KeyCrypter keyCrypter, @Nullable KeyParameter key) { checkArgument(!entropy.isEncrypted(), "Entropy must not be encrypted"); this.publicKey = Crypto.getPublicKey(entropy.getPrivKeyBytes()); // Encrypt entropy if needed if (keyCrypter != null && key != null) { this.entropy = entropy.encrypt(keyCrypter, key, entropy.getParent()); } else { this.entropy = entropy; } }
private void assertAllKeysDecrypted(WalletPocketHD pocket) { List<ECKey> keys = pocket.keys.getKeys(false); for (ECKey k : keys) { DeterministicKey key = (DeterministicKey) k; assertFalse(key.isEncrypted()); } }
private void assertAllKeysEncrypted(WalletPocketHD pocket) { List<ECKey> keys = pocket.keys.getKeys(false); for (ECKey k : keys) { DeterministicKey key = (DeterministicKey) k; assertTrue(key.isEncrypted()); } }
private void assertAllKeysDecrypted(WalletPocketHD pocket) { List<ECKey> keys = pocket.keys.getKeys(false); for (ECKey k : keys) { DeterministicKey key = (DeterministicKey) k; assertFalse(key.isEncrypted()); } }
@Test public void encryptionWhilstEmpty() throws Exception { group = new KeyChainGroup(PARAMS); group.setLookaheadSize(5); KeyCrypterScrypt scrypt = new KeyCrypterScrypt(2); final KeyParameter aesKey = scrypt.deriveKey("password"); group.encrypt(scrypt, aesKey); assertTrue(group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).isEncrypted()); final ECKey key = group.currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS); group.decrypt(aesKey); assertFalse(checkNotNull(group.findKeyFromPubKey(key.getPubKey())).isEncrypted()); }