Loopring / hello_loopring

hello_loopring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong ECDSA generated for TestNet (uat2) but right one generated for prod (api3)

taranasus opened this issue · comments

Hi, I've been using this example to create a LoopringAPI C# wrapper so that us non-python folk can have some of that Loopring fun. Link here https://github.com/taranasus/LoopringAPI

headers.update({'X-API-SIG': "0x" + bytes.hex(v_r_s_to_signature(v, r, s)) + EthSignType.EIP_712})

I've been using this python repo as the basis and test example. Here's the thing. The code works for production just fine, but for uat2 it generates the wrong ECDSA signature. It happens for both the python code linked above and the C# method i've made linked here: https://github.com/taranasus/LoopringAPI/blob/2bf91fb432907ec68662fb31e4dfbe4e1fe45c6d/LoopringAPI/SecureClient.cs#L539

It's been driving me nuts to try and come to this conclusion, as you'd expect the example code in python to work and I was running under the assumption that I was being dumb. but no.

Can you please have a look at this python example and see why it won't work with uat2, so we all know what went wrong.

It was the domain channel id. Had it hardcoded to 1 when it should have been pulled from the API, sorry about that

@taranasus can you elaborate on where the domain channel id is hardcoded to 1? Are you referring to the chainId? We were running into a similar issue yesterday.

Sorry @saschlac I should have been clearer, I did indeed mean the chain ID. On this line you can see it is set:

chainId=export_account['chainId'],

With the value from here:

"chainId": 5, # UAT in goerli, chainID is 5

And you can see it's set to 5 for the goerli network (uat2 and uat3), but it should be 1 for the real network (api3). I had hardcoded it to 1 in my code and because I'm a noob at this, didn't realize its significance / importance at the time.

I'll be closing this now as my own stupidity a bug in python does not make.