So, Martin from FairgateLabs has managed to create a BLAKE3 implementation in Bitcoin script. This is the smallest hash function ever put into script, coming in at just 45K bytes or 11.2K vbytes in a Taproot script.
You might wonder why we need a new hash function since OP_HASH and OP_HASH256 are already available. The thing is, Bitcoin script doesn’t let us manipulate individual bytes of the hash digests produced by those opcodes. This limitation means we can’t create Lamport or Winternitz signatures with what we have now. Having signatures for any kind of message is super important for systems like BitVMX.org. The shorter the code, the less it costs for on-chain disputes.
(BitVMX is an optimistic proving system for any programs based on a virtual CPU, and it doesn’t need any hard or soft forks for Bitcoin.)
Here are some stats:
This new implementation is compared to the previous version in BitVM. Check out the improvements:
Bytes Hashed Number of blocks Original Size New Implementation Size Improvement from original
64 1 103k 45k 55.60%
80 2 206k 91k 55.72%
Now, let’s look at the max stack height usage:
Bytes Blocks Original New New stack-optimized Size
64 1 384 671 550 47K
80 2 448 779 678 95K
You can check the PR out here: https://github.com/BitVM/BitVM/pull/67
If you wanna know more about BitVMX, feel free to read its paper: https://bitvmx.org/files/bitvmx-whitepaper.pdf. Also, you can drop comments in this thread here.
Implementing BLAKE3 in Bitcoin Script with just 12K vbytes
1 reply 350 views
Again, as I wrote before, sounds like yet another reason to enable OP_CAT. And I wonder, if redirecting some efforts put into writing cat-less scripts, into activating OP_CAT instead, would make life easier.
Because that OP_CAT BIP needs more examples and use cases. Which means, that filling this gap could push things forward.
?Reply
Sign in to reply to this topic
Related topics
- Bitcoin Core displaying coins (UTXOs) in a new tab 13
- Are you in favor of BIP-110? Let's get a Bitcoin poll going. 0
- Erlay seems to have some issues here’s a better proposal for a bitcoin protocol without invites 3
- Ways to earn some sats by contributing to bitcoin core development 5
- Exploring the Potential and Challenges of a Kardashev-Scale Bitcoin Network 3
- What can I do to fix this Bitcoin Core error? 8