bitpay / jsonPaymentProtocol

JSON Payment Protocol Interface
47 stars 57 forks source link

Signature is invalid #23

Closed elbelga closed 5 years ago

elbelga commented 5 years ago

When I retrieve and invoice like this https://bitpay.com/i/9NS2N7jueaGGAc8qHSJbz7

HTTP/1.1 200 OK
Date: Fri, 01 Mar 2019 11:32:42 GMT
Content-Type: application/payment-request; charset=utf-8
Content-Length: 405
Connection: close
Strict-Transport-Security: max-age=31536000
x-signature-type: ecc
x-identity: 1DbY94wCcLRM1Y6RGFg457JyqBbsYxzfiN
signature: 38ca09c742a325d9c38a87de621cd896a5fabb4d01942fc0126b58a8a366f7d634164a31910e2aef07e008c784af3725477610bb831a97c4620b862289c92c34
digest: SHA-256=222611bea82fb44ab45b9f598f0867adaec923c66d5f2b39eabc2d1b48f4f4ef

{"network":"main","currency":"BTC","requiredFeeRate":15.086,"outputs":[{"amount":502700,"address":"169s8UaMUtYwfPqnLsyJNbP7sZAfLYVaYQ"}],"time":"2019-03-01T11:32:22.871Z","expires":"2019-03-01T11:47:22.871Z","memo":"Payment request for BitPay invoice 9NS2N7jueaGGAc8qHSJbz7 for merchant Wikimedia Foundation","paymentUrl":"https://bitpay.com/i/9NS2N7jueaGGAc8qHSJbz7","paymentId":"9NS2N7jueaGGAc8qHSJbz7"}

and I try to validate signature with bitcore-lib, it says that signature is invalid

> bitcore.crypto.Signature.fromString("38ca09c742a325d9c38a87de621cd896a5fabb4d01942fc0126b58a8a366f7d634164a31910e2aef07e008c784af3725477610bb831a97c4620b862289c92c34")
Invalid Argument: Error: Header byte should be 0x30

Why is wrong signature ?

elbelga commented 5 years ago

Ok, I see what is wrong, signature is in COMPACT format not in DER format.