DeterministicKey key = (DeterministicKey) findKeyFromPubKey(pubkey);
if (key == null) {
if (index == -1)
return null;
List<ChildNumber> path = checkNotNull(freshAuthKey().getParent()).getPath();
key = getKeyByPath(HDUtils.append(path, new ChildNumber(index)));
if (!Arrays.equals(key.getPubKey(), pubkey))
return null;
}
return key;
}