@Override
  public Bytes32 calculateECDHKeyAgreement(final PublicKey partyKey)
      throws SecurityModuleException {
    try {
      final Bytes encodedECPoint = ECPointUtil.getEncodedBytes(partyKey.getW());
      final SECPPublicKey secp256KPartyKey = signatureAlgorithm.createPublicKey(encodedECPoint);
      return signatureAlgorithm.calculateECDHKeyAgreement(
          keyPair.getPrivateKey(), secp256KPartyKey);
    } catch (final Exception e) {
      throw new SecurityModuleException(
          "Unexpected error while calculating ECDH Key Agreement: " + e.getMessage(), e);
    }
  }
Instantiates a new Key pair security module.

@param keyPair the key pair
crypto/services/src/main/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModule.java