leonardocustodio / polkadart

Polkadart provides developers the ability to query a node and interact with the Polkadot based chains using Dart.
https://polkadart.dev
Apache License 2.0
39 stars 16 forks source link

After using the private key to sign the data, the array length in R is 32, and the first element appears 0. How should I solve this problem? #422

Closed querli closed 9 months ago

querli commented 9 months ago
image
leonardocustodio commented 9 months ago

@justkawal

justkawal commented 9 months ago

Looking into it.

@justkawal

justkawal commented 9 months ago

Can you share your intToBytes function ?

justkawal commented 9 months ago

On my side I used the internal Utilities class methods to convert the BigInt to Bytes.

Screenshot 2024-02-21 at 14 58 49
justkawal commented 9 months ago

@querli I haven't done the Hash.hashSHA256 on line 6 because sign function already does that internally on calling sign method:

https://github.com/leonardocustodio/polkadart/blob/592ec4344e94e3bdcb7de6616d1212ff3b812c7c/packages/secp256k1_ecdsa/lib/src/private_key.dart#L56

querli commented 9 months ago

Thank you very much for your answer? Is now positioning is intToBytes function problem, use the library is web3dart 2.7.2, link is https://pub.dev/packages/web3dart, due to the cognition is not deep, specific don't know what is the difference between transformation!

leonardocustodio commented 9 months ago

Hey @querli, not sure I understood your comment. You mean you were using another lib to make the convertion? But did your problem get solved now?

querli commented 9 months ago

Yes, I used the web3Dart library. Since secp256K1 cannot be used, I relied on your secp256k1_ecdsa separately. Now I use secp256k1_ecdsa to convert the data format

querli commented 9 months ago

hmacSha256

Is this optional parameter hmacSha256 also a sha256 hash function? What if you use it?

querli commented 9 months ago

May I ask whether recovery in Signature can control the automatic addition of 27? Make recovery 27 or 28. At present, I process this data manually.

image