/** * Produce a string rendering of the ECKey INCLUDING the private key. * Unless you absolutely need the private key it is better for security reasons to just use {@link #toString()}. */ public String toStringWithPrivate(NetworkParameters params) { return toString(true, params); }
@Test public void testToString() throws Exception { ECKey key = ECKey.fromPrivate(BigInteger.TEN).decompress(); // An example private key. NetworkParameters params = MainNetParams.get(); assertEquals("ECKey{pub HEX=04a0434d9e47f3c86235477c7b1ae6ae5d3442d49b1943c2b752a68e2a47e247c7893aba425419bc27a3b6c7e693a24c696f794c2ed877a1593cbee53b037368d7, isEncrypted=false, isPubKeyOnly=false}", key.toString()); assertEquals("ECKey{pub HEX=04a0434d9e47f3c86235477c7b1ae6ae5d3442d49b1943c2b752a68e2a47e247c7893aba425419bc27a3b6c7e693a24c696f794c2ed877a1593cbee53b037368d7, priv HEX=000000000000000000000000000000000000000000000000000000000000000a, priv WIF=5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreBoNWTw6, isEncrypted=false, isPubKeyOnly=false}", key.toStringWithPrivate(params)); }
@Override public String toString() { return toString(false, null, null); }
/** * Produce a string rendering of the ECKey INCLUDING the private key. * Unless you absolutely need the private key it is better for security reasons to just use {@link #toString()}. */ public String toStringWithPrivate(NetworkParameters params) { return toString(true, params); }
/** * Produce a string rendering of the ECKey INCLUDING the private key. * Unless you absolutely need the private key it is better for security reasons to just use {@link #toString()}. */ public String toStringWithPrivate(NetworkParameters params) { return toString(true, params); }
@Override public String toString() { return toString(false, null); }
@Override public String toString() { return toString(false, null); }
@Override public String toString() { return toString(false, null); }
/** * Produce a string rendering of the ECKey INCLUDING the private key. * Unless you absolutely need the private key it is better for security reasons to just use {@link #toString()}. */ public String toStringWithPrivate(@Nullable KeyParameter aesKey, NetworkParameters params) { return toString(true, aesKey, params); }
private int findKeyInRedeem(ECKey key) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); for (int i = 0 ; i < numKeys ; i++) { if (Arrays.equals(chunks.get(1 + i).data, key.getPubKey())) { return i; } } throw new IllegalStateException("Could not find matching key " + key.toString() + " in script " + this); }
private int findKeyInRedeem(ECKey key) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); for (int i = 0 ; i < numKeys ; i++) { if (Arrays.equals(chunks.get(1 + i).data, key.getPubKey())) { return i; } } throw new IllegalStateException("Could not find matching key " + key.toString() + " in script " + this); }
private int findKeyInRedeem(ECKey key) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); for (int i = 0 ; i < numKeys ; i++) { if (Arrays.equals(chunks.get(1 + i).data, key.getPubKey())) { return i; } } throw new IllegalStateException("Could not find matching key " + key.toString() + " in script " + this); }
private int findKeyInRedeem(ECKey key) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); for (int i = 0 ; i < numKeys ; i++) { if (Arrays.equals(chunks.get(1 + i).data, key.getPubKey())) { return i; } } throw new IllegalStateException("Could not find matching key " + key.toString() + " in script " + this); }
throw new KeyCrypterException("The key " + key.toString() + " cannot be successfully decrypted after encryption so aborting wallet encryption."); encrypted.importKeyLocked(encryptedKey);
throw new KeyCrypterException("The key " + key.toString() + " cannot be successfully decrypted after encryption so aborting wallet encryption."); encrypted.importKeyLocked(encryptedKey);
throw new KeyCrypterException("The key " + key.toString() + " cannot be successfully decrypted after encryption so aborting wallet encryption."); encrypted.importKeyLocked(encryptedKey);
throw new KeyCrypterException("The key " + key.toString() + " cannot be successfully decrypted after encryption so aborting wallet encryption."); encrypted.importKeyLocked(encryptedKey);
@Test public void testToString() throws Exception { System.out.println("\ntestToString:"); System.out.println("ecKeyPubAsHex: " + ecKey.getPublicKeyAsHex()); System.out.println("pub from ecKey toString " + pub.toString()); System.out.println("EncKey.toString: " + ek.toString()); assertEquals("toString of ecKeyPubHex same as EncryptionKeyToString ", (new EncryptionKeyImpl(pubKey)).toString(), ek.toString()); assertEquals(ek, new EncryptionKeyImpl(ek.toString())); } }
@Test public void testEncryptionKey() throws Exception { System.out.println("\nBegin Test encryptionKey:"); EncryptionKey encryptionKey1 = new EncryptionKeyImpl(testKeys.getPublic()); // // PublicKey publicKey = BitcoinCrypto.loadPublicKey(Base64.getEncoder().encodeToString(ecKey.getPubKey())); System.out.println("ecKey: " + ecKey.toString()); System.out.println("ecKey priv: " + ecKey.getPrivateKeyAsHex()); System.out.println("secureRandom: " + secureRandom.nextInt()); System.out.println("decryptionKey: " + decryptionKey.toString()); System.out.println("ASN.1 " + Arrays.toString(ecKey.toASN1())); EncryptionKeyImpl encTest = new EncryptionKeyImpl(publicTestKey); System.out.println("\nencTest: " + encTest); System.out.println("encryptionKey: " + encryptionKey1); System.out.println("EncKey.toString from ECKeys Pub: " + encTest.toString()); System.out.println("EncKey from DecKey to string: " + decryptionKey.EncryptionKey().toString()); encryptionKey = new EncryptionKeyImpl(publicTestKey); assertEquals(encryptionKey.toString(), decryptionKey.EncryptionKey().toString()); }