@Override
  public Bytes32 calculateECDHKeyAgreement(
      final SECPPrivateKey privKey, final SECPPublicKey theirPubKey) {
    checkArgument(privKey != null, "missing private key");
    checkArgument(theirPubKey != null, "missing remote public key");

    final ECPrivateKeyParameters privKeyP = new ECPrivateKeyParameters(privKey.getD(), curve);
    final ECPublicKeyParameters pubKeyP =
        new ECPublicKeyParameters(theirPubKey.asEcPoint(curve), curve);

    final ECDHBasicAgreement agreement = new ECDHBasicAgreement();
    agreement.init(privKeyP);
    final BigInteger agreed = agreement.calculateAgreement(pubKeyP);

    return UInt256.valueOf(agreed);
  }
Calculates an ECDH key agreement between the private and the public key.

@param privKey The private key.
@param theirPubKey The public key.
@return The agreed secret.
crypto/algorithms/src/main/java/org/hyperledger/besu/crypto/AbstractSECP256.java