algotrader-com / starkex

2 stars 2 forks source link

Some payloads are not signed correctly #2

Closed claraccio closed 2 years ago

claraccio commented 3 years ago

For some payloads, the signature does not match the js/python libs. I think it may have something to do with the _truncateToN that is not implemented in Java but is in JS. See https://github.com/dydxprotocol/starkex-lib/blob/f19a56056e8af31c9732f4dca926eb2cfd1c5521/src/lib/starkware/crypto-js.ts#L143 And https://github.com/ethers-io/ethers.js/blob/b1458989761c11bf626591706aa4ce98dae2d6a9/packages/signing-key/lib.esm/elliptic.js#L2339

claraccio commented 3 years ago

Some test data

expected signature: 0121b9b648ee938ca403bb865ab26aa442edb9b7f2c40edf7f86aae0b9686429014cf84c77fe3701ea4516a9e77c31890a69ec72f1af0c64cada7cbf14313c58 actual signature: 02b5f8fc63a2e09b4a275641c1647d42860c1e6dd7004245308d7fa95b3dffdd01e7b64919a8f3e7d57554193ce23989780e0de5db072c57ed2ddb3c555d39e0

Using a OrderWithClientIdWithPrice

"market" -> "ZEC-USD"
"limitFee" -> "0.0015"
"side" -> "SELL"
"clientId" -> "WyHPW57ZKGwcie18UbEBGcry2QervYgYSG1Fm6YG"
"positionId" -> "123456"
"size" -> "1.00"
"price" -> "200.0"
"expiration" -> "2021-11-03T16:22:23Z"
"starkPrivateKey" -> "0x515282606d04ca75bfda0b2f3f92f9ad591f0153ff79ccac99f0a61016a4c5"

on NetworkId.MAINNET