title: Apple Pay - How to compare merchant public key with publicKeyHash from payment token?
body: <p>I'm working on Apple Pay payment token decryption.
  According to this instruction <a href="https://developer.apple.com/library/content/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html#//apple_ref/doc/uid/TP40014929-CH8-SW3" rel="nofollow noreferrer">Payment Token Format Reference</a> on step 2. I need use publicKeyHash field from header of payment token to determine which
  merchant certificate was used by Apple.</p>
  <p>pulbicKeyHash is SHA–256 hash of the X.509 encoded public key bytes of the merchant’s certificate, Base64 encoded as a string.</p>
  <p>I have one merchant certificate. So I assume that if i will take sha-256 hash of my certificate's public key and Base64 encode it i will get the same value that i receive in publicKeyHash field of payment token.</p>
  <p>But I can't figure out what particular part of the certificate should I hash.
  The initial merchant certificate provided by Apple is in .cer format.
  I'have extracted public key from it to .pem format. Than i have tried both take hash -&gt; base64encode of public key (String between -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----) and
  to take hash of base64 decoded .pem which i think should be .der and base 64 encode it.</p>
  <p>And both failed to match value received from Apple Pay. Also it have different length my base64 encoded hash have 88 char length, and publicKeyHash  field is 44 char in length.</p>
  <p>When I have tried to base 64 decode publicKeyHash, I've got unreadeble characters like &quot;D�đ���$�f���@c���$����WP��&quot;
  But according to Apple documentation there should be sha-256 hash which can not contain such symbols.</p>
  <p>Can somebody explain me what concrete steps should I perform in order to complete this merchant certificate check?</p>