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

Tool for generating sha256 initializiation with fixed midstate from BIP340 tagged hash #1653

Open
theStack opened this issue Feb 8, 2025 · 1 comment
Labels
meta/development processes, conventions, developer documentation, etc.

Comments

@theStack
Copy link
Contributor

theStack commented Feb 8, 2025

New secp256k1 modules often take use of BIP340 tagged hashes, with corresponding functions to initialize _sha256 objects with a fixed midstate for efficiency reasons. Right now there seems to be no standard way to create these functions, presumably every contributor does this in a slightly different way (I guess all ways involve cluttering the code with printf statements though). I was wondering if it's worth it to provide a small tool for that, which could also be useful for reviewing.

Proof-of-concept (not involving the build system yet): theStack@009cac6

@real-or-random real-or-random added the meta/development processes, conventions, developer documentation, etc. label Feb 24, 2025
@real-or-random
Copy link
Contributor

real-or-random commented Feb 24, 2025

Last time I needed this, I used this Python library: https://github.com/cloudtools/sha256. I believe that's a bit simpler than maintaining a C program (with build system integration, etc.)

Of course, we could also add a small Python snippet that prints a BIP340 midstate explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta/development processes, conventions, developer documentation, etc.
Projects
None yet
Development

No branches or pull requests

2 participants