/** * Returns only the external keys that have been issued by this chain, lookahead not included. */ public List<ECKey> getIssuedReceiveKeys() { final List<ECKey> keys = new ArrayList<>(getKeys(false, false)); for (Iterator<ECKey> i = keys.iterator(); i.hasNext();) { DeterministicKey parent = ((DeterministicKey) i.next()).getParent(); if (parent == null || !externalParentKey.equals(parent)) i.remove(); } return keys; }
/** * Returns only the external keys that have been issued by this chain, lookahead not included. */ public List<ECKey> getIssuedReceiveKeys() { final List<ECKey> keys = new ArrayList<ECKey>(getKeys(false)); for (Iterator<ECKey> i = keys.iterator(); i.hasNext();) { DeterministicKey parent = ((DeterministicKey) i.next()).getParent(); if (parent == null || !externalParentKey.equals(parent)) i.remove(); } return keys; }
/** * Returns only the external keys that have been issued by this chain, lookahead not included. */ public List<ECKey> getIssuedReceiveKeys() { final List<ECKey> keys = new ArrayList<>(getKeys(false, false)); for (Iterator<ECKey> i = keys.iterator(); i.hasNext();) { DeterministicKey parent = ((DeterministicKey) i.next()).getParent(); if (parent == null || !externalParentKey.equals(parent)) i.remove(); } return keys; }
/** * Returns only the external keys that have been issued by this chain, lookahead not included. */ public List<ECKey> getIssuedReceiveKeys() { final List<ECKey> keys = new ArrayList<ECKey>(getKeys(false)); for (Iterator<ECKey> i = keys.iterator(); i.hasNext();) { DeterministicKey parent = ((DeterministicKey) i.next()).getParent(); if (parent == null || !externalParentKey.equals(parent)) i.remove(); } return keys; }
private void checkForBitFlip(DeterministicKey k) { DeterministicKey parent = checkNotNull(k.getParent()); byte[] rederived = HDKeyDerivation.deriveChildKeyBytesFromPublic(parent, k.getChildNumber(), HDKeyDerivation.PublicDeriveMode.WITH_INVERSION).keyBytes; byte[] actual = k.getPubKey(); if (!Arrays.equals(rederived, actual)) throw new IllegalStateException(String.format(Locale.US, "Bit-flip check failed: %s vs %s", Arrays.toString(rederived), Arrays.toString(actual))); }
private void checkForBitFlip(DeterministicKey k) { DeterministicKey parent = checkNotNull(k.getParent()); byte[] rederived = HDKeyDerivation.deriveChildKeyBytesFromPublic(parent, k.getChildNumber(), HDKeyDerivation.PublicDeriveMode.WITH_INVERSION).keyBytes; byte[] actual = k.getPubKey(); if (!Arrays.equals(rederived, actual)) throw new IllegalStateException(String.format(Locale.US, "Bit-flip check failed: %s vs %s", Arrays.toString(rederived), Arrays.toString(actual))); }
private void checkForBitFlip(DeterministicKey k) { DeterministicKey parent = checkNotNull(k.getParent()); byte[] rederived = HDKeyDerivation.deriveChildKeyBytesFromPublic(parent, k.getChildNumber(), HDKeyDerivation.PublicDeriveMode.WITH_INVERSION).keyBytes; byte[] actual = k.getPubKey(); if (!Arrays.equals(rederived, actual)) throw new IllegalStateException(String.format(Locale.US, "Bit-flip check failed: %s vs %s", Arrays.toString(rederived), Arrays.toString(actual))); }
private void checkForBitFlip(DeterministicKey k) { DeterministicKey parent = checkNotNull(k.getParent()); byte[] rederived = HDKeyDerivation.deriveChildKeyBytesFromPublic(parent, k.getChildNumber(), HDKeyDerivation.PublicDeriveMode.WITH_INVERSION).keyBytes; byte[] actual = k.getPubKey(); if (!Arrays.equals(rederived, actual)) throw new IllegalStateException(String.format(Locale.US, "Bit-flip check failed: %s vs %s", Arrays.toString(rederived), Arrays.toString(actual))); }
/** * Inserts a key into the heirarchy. Used during deserialization: you normally don't need this. Keys must be * inserted in order. */ public final void putKey(DeterministicKey key) { ImmutableList<ChildNumber> path = key.getPath(); // Update our tracking of what the next child in each branch of the tree should be. Just assume that keys are // inserted in order here. final DeterministicKey parent = key.getParent(); if (parent != null) lastChildNumbers.put(parent.getPath(), key.getChildNumber()); keys.put(path, key); }
/** * Inserts a key into the heirarchy. Used during deserialization: you normally don't need this. Keys must be * inserted in order. */ public final void putKey(DeterministicKey key) { ImmutableList<ChildNumber> path = key.getPath(); // Update our tracking of what the next child in each branch of the tree should be. Just assume that keys are // inserted in order here. final DeterministicKey parent = key.getParent(); if (parent != null) lastChildNumbers.put(parent.getPath(), key.getChildNumber()); keys.put(path, key); }
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; } }
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; } }
/** * Inserts a key into the heirarchy. Used during deserialization: you normally don't need this. Keys must be * inserted in order. */ public final void putKey(DeterministicKey key) { ImmutableList<ChildNumber> path = key.getPath(); // Update our tracking of what the next child in each branch of the tree should be. Just assume that keys are // inserted in order here. final DeterministicKey parent = key.getParent(); if (parent != null) lastChildNumbers.put(parent.getPath(), key.getChildNumber()); keys.put(path, key); }
/** * Inserts a key into the hierarchy. Used during deserialization: you normally don't need this. Keys must be * inserted in order. */ public final void putKey(DeterministicKey key) { ImmutableList<ChildNumber> path = key.getPath(); // Update our tracking of what the next child in each branch of the tree should be. Just assume that keys are // inserted in order here. final DeterministicKey parent = key.getParent(); if (parent != null) lastChildNumbers.put(parent.getPath(), key.getChildNumber()); keys.put(path, key); }
/** * Returns leaf keys issued by this chain (including lookahead zone but no lookahead threshold) */ public List<DeterministicKey> getActiveKeys() { ImmutableList.Builder<DeterministicKey> keys = ImmutableList.builder(); for (ECKey key : getKeys(true)) { DeterministicKey dKey = (DeterministicKey) key; if (isLeaf(dKey)) { if (dKey.getParent().equals(internalKey) && dKey.getChildNumber().num() >= issuedInternalKeys + lookaheadSize) continue; if (dKey.getParent().equals(externalKey) && dKey.getChildNumber().num() >= issuedExternalKeys + lookaheadSize) continue; keys.add(dKey); } } return keys.build(); }
/** * Returns leaf keys issued by this chain (including lookahead zone but no lookahead threshold) */ public List<DeterministicKey> getActiveKeys() { ImmutableList.Builder<DeterministicKey> keys = ImmutableList.builder(); for (ECKey key : getKeys(true)) { DeterministicKey dKey = (DeterministicKey) key; if (isLeaf(dKey)) { if (dKey.getParent().equals(internalKey) && dKey.getChildNumber().num() >= issuedInternalKeys + lookaheadSize) continue; if (dKey.getParent().equals(externalKey) && dKey.getChildNumber().num() >= issuedExternalKeys + lookaheadSize) continue; keys.add(dKey); } } return keys.build(); }
/* package */ List<ECKey> getKeys(boolean includeLookahead) { List<ECKey> keys = basicKeyChain.getKeys(); if (!includeLookahead) { int treeSize = internalParentKey.getPath().size(); List<ECKey> issuedKeys = new LinkedList<ECKey>(); for (ECKey key : keys) { DeterministicKey detkey = (DeterministicKey) key; DeterministicKey parent = detkey.getParent(); if (parent == null) continue; if (detkey.getPath().size() <= treeSize) continue; if (parent.equals(internalParentKey) && detkey.getChildNumber().i() >= issuedInternalKeys) continue; if (parent.equals(externalParentKey) && detkey.getChildNumber().i() >= issuedExternalKeys) continue; issuedKeys.add(detkey); } return issuedKeys; } return keys; }
/* package */ List<ECKey> getKeys(boolean includeLookahead) { List<ECKey> keys = basicKeyChain.getKeys(); if (!includeLookahead) { int treeSize = internalParentKey.getPath().size(); List<ECKey> issuedKeys = new LinkedList<ECKey>(); for (ECKey key : keys) { DeterministicKey detkey = (DeterministicKey) key; DeterministicKey parent = detkey.getParent(); if (parent == null) continue; if (detkey.getPath().size() <= treeSize) continue; if (parent.equals(internalParentKey) && detkey.getChildNumber().i() >= issuedInternalKeys) continue; if (parent.equals(externalParentKey) && detkey.getChildNumber().i() >= issuedExternalKeys) continue; issuedKeys.add(detkey); } return issuedKeys; } return keys; }