private String protoToString(List<Protos.Key> keys) { StringBuilder sb = new StringBuilder(); for (Protos.Key key : keys) { sb.append(key.toString()); sb.append("\n"); } return sb.toString().trim(); }
public com.openwallet.core.protos.Protos.Key buildPartial() { com.openwallet.core.protos.Protos.Key result = new com.openwallet.core.protos.Protos.Key(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0;
bitField0_ = (bitField0_ & ~0x00000001); if (seedBuilder_ == null) { seed_ = com.openwallet.core.protos.Protos.Key.getDefaultInstance(); } else { seedBuilder_.clear(); bitField0_ = (bitField0_ & ~0x00000004); if (masterKeyBuilder_ == null) { masterKey_ = com.openwallet.core.protos.Protos.Key.getDefaultInstance(); } else { masterKeyBuilder_.clear();
final Protos.Key.Type t = key.getType(); if (t == Protos.Key.Type.DETERMINISTIC_KEY) { if (!key.hasDeterministicKey()) throw new UnreadableWalletException("Deterministic key missing extra data: " + key.toString()); if (EXTERNAL_PATH_NUM.equals(detkey.getChildNumber())) { chain.externalKey = detkey; chain.issuedExternalKeys = key.getDeterministicKey().getIssuedSubkeys(); lookaheadSize = Math.max(lookaheadSize, key.getDeterministicKey().getLookaheadSize()); } else if (INTERNAL_PATH_NUM.equals(detkey.getChildNumber())) { chain.internalKey = detkey; chain.issuedInternalKeys = key.getDeterministicKey().getIssuedSubkeys();
Protos.Key key = walletProto.getSeed(); if (key.hasSecretBytes()) { List<String> mnemonic = Splitter.on(" ").splitToList(key.getSecretBytes().toStringUtf8()); seed = new DeterministicSeed(new byte[16], mnemonic, 0); } else if (key.hasEncryptedData()) { EncryptedData data = new EncryptedData(key.getEncryptedData().getInitialisationVector().toByteArray(), key.getEncryptedData().getEncryptedPrivateKey().toByteArray()); seed = new DeterministicSeed(data, null, 0); } else { throw new UnreadableWalletException("Malformed key proto: " + key.toString());
.computeBytesSize(5, getLabelBytes()); .computeMessageSize(6, deterministicKey_); size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size;
public static DeterministicKey getDeterministicKey(Protos.Key key, @Nullable DeterministicKey parent, @Nullable KeyCrypter crypter) { checkState(key.getType() == Protos.Key.Type.DETERMINISTIC_KEY, "Key protocol buffer must " + "have be a deterministic key type"); checkState(key.hasDeterministicKey(), "Deterministic key missing extra data."); LazyECPoint pubkey = new LazyECPoint(ECKey.CURVE.getCurve(), key.getPublicKey().toByteArray()); byte[] chainCode = key.getDeterministicKey().getChainCode().toByteArray(); if (key.hasSecretBytes()) { final BigInteger priv = new BigInteger(1, key.getSecretBytes().toByteArray()); detkey = new DeterministicKey(immutablePath, chainCode, pubkey, priv, parent); } else { if (key.hasEncryptedData()) { Protos.EncryptedData proto = key.getEncryptedData(); EncryptedData data = new EncryptedData(proto.getInitialisationVector().toByteArray(), proto.getEncryptedPrivateKey().toByteArray());
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; if (!hasType()) { memoizedIsInitialized = 0; return false; } if (hasEncryptedData()) { if (!getEncryptedData().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (hasDeterministicKey()) { if (!getDeterministicKey().isInitialized()) { memoizedIsInitialized = 0; return false; } } memoizedIsInitialized = 1; return true; }
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeEnum(1, type_.getNumber()); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeBytes(2, secretBytes_); } if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeMessage(3, encryptedData_); } if (((bitField0_ & 0x00000008) == 0x00000008)) { output.writeBytes(4, publicKey_); } if (((bitField0_ & 0x00000010) == 0x00000010)) { output.writeBytes(5, getLabelBytes()); } if (((bitField0_ & 0x00000020) == 0x00000020)) { output.writeMessage(6, deterministicKey_); } getUnknownFields().writeTo(output); }
public Builder mergeFrom(com.openwallet.core.protos.Protos.Key other) { if (other == com.openwallet.core.protos.Protos.Key.getDefaultInstance()) return this; if (other.hasType()) { setType(other.getType()); } if (other.hasSecretBytes()) { setSecretBytes(other.getSecretBytes()); } if (other.hasEncryptedData()) { mergeEncryptedData(other.getEncryptedData()); } if (other.hasPublicKey()) { setPublicKey(other.getPublicKey()); } if (other.hasLabel()) { bitField0_ |= 0x00000010; label_ = other.label_; onChanged(); } if (other.hasDeterministicKey()) { mergeDeterministicKey(other.getDeterministicKey()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
/** * <code>optional .com.openwallet.core.protos.Key seed = 2;</code> */ public Builder mergeSeed(com.openwallet.core.protos.Protos.Key value) { if (seedBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002) && seed_ != com.openwallet.core.protos.Protos.Key.getDefaultInstance()) { seed_ = com.openwallet.core.protos.Protos.Key.newBuilder(seed_).mergeFrom(value).buildPartial(); } else { seed_ = value; } onChanged(); } else { seedBuilder_.mergeFrom(value); } bitField0_ |= 0x00000002; return this; } /**
/** * <code>required .com.openwallet.core.protos.Key master_key = 3;</code> */ public Builder mergeMasterKey(com.openwallet.core.protos.Protos.Key value) { if (masterKeyBuilder_ == null) { if (((bitField0_ & 0x00000008) == 0x00000008) && masterKey_ != com.openwallet.core.protos.Protos.Key.getDefaultInstance()) { masterKey_ = com.openwallet.core.protos.Protos.Key.newBuilder(masterKey_).mergeFrom(value).buildPartial(); } else { masterKey_ = value; } onChanged(); } else { masterKeyBuilder_.mergeFrom(value); } bitField0_ |= 0x00000008; return this; } /**
/** * 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); }
/** * <code>optional string label = 5;</code> * * <pre> * User-provided label associated with the key. * </pre> */ public Builder clearLabel() { bitField0_ = (bitField0_ & ~0x00000010); label_ = getDefaultInstance().getLabel(); onChanged(); return this; } /**
/** * <code>optional .com.openwallet.core.protos.Key seed = 2;</code> */ public Builder clearSeed() { if (seedBuilder_ == null) { seed_ = com.openwallet.core.protos.Protos.Key.getDefaultInstance(); onChanged(); } else { seedBuilder_.clear(); } bitField0_ = (bitField0_ & ~0x00000002); return this; } /**
public com.openwallet.core.protos.Protos.Key getDefaultInstanceForType() { return com.openwallet.core.protos.Protos.Key.getDefaultInstance(); }
/** * <code>required .com.openwallet.core.protos.Key master_key = 3;</code> */ public Builder clearMasterKey() { if (masterKeyBuilder_ == null) { masterKey_ = com.openwallet.core.protos.Protos.Key.getDefaultInstance(); onChanged(); } else { masterKeyBuilder_.clear(); } bitField0_ = (bitField0_ & ~0x00000008); return this; } /**
/** * <code>optional bytes public_key = 4;</code> * * <pre> * The public EC key derived from the private key. We allow both to be stored to avoid mobile clients having to * do lots of slow EC math on startup. For DETERMINISTIC_MNEMONIC entries this is missing. * </pre> */ public Builder clearPublicKey() { bitField0_ = (bitField0_ & ~0x00000008); publicKey_ = getDefaultInstance().getPublicKey(); onChanged(); return this; }
/** * <code>optional bytes secret_bytes = 2;</code> * * <pre> * Either the private EC key bytes (without any ASN.1 wrapping), or the deterministic root seed. * If the secret is encrypted, or this is a "watching entry" then this is missing. * </pre> */ public Builder clearSecretBytes() { bitField0_ = (bitField0_ & ~0x00000002); secretBytes_ = getDefaultInstance().getSecretBytes(); onChanged(); return this; }
public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { return com.openwallet.core.protos.Protos.Key.getDescriptor().getEnumTypes().get(0); }