Signing a BWS Request from Python

(Eric Newhuis) #1


Hats off to such a great project. Amazing software.

I am trying to call BWS from Python and although I’ve managed to reconstruct the basics of the x-signature in my request header I haven’t been able to weed out bugs I have from all the minor differences in the layers of hashing and ECDSA signing and various decisions that went into the Node.js code versus similar code in Python.

Can anyone recommend a Python BWS client library or, alternatively, is there a detailed spec on how to properly sign a web request? I’d like to avoid having to write a middle layer, however, I am also open to alternative ways of calling the API from Python. As a side-note I am using asyncio and a very event-driven architectural style in my Python client.

Best Regards,
Eric Newhuis

P.S. Here are some hints from my logs.

copayerId = e3f542f7725141856922bba2d11c611624e897889c2599cb4b1706d2c7bb6ce6
msg = post|http://localhost:3232/bws/api/v2/addresses/?r=10930|
privKey = 29e28b9e8fcb3e47d3625cd60237d79250e3479f8df7ce034db7467927103a23
hash = b'00aea9cc1f7ff4b8296cd13a2c4f468a6f3b202ae6e77db61862d76c38e05d89'
sig = df5df2db6b11fd4dd4b1bd4219e08e696a4f5cde77b3a6368e7f130a080f17e7ecb2f94b4b1f0650545f88c0728e7e1ff0e501667bfda8b64dabef6f59f6f238
response = {"code":"NOT_AUTHORIZED","message":"Invalid signature"}```

ECDSA curve  = SECP256k1