if (!key.hasPublicKey()) throw new UnreadableWalletException("Public key missing"); byte[] pub = key.getPublicKey().toByteArray(); ECKey ecKey; if (encrypted) {
if (!key.hasPublicKey()) throw new UnreadableWalletException("Public key missing"); byte[] pub = key.getPublicKey().toByteArray(); ECKey ecKey; if (encrypted) {
if (!key.hasPublicKey()) throw new UnreadableWalletException("Public key missing"); byte[] pub = key.getPublicKey().toByteArray(); ECKey ecKey; if (encrypted) {
path.add(new ChildNumber(i)); LazyECPoint pubkey = new LazyECPoint(ECKey.CURVE.getCurve(), key.getPublicKey().toByteArray()); final ImmutableList<ChildNumber> immutablePath = ImmutableList.copyOf(path);
path.add(new ChildNumber(i)); LazyECPoint pubkey = new LazyECPoint(ECKey.CURVE.getCurve(), key.getPublicKey().toByteArray()); final ImmutableList<ChildNumber> immutablePath = ImmutableList.copyOf(path);
path.add(new ChildNumber(i)); LazyECPoint pubkey = new LazyECPoint(ECKey.CURVE.getCurve(), key.getPublicKey().toByteArray()); final ImmutableList<ChildNumber> immutablePath = ImmutableList.copyOf(path);
byte[] pubKey = keyProto.hasPublicKey() ? keyProto.getPublicKey().toByteArray() : null;
setPublicKey(other.getPublicKey());
setPublicKey(other.getPublicKey());
if (!key.hasPublicKey()) throw new UnreadableWalletException("Public key missing"); byte[] pub = key.getPublicKey().toByteArray(); ECKey ecKey; if (encrypted) {
setPublicKey(other.getPublicKey());
setPublicKey(other.getPublicKey());
@Test public void serializationUnencrypted() throws UnreadableWalletException { Utils.setMockClock(); Date now = Utils.now(); final ECKey key1 = new ECKey(); Utils.rollMockClock(5000); final ECKey key2 = new ECKey(); chain.importKeys(ImmutableList.of(key1, key2)); List<Protos.Key> keys = chain.serializeToProtobuf(); assertEquals(2, keys.size()); assertArrayEquals(key1.getPubKey(), keys.get(0).getPublicKey().toByteArray()); assertArrayEquals(key2.getPubKey(), keys.get(1).getPublicKey().toByteArray()); assertArrayEquals(key1.getPrivKeyBytes(), keys.get(0).getSecretBytes().toByteArray()); assertArrayEquals(key2.getPrivKeyBytes(), keys.get(1).getSecretBytes().toByteArray()); long normTime = (long) (Math.floor(now.getTime() / 1000) * 1000); assertEquals(normTime, keys.get(0).getCreationTimestamp()); assertEquals(normTime + 5000 * 1000, keys.get(1).getCreationTimestamp()); chain = BasicKeyChain.fromProtobufUnencrypted(keys); assertEquals(2, chain.getKeys().size()); assertEquals(key1, chain.getKeys().get(0)); assertEquals(key2, chain.getKeys().get(1)); }
public Builder mergeFrom(org.bitcoinj.wallet.Protos.Key other) { if (other == org.bitcoinj.wallet.Protos.Key.getDefaultInstance()) return this; if (other.hasType()) { setType(other.getType()); } if (other.hasPrivateKey()) { setPrivateKey(other.getPrivateKey()); } if (other.hasEncryptedPrivateKey()) { mergeEncryptedPrivateKey(other.getEncryptedPrivateKey()); } if (other.hasPublicKey()) { setPublicKey(other.getPublicKey()); } if (other.hasLabel()) { bitField0_ |= 0x00000010; label_ = other.label_; onChanged(); } if (other.hasCreationTimestamp()) { setCreationTimestamp(other.getCreationTimestamp()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
@Test public void serializationEncrypted() throws UnreadableWalletException { ECKey key1 = new ECKey(); chain.importKeys(key1); chain = chain.toEncrypted("foo bar"); key1 = chain.getKeys().get(0); List<Protos.Key> keys = chain.serializeToProtobuf(); assertEquals(1, keys.size()); assertArrayEquals(key1.getPubKey(), keys.get(0).getPublicKey().toByteArray()); assertFalse(keys.get(0).hasSecretBytes()); assertTrue(keys.get(0).hasEncryptedData()); chain = BasicKeyChain.fromProtobufEncrypted(keys, checkNotNull(chain.getKeyCrypter())); assertEquals(key1.getEncryptedPrivateKey(), chain.getKeys().get(0).getEncryptedPrivateKey()); assertTrue(chain.checkPassword("foo bar")); }
/** * <code>optional bytes public_key = 3;</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 public_key = 3;</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. * </pre> */ public Builder clearPublicKey() { bitField0_ = (bitField0_ & ~0x00000008); publicKey_ = getDefaultInstance().getPublicKey(); onChanged(); return this; }
/** * <code>optional bytes public_key = 3;</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 public_key = 3;</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 public_key = 3;</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; }