Loopring / hello_loopring

hello_loopring
38 stars 33 forks source link

How to generate the 192 bits `X-API-SIG` header (/api/v3/apiKey) #20

Open 26medias opened 2 years ago

26medias commented 2 years ago

Hi,

I have exported my account data, I can run the basic keygen example (using python poseidon_hash_sample.py -a sign -i 1,2,3 -k 0x1), however I'm confused as to what data from my account settings (Public X, public Y, Private EDDSA) to pass to the keygen and in which format.

The doc seems to be missing that part.

My goal is to obtain my API key via /api/v3/apiKey, so I can then connect to the websockets (https://docs.loopring.io/en/websocket/overview.html)

Thanks!

yueawang commented 2 years ago

We have the api call here https://github.com/Loopring/hello_loopring/blob/0f86004f3695eb5296cad51a086bd360ed4cb1b7/sdk/loopring_v3_client.py#L407. You can flow the whole process to make your code work. Generally speaking, It is to sign the hash string of the whole request. The pseudo code is like

x_api_sig = eddsa_sign(poseidon_hash(sha256(url_request_string)))