BTCMarkets / API

API
120 stars 30 forks source link

Having trouble replicating the authentication signature in the example GET request #127

Closed glasgotron closed 6 years ago

glasgotron commented 6 years ago

Hi, I'm just starting out playing around with the BTC markets api, and I've become stuck trying to replicate the signature generated in the example GET request given on the Authentication page.

I've successfully decoded the example private key into what's given on this page, i.e:

c1eaf07abc1eaebe65919ca1eecf098c93158796a17781e714147ba3e3834014a68fb0e14ca179f5f36c45599830c5479535bb11d321489c3095b38425a229aee4

but I'm having no luck with replicating the signature through SHA512, using various online signature generators, e.g. https://www.liavaag.org/English/SHA-Generator/HMAC/ https://www.online-convert.com/result/5c79af2d-693c-497c-bd59-6fdd055882d7 https://quickhash.com/hash-sha512-online

I am confused about two things:

1) Is the key to use in SHA512 exactly as above, or should I be using the decimal equivalen? I'm guessing that it depends on the implementation of the hmac algorithm. Is this correct?

2) What would be the exact format of the string that the key is being applied to. As far as I can tell, it should be used as a string literal, so would actually consist of either:

/account/balance 1519429556662

with a newline character following the timestamp, or else:

/account/balance\n1519429556662\n

But neither of these seem to work with either representations of the decoded key. I've even tried copying exactly:

'/account/balance' + '\n' + '1519429556662' + '\n'

but this also doesn't seem to work.

Could somebody please provide exactly what you would need to use for both the string and the key in order to generate the signature in the example? i.e. (sPGaVm2a0TLmqzyNDMYnHPkXAiyu2Dhn/WL3XlTowTSlwpykSApubBR795HLzUljJk6KFvAxhVVplzrIvFuChA==)

Thanks very much, sorry for the noob question.

justin-ngin commented 6 years ago

Hi @glasgotron ,

What language are you using to interact with the API?

Thanks, Justin

glasgotron commented 6 years ago

Hi Justin,

I'm using Visual C++, but haven't actually gotten to the point of using it to interact with BTC Markets at this point. I'm still playing around with my encoding/decoding from base 64 and the SHA512 algorithm and trying to confirm that they work correctly.

But I'm not sure of the precise input I need to give it to test this, so I'm trying to use online signature generators such as the ones mentioned in my original comment to help me figure it out, but after trying all the combinations of differing key and string representations I can think of, I haven't been able to generate the signature that is generated in the example.

Is the exact input necessary dependent on the implementation of SHA512, or have I just been giving incorrect input?

Thanks, Ben.

On Sun, Mar 11, 2018 at 6:08 PM, Justin notifications@github.com wrote:

Hi @glasgotron https://github.com/glasgotron ,

What language are you using to interact with the API?

Thanks, Justin

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BTCMarkets/API/issues/127#issuecomment-372094522, or mute the thread https://github.com/notifications/unsubscribe-auth/AjiKIlkg89rXErHe9bDHpxdfCvqfT5Waks5tdM1fgaJpZM4SllQB .