This is example callback verification code in Ruby (https://developers.coinbase.com/docs/wallet/notifications):

CALLBACK_DIGEST = OpenSSL::Digest.new("SHA256")

def self.verify_callback(body, signature)
  return false unless callback_signing_public_key
  callback_signing_public_key.verify(CALLBACK_DIGEST, signature.unpack("m0")[0], body)
  rescue OpenSSL::PKey::RSAError, ArgumentError

def self.callback_signing_public_key
  @@callback_signing_public_key ||= nil
  return @@callback_signing_public_key if @@callback_signing_public_key
  path = File.expand_path(File.join(File.dirname(__FILE__), 'coinbase-callback.pub'))
  @@callback_signing_public_key = OpenSSL::PKey::RSA.new(File.read(path))

How can I do this in PHP ?

  • Asking for someone to port code for you isn't a very good question. Perhaps you should be more specific in your question about the parts of the code you don't understand. – Jestin Sep 21 '16 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.