/** * Returns the key chain found in the given list of keys. */ public static NxtFamilyKey fromProtobuf(List<Protos.Key> keys, @Nullable KeyCrypter crypter) throws UnreadableWalletException { if (keys.size() != 2) { throw new UnreadableWalletException("Expected 2 keys, NXT secret and Curve25519 " + "pub/priv pair, instead got: " + keys.size()); } Protos.Key entropyProto = keys.get(0); DeterministicKey entropyKey = KeyUtils.getDeterministicKey(entropyProto, null, crypter); Protos.Key publicKeyProto = keys.get(1); if (publicKeyProto.getType() != Protos.Key.Type.ORIGINAL) { throw new UnreadableWalletException("Unexpected type for NXT public key: " + publicKeyProto.getType()); } byte[] publicKeyBytes = publicKeyProto.getPublicKey().toByteArray(); return new NxtFamilyKey(entropyKey, publicKeyBytes); }
public NxtFamilyWallet(NxtFamilyKey key, CoinType type) { this(KeyUtils.getPublicKeyId(type, key.getPublicKey()), key, type); }
public static Protos.Key.Builder serializeKey(ECKey key) { Protos.Key.Builder protoKey = serializeEncryptableItem(key); protoKey.setPublicKey(ByteString.copyFrom(key.getPubKey())); return protoKey; }
DeterministicKey rootKey = KeyUtils.getDeterministicKey(key, null, crypter); chain = new SimpleHDKeyChain(rootKey, crypter); chain.lookaheadSize = LAZY_CALCULATE_LOOKAHEAD; rootTreeSize = rootKey.getPath().size(); LinkedList<ChildNumber> path = newLinkedList(KeyUtils.getKeyProtoPath(key)); path.add(index); DeterministicKey detkey = KeyUtils.getDeterministicKey(key, parent, crypter); if (log.isDebugEnabled()) { log.debug("Deserializing: DETERMINISTIC_KEY: {}", detkey);
Map<ECKey, Protos.Key.Builder> toEditableProtobufs() { Map<ECKey, Protos.Key.Builder> result = new LinkedHashMap<ECKey, Protos.Key.Builder>(); for (ECKey ecKey : getKeys()) { Protos.Key.Builder protoKey = KeyUtils.serializeKey(ecKey); result.put(ecKey, protoKey); } return result; } }
final ImmutableList<ChildNumber> immutablePath = getKeyProtoPath(key);
List<Protos.Key.Builder> toEditableProtobuf() { LinkedList<Protos.Key.Builder> entries = newLinkedList(); // Entropy Protos.Key.Builder entropyProto = KeyUtils.serializeKey(entropy); entropyProto.setType(Protos.Key.Type.DETERMINISTIC_KEY); final Protos.DeterministicKey.Builder detKey = entropyProto.getDeterministicKeyBuilder(); detKey.setChainCode(ByteString.copyFrom(entropy.getChainCode())); for (ChildNumber num : entropy.getPath()) { detKey.addPath(num.i()); } entries.add(entropyProto); // NTX key Protos.Key.Builder publicKeyProto = Protos.Key.newBuilder(); publicKeyProto.setType(Protos.Key.Type.ORIGINAL); publicKeyProto.setPublicKey(ByteString.copyFrom(publicKey)); entries.add(publicKeyProto); return entries; }
private static Protos.Key getMasterKeyProto(Wallet wallet) { DeterministicKey key = wallet.getMasterKey(); Protos.Key.Builder proto = KeyUtils.serializeKey(key); proto.setType(Protos.Key.Type.DETERMINISTIC_KEY); final Protos.DeterministicKey.Builder detKey = proto.getDeterministicKeyBuilder(); detKey.setChainCode(ByteString.copyFrom(key.getChainCode())); for (ChildNumber num : key.getPath()) { detKey.addPath(num.i()); } return proto.build(); }
Protos.Key.Builder mnemonicEntry = KeyUtils.serializeEncryptableItem(wallet.getSeed()); mnemonicEntry.setType(Protos.Key.Type.DETERMINISTIC_MNEMONIC); walletBuilder.setSeed(mnemonicEntry.build());
WalletPocketHD(SimpleHDKeyChain keys, CoinType coinType) { this(KeyUtils.getPublicKeyId(coinType, keys.getRootKey().getPubKey()), keys, coinType); }
KeyUtils.getDeterministicKey(walletProto.getMasterKey(), null, crypter);