public static byte[] computeSharedSecret(ECPrivateKey myPrivateKey, ECPublicKey peerPublicKey)
      throws GeneralSecurityException {
    validatePublicKeySpec(peerPublicKey, myPrivateKey);
    return computeSharedSecret(myPrivateKey, peerPublicKey.getW());
  }
Checks that the shared secret is on the curve of the private key, to prevent arithmetic errors
or fault attacks.
java_src/src/main/java/com/google/crypto/tink/subtle/EllipticCurves.java