Implementing BLAKE3 in Bitcoin Script with just 12K vbytes

1 reply 350 views
chad_2018Member
Posts: 6 · Reputation: 70
#1Dec 18, 2024, 04:30 AM
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.
5 Reply Quote Share
sage777Full Member
Posts: 102 · Reputation: 305
#2Dec 19, 2024, 04:00 PM
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.
3 Reply Quote Share
?Reply
Sign in to reply to this topic

Related topics