c0mm4nd / dart-secp256k1

Fucking dart!!! Force me to write all deps!!!
https://pub.dev/packages/secp256k1
MIT License
12 stars 1 forks source link

Migration to pointycastle ? #5

Closed redDwarf03 closed 3 years ago

redDwarf03 commented 3 years ago

Hello thx for your work. Why don't you migrate your work to PointyCastle ? Actually I have different results between your work and PC

When I code with PC:

final secp256k1 = ECCurve_secp256k1();
final point = secp256k1.G;
final bigInt = BigInt.parse(hex.encode(pvBuf), radix: 16);
var curvePoint = point * bigInt;
Uint8List pubBuf = curvePoint!.getEncoded();

i have

Expected: '04350d90092eeaaba2607ee2d307ce4e2130b5d9d567e20764b742c7133b0e1ad9af1d1e5d4a2e831bde9cbecd14864f5dd3e08bdf6621f36600ff3beeb0fdda8d'
Actual: '03350d90092eeaaba2607ee2d307ce4e2130b5d9d567e20764b742c7133b0e1ad9'

-> the 2nd character is wrong and the length of result is not good

and when I code with your library

var pubBuf = secp256k1.PrivateKey.fromHex(uint8ListToHex(pvBuf)).publicKey;
pubBuf.toHex());

i have

Expected: '04350d90092eeaaba2607ee2d307ce4e2130b5d9d567e20764b742c7133b0e1ad9af1d1e5d4a2e831bde9cbecd14864f5dd3e08bdf6621f36600ff3beeb0fdda8d'
Actual: '04350d90092eeaaba2607ee2d307ce4e2130b5d9d567e20764b742c7133b0e1ad9af1d1e5d4a2e831bde9cbecd14864f5dd3e08bdf6621f36600ff3beeb0fdda8d'

-> the result is good

Do you know why I have difference and is it possible to add your experience in the PC project ?

Sorry if my issue is not an issue :)

c0mm4nd commented 3 years ago

-> the 2nd character is wrong and the length of result is not good

Just different convert method (from rawbytes to hex-encoded)

The rawbytes for 04xxxxx pubKey and 03xxxx pubKey are same.

When using this lib, you can get your publicKey in this format via publicKey.toCompressedHex() to get the shorter one.

Why don't you migrate your work to PointyCastle ?

  1. Personally speaking, I prefer small but customizable deps. Easy to use and easy to code.
  2. When I started writing dart libs, PC was v1.0.2

BTW, thanks for your contribution on implementing null safety

redDwarf03 commented 3 years ago

thank you for you feedback. you're right for small dev

just to know: could you dev a project for P256 Curve and Ed25519 Curve based on your SECP256K1 project ? :)

c0mm4nd commented 3 years ago

I have almost finished developing the dart's ECDSA lib like golang's last year but I cannot find the code now... I will implement it (because I need

redDwarf03 commented 3 years ago

great. do you know when ?

tejainece commented 3 years ago

@redDwarf03 PointyCastles's API is a mess with so much shitty patterns borrowed from its Java origins. Better to have a clean small package.

redDwarf03 commented 3 years ago

Agree