/** Inserts the given key and equivalent hashed form (for the address). */ public synchronized void insert(ECKey key) { insert(key.getPubKey()); insert(key.getPubKeyHash()); }
private List<PubkeyIPObject> removeOurIPFromList (List<PubkeyIPObject> list) { List<PubkeyIPObject> toRemove = new ArrayList<>(); for (PubkeyIPObject ip : list) { if (Arrays.equals(ip.pubkey, serverObject.pubKeyServer.getPubKey())) { toRemove.add(ip); } } list.removeAll(toRemove); return list; } }
@Override public List<Channel> getChannel (ECKey nodeKey) { synchronized (channelList) { return channelList.stream().filter(channel1 -> Arrays.equals(channel1.nodeKeyClient, nodeKey.getPubKey())).collect(Collectors.toList()); } }
public static Script getChannelTxOutputPaymentReceiving (ECKey keyServer, ECKey keyClient, RevocationHash revocationHash, PaymentSecret secret, int refundTimeout) { return produceScript(CHANNEL_TX_OUTPUT_PAYMENT_RECEIVING_ONE, revocationHash.getSecretHash(), keyClient.getPubKey(), secret.hash, keyServer.getPubKey(), keyClient.getPubKey(), integerToByteArray(refundTimeout), keyClient.getPubKey()); }
public static Script getChannelTxOutputPaymentSending (ECKey keyServer, ECKey keyClient, RevocationHash revocationHash, PaymentSecret secret, int refundTimeout) { return produceScript(CHANNEL_TX_OUTPUT_PAYMENT_SENDING_ONE, revocationHash.getSecretHash(), secret.hash, keyClient.getPubKey(), integerToByteArray(refundTimeout), keyServer.getPubKey(), keyClient.getPubKey()); }
@Override public int hashCode() { // Public keys are random already so we can just use a part of them as the hashcode. Read from the start to // avoid picking up the type code (compressed vs uncompressed) which is tacked on the end. byte[] bits = getPubKey(); return Ints.fromBytes(bits[0], bits[1], bits[2], bits[3]); }
public static Script getAnchorOutputScript (ECKey keyClient, ECKey keyServer) { List<byte[]> keyList = new ArrayList<>(); keyList.add(keyClient.getPubKey()); keyList.add(keyServer.getPubKey()); keyList.sort(UnsignedBytes.lexicographicalComparator()); return produceScript(ANCHOR_OUTPUT_SCRIPT, keyList.get(0), keyList.get(1)); }
public static Script getChannelTxOutputRevocation (@NotNull RevocationHash revocationHash, @NotNull ECKey keyServer, ECKey keyClient, int revocationDelay) { return produceScript(CHANNEL_TX_OUTPUT_REVOCATION, revocationHash.getSecretHash(), keyClient.getPubKey(), integerToByteArray(revocationDelay), keyServer.getPubKey()); }
Map<ECKey, Protos.Key.Builder> serializeToEditableProtobufs() { Map<ECKey, Protos.Key.Builder> result = new LinkedHashMap<>(); for (ECKey ecKey : hashToKeys.values()) { Protos.Key.Builder protoKey = serializeEncryptableItem(ecKey); protoKey.setPublicKey(ByteString.copyFrom(ecKey.getPubKey())); result.put(ecKey, protoKey); } return result; }
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); }
public static Script getPaymentTxOutput (ECKey keyReceiver, ECKey keyRevocation, RevocationHash revocationHash, int revocationTimeout) { return produceScript(CHANNEL_TX_OUTPUT_PAYMENT_TWO, revocationHash.getSecretHash(), keyRevocation.getPubKey(), integerToByteArray(revocationTimeout), keyReceiver.getPubKey()); }
public static Protos.Key.Builder serializeKey(ECKey key) { Protos.Key.Builder protoKey = serializeEncryptableItem(key); protoKey.setPublicKey(ByteString.copyFrom(key.getPubKey())); return protoKey; }
public LNEstablishAMessage (ECKey channelKeyServer, Transaction anchor, RevocationHash revocationHash, long clientAmount, long serverAmount, int minConfirmationAnchor, Address address, int feePerByte, long csvDelay) { this.channelKeyServer = channelKeyServer.getPubKey(); this.minConfirmationAnchor = minConfirmationAnchor; this.anchorTransaction = anchor.bitcoinSerialize(); this.revocationHash = revocationHash; this.amountClient = clientAmount; this.amountServer = serverAmount; this.addressBytes = address.getHash160(); this.feePerByte = feePerByte; this.csvDelay = csvDelay; }
/** * Verifies the given R/S pair (signature) against a hash using the public key. */ public boolean verify(Sha256Hash sigHash, ECDSASignature signature) { return ECKey.verify(sigHash.getBytes(), signature, getPubKey()); }
private void saveReceiverToDatabase (PaymentData payment, PeeledOnion peeledOnion) { if (peeledOnion.isLastHop) { dbHandler.updatePaymentAddReceiverAddress(payment.secret, new byte[0]); } else { dbHandler.updatePaymentAddReceiverAddress(payment.secret, peeledOnion.nextHop.getPubKey()); } }
private void sendInitialMessageIfNotSent () { if (!encSent) { executor.sendMessageUpwards(messageFactory.getEncryptionInitialMessage(node.ephemeralKeyServer.getPubKey())); encSent = true; } }
public static Script getChannelTxOutputReceiving (RevocationHash revocationHash, PaymentData paymentData, ECKey keyServer, ECKey keyClient) { return produceScript(CHANNEL_TX_OUTPUT_PAYMENT_RECEIVING, paymentData.secret.hash, integerToByteArray(paymentData.csvDelay), keyClient.getPubKey(), revocationHash.getSecretHash(), integerToByteArray(paymentData.timestampRefund), keyServer.getPubKey()); }
/** * Create a witness that can redeem a pay-to-witness-pubkey-hash output. */ public static TransactionWitness createWitness(@Nullable final TransactionSignature signature, final ECKey pubKey) { final byte[] sigBytes = signature != null ? signature.encodeToBitcoin() : new byte[]{}; final byte[] pubKeyBytes = pubKey.getPubKey(); final TransactionWitness witness = new TransactionWitness(2); witness.setPush(0, sigBytes); witness.setPush(1, pubKeyBytes); return witness; }