void computeSecrets() {
    final Bytes agreedSecret =
        signatureAlgorithm.calculateECDHKeyAgreement(ephKeyPair.getPrivateKey(), partyEphPubKey);

    final Bytes sharedSecret =
        keccak256(
            concatenate(agreedSecret, keccak256(concatenate(responderNonce, initiatorNonce))));

    final Bytes32 aesSecret = keccak256(concatenate(agreedSecret, sharedSecret));
    final Bytes32 macSecret = keccak256(concatenate(agreedSecret, aesSecret));
    final Bytes32 token = keccak256(sharedSecret);

    final HandshakeSecrets secrets =
        new HandshakeSecrets(aesSecret.toArray(), macSecret.toArray(), token.toArray());

    final Bytes initiatorMac = concatenate(macSecret.xor(responderNonce), initiatorMsgEnc);
    final Bytes responderMac = concatenate(macSecret.xor(initiatorNonce), responderMsgEnc);

    if (initiator) {
      secrets.updateEgress(initiatorMac.toArray());
      secrets.updateIngress(responderMac.toArray());
    } else {
      secrets.updateIngress(initiatorMac.toArray());
      secrets.updateEgress(responderMac.toArray());
    }

    this.secrets = secrets;
  }
Computes the secrets from the two exchanged messages.
ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/handshake/ecies/ECIESHandshaker.java