public ECKey getECKey() { if(key == null) { key = ECKey.fromPublicOnly(bytes); } return key; }
/** * Constructs a key that has an encrypted private component. The given object wraps encrypted bytes and an * initialization vector. Note that the key will not be decrypted during this call: the returned ECKey is * unusable for signing unless a decryption key is supplied. */ public static ECKey fromEncrypted(EncryptedData encryptedPrivateKey, KeyCrypter crypter, byte[] pubKey) { ECKey key = fromPublicOnly(pubKey); key.encryptedPrivateKey = checkNotNull(encryptedPrivateKey); key.keyCrypter = checkNotNull(crypter); return key; }
/** * Constructs a key that has an encrypted private component. The given object wraps encrypted bytes and an * initialization vector. Note that the key will not be decrypted during this call: the returned ECKey is * unusable for signing unless a decryption key is supplied. */ public static ECKey fromEncrypted(EncryptedData encryptedPrivateKey, KeyCrypter crypter, byte[] pubKey) { ECKey key = fromPublicOnly(pubKey); key.encryptedPrivateKey = checkNotNull(encryptedPrivateKey); key.keyCrypter = checkNotNull(crypter); return key; }
/** * Constructs a key that has an encrypted private component. The given object wraps encrypted bytes and an * initialization vector. Note that the key will not be decrypted during this call: the returned ECKey is * unusable for signing unless a decryption key is supplied. */ public static ECKey fromEncrypted(EncryptedData encryptedPrivateKey, KeyCrypter crypter, byte[] pubKey) { ECKey key = fromPublicOnly(pubKey); key.encryptedPrivateKey = checkNotNull(encryptedPrivateKey); key.keyCrypter = checkNotNull(crypter); return key; }
/** * Constructs a key that has an encrypted private component. The given object wraps encrypted bytes and an * initialization vector. Note that the key will not be decrypted during this call: the returned ECKey is * unusable for signing unless a decryption key is supplied. */ public static ECKey fromEncrypted(EncryptedData encryptedPrivateKey, KeyCrypter crypter, byte[] pubKey) { ECKey key = fromPublicOnly(pubKey); key.encryptedPrivateKey = checkNotNull(encryptedPrivateKey); key.keyCrypter = checkNotNull(crypter); return key; }
void parseMessage (byte[] data) { byte[] pubkeyOfNextHop = new byte[33]; System.arraycopy(data, 0, pubkeyOfNextHop, 0, 33); byte[] emptyData = new byte[OnionObject.KEY_LENGTH]; if (Arrays.equals(emptyData, pubkeyOfNextHop)) { System.out.println("We are the last hop.."); isLastHop = true; } else { nextHop = ECKey.fromPublicOnly(pubkeyOfNextHop); } }
private static ECDHKeySet getKeySet (ECKey keyServer, OnionObject encryptedOnionObject) { byte[] key = new byte[OnionObject.KEY_LENGTH]; System.arraycopy(encryptedOnionObject.data, 0, key, 0, key.length); ECKey ephemeralKey = ECKey.fromPublicOnly(key); ECDHKeySet keySet = ECDH.getSharedSecret(keyServer, ephemeralKey); return keySet; }
private ClientObject ipObjectToNode (PubkeyIPObject ipObject, ConnectionIntent intent) { ClientObject node = new ClientObject(); node.isServer = false; node.intent = intent; node.pubKeyClient = ECKey.fromPublicOnly(ipObject.pubkey); node.host = ipObject.hostname; node.port = ipObject.port; return node; }
public void verifySignature () throws UnsupportedEncodingException, NoSuchProviderException, NoSuchAlgorithmException { if (!CryptoTools.verifySignature(ECKey.fromPublicOnly(pubkey), this.getData(), this.signature)) { throw new RuntimeException("Signature failed.."); } }
private int findSigInRedeem(byte[] signatureBytes, Sha256Hash hash) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true); for (int i = 0 ; i < numKeys ; i++) { if (ECKey.fromPublicOnly(chunks.get(i + 1).data).verify(hash, signature)) { return i; } } throw new IllegalStateException("Could not find matching key for signature on " + hash.toString() + " sig " + Utils.HEX.encode(signatureBytes)); }
private int findSigInRedeem(byte[] signatureBytes, Sha256Hash hash) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true); for (int i = 0 ; i < numKeys ; i++) { if (ECKey.fromPublicOnly(chunks.get(i + 1).data).verify(hash, signature)) { return i; } } throw new IllegalStateException("Could not find matching key for signature on " + hash.toString() + " sig " + Utils.HEX.encode(signatureBytes)); }
PaymentChannelV1ServerState(StoredServerChannel storedServerChannel, Wallet wallet, TransactionBroadcaster broadcaster) throws VerificationException { super(storedServerChannel, wallet, broadcaster); synchronized (storedServerChannel) { this.clientKey = ECKey.fromPublicOnly(getContractScript().getChunks().get(1).data); this.clientOutput = checkNotNull(storedServerChannel.clientOutput); this.refundTransactionUnlockTimeSecs = storedServerChannel.refundTransactionUnlockTimeSecs; stateMachine.transition(State.READY); } }
private int findSigInRedeem(byte[] signatureBytes, Sha256Hash hash) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true); for (int i = 0 ; i < numKeys ; i++) { if (ECKey.fromPublicOnly(chunks.get(i + 1).data).verify(hash, signature)) { return i; } } throw new IllegalStateException("Could not find matching key for signature on " + hash.toString() + " sig " + HEX.encode(signatureBytes)); }
PaymentChannelV1ServerState(StoredServerChannel storedServerChannel, Wallet wallet, TransactionBroadcaster broadcaster) throws VerificationException { super(storedServerChannel, wallet, broadcaster); synchronized (storedServerChannel) { this.clientKey = ECKey.fromPublicOnly(getContractScript().getChunks().get(1).data); this.clientOutput = checkNotNull(storedServerChannel.clientOutput); this.refundTransactionUnlockTimeSecs = storedServerChannel.refundTransactionUnlockTimeSecs; stateMachine.transition(State.READY); } }
PaymentChannelV1ServerState(StoredServerChannel storedServerChannel, Wallet wallet, TransactionBroadcaster broadcaster) throws VerificationException { super(storedServerChannel, wallet, broadcaster); synchronized (storedServerChannel) { this.clientKey = ECKey.fromPublicOnly(getContractScript().getChunks().get(1).data); this.clientOutput = checkNotNull(storedServerChannel.clientOutput); this.refundTransactionUnlockTimeSecs = storedServerChannel.refundTransactionUnlockTimeSecs; stateMachine.transition(State.READY); } }
public VerificationKeyImpl(byte[] ecKey, NetworkParameters params) { this.ecKey = ECKey.fromPublicOnly(ecKey); this.vKey = this.ecKey.getPubKey(); this.params = params; this.address = new AddressImpl(this.ecKey.toAddress(params)); }
public VerificationKeyImpl(String string, NetworkParameters params) { // TODO byte[] bytes = Hex.decode(string); this.ecKey = ECKey.fromPublicOnly(bytes); this.vKey = this.ecKey.getPubKey(); this.params = params; this.address = new AddressImpl(this.ecKey.toAddress(params)); }
private void processEncryptionInitialMessage (Message message) { if (!(message instanceof EncryptionInitialMessage)) { executor.sendMessageUpwards(messageFactory.getFailureMessage("Expecting EncryptionInitial Message.. " + message)); } else { EncryptionInitialMessage encryptionInitial = (EncryptionInitialMessage) message; node.ephemeralKeyClient = ECKey.fromPublicOnly(encryptionInitial.key); node.ecdhKeySet = ECDH.getSharedSecret(node.ephemeralKeyServer, node.ephemeralKeyClient); sendInitialMessageIfNotSent(); onKeyExchangeFinished(); } }
@Test public void isWatching() { group = new KeyChainGroup( PARAMS, DeterministicKey .deserializeB58( "xpub69bjfJ91ikC5ghsqsVDHNq2dRGaV2HHVx7Y9LXi27LN9BWWAXPTQr4u8U3wAtap8bLdHdkqPpAcZmhMS5SnrMQC4ccaoBccFhh315P4UYzo", PARAMS)); final ECKey watchingKey = ECKey.fromPublicOnly(new ECKey().getPubKeyPoint()); group.importKeys(watchingKey); assertTrue(group.isWatching()); }
@Test public void testPublicKeysAreEqual() { ECKey key = new ECKey(); ECKey pubKey1 = ECKey.fromPublicOnly(key.getPubKeyPoint()); assertTrue(pubKey1.isCompressed()); ECKey pubKey2 = pubKey1.decompress(); assertEquals(pubKey1, pubKey2); assertEquals(pubKey1.hashCode(), pubKey2.hashCode()); } }