Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong v value on ethereum signature #6

Closed
fonstack opened this issue Sep 4, 2024 · 8 comments
Closed

Wrong v value on ethereum signature #6

fonstack opened this issue Sep 4, 2024 · 8 comments

Comments

@fonstack
Copy link

fonstack commented Sep 4, 2024

Hey @c0mm4nd

I've using your library and I just realized there is something wrong with the calculation of v.

In one signature it should return v = 0 but instead is returning v = 1. This is basically changing the end of the signature from ...1b to ...1c. Any idea why is this happening?

@c0mm4nd
Copy link
Owner

c0mm4nd commented Sep 4, 2024

The eth sign test passed as shown in commit 8b87d9f
Is there any newer standard for Ethereum signature?

If possible, could you show me your data, including the content hash, privKey, and the expected signature helping me debug?

@fonstack
Copy link
Author

fonstack commented Sep 4, 2024

I'm testing with this params:

  • private key -> e4d7f99de955728c9921a3de9f2bcdaeb54938da0b1179fdd2275d7ce09dd002

  • hash hex to be signed -> b6e16d27ac5ab427a7f68900ac5559ce272dc6c37c82b3e052246c82244c50e4 ("Hello, world!")

  • expected signature -> 0x96df6608b777f7642e741b97843475ab29981bca31c2f47d657b43ff7b460d2148def6cd02fb866ac45f736dcc6829f1ca34c1f112805eae0c73981aecee94281b with v = 0 (the last 1b)

but I'm getting ->
0x96df6608b777f7642e741b97843475ab29981bca31c2f47d657b43ff7b460d2148def6cd02fb866ac45f736dcc6829f1ca34c1f112805eae0c73981aecee942801

If I use getV() I'm getting 28 => 1c
and the expected is getV() = 27 => 1b

@fonstack
Copy link
Author

fonstack commented Sep 4, 2024

You can also take a look at this playground using another library and it's indeed returning the signature with ...1b

https://zapp.run/edit/dart-zow060qox06?entry=lib/main.dart&file=lib/main.dart

@c0mm4nd
Copy link
Owner

c0mm4nd commented Sep 4, 2024

@fonstack
Copy link
Author

fonstack commented Sep 4, 2024

I can also provide you this JS (using viem) playground with the exact same result @c0mm4nd

https://stackblitz.com/edit/node-js-playground-qsoa9p?file=index.js

Please let me know if you need furthers assistance. This package is pretty important to us and we need this to continue our development!

josher8a added a commit to josher8a/dart-ecdsa that referenced this issue Sep 4, 2024
@fonstack
Copy link
Author

fonstack commented Sep 4, 2024

Hey @c0mm4nd please take a look at teammate’s @josher8a PR. He is solving the issue based on this https://ethereum.stackexchange.com/a/53182

@c0mm4nd
Copy link
Owner

c0mm4nd commented Sep 5, 2024

Thank you and your great team. I have already merged the PR and published a new version on pub.dev https://pub.dev/packages/ecdsa/versions/0.1.1

@fonstack
Copy link
Author

I'll close this since it's already solved, thanks sir @c0mm4nd

cc: kudos to @josher8a :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants