1

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
  false
end

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))
end

How can I do this in PHP ?

Sven Williamson
  • 1,524
  • 10
  • 23
Eka
  • 11
  • 2
  • 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

0 Answers0