Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[signature header] Fix array of possible header bytes #1

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

Merged
shadowy-pycoder merged 1 commit into shadowy-pycoder:master from satsie:fix-header-bytes
May 3, 2023

Conversation

@satsie
Copy link
Contributor

@satsie satsie commented May 3, 2023

Hi! Thank you for making such a fantastic tool. It's really helped me understand how message signing works.

This PR fixes the array of possible bytes that the signature header can be. Some of the hex values were missing and some were (mistakenly?) repeated. I've also added comments for the ranges that each set of bytes correspond to, however I didn't know what the 43 - 46 range was.

Copy link
Owner

First of all, thank you for your time reviewing the source code. I am very glad that it helped you to better understand how bitcoin works, I also learned a lot of things working on it. As for repeating headers, it was clearly a mistake because I used as a reference the same wiki page you linked, and the following lines caused a confusion:

Compute the header byte. If r < p-n and is_even(y), set HeaderByte to 34. If r < p-n and >is_odd(y), set HeaderByte to 31. If r ≥ p-n and is_even(y), set HeaderByte to 32. If r ≥ p-n >and is_odd(y), set HeaderByte to 31.

As you can see, "31" is repeated twice, which doesn't make sense. The order of headers is not that important in the current implementation (it was in the previous one when I tried to calculate headers in the "sign" function instead of "verify" function), but also should be corrected for consistency. So, I approve your pull request.

satsie reacted with heart emoji

@shadowy-pycoder shadowy-pycoder merged commit 2951545 into shadowy-pycoder:master May 3, 2023
Copy link
Contributor Author

satsie commented May 4, 2023

Thanks for taking a look and merging! That bit about the header byte in the bitcoin wiki is very confusing to me 😅 Admittedly, I've been using this table from Bitcoin Stack Exchange more: https://bitcoin.stackexchange.com/a/111691/85287 Sharing in case it helps 😸

Screenshot from 2023年05月04日 11-03-50

Side thought - do you know what the 43-46 range is?

@satsie satsie deleted the fix-header-bytes branch May 4, 2023 15:05
Copy link
Owner

shadowy-pycoder commented May 4, 2023
edited
Loading

Side thought - do you know what the 43-46 range is?

This header range is reserved for Taproot addresses.

satsie reacted with heart emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /