Bitcoin Forum
May 09, 2024, 01:36:56 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: SHA-256 implementation in Bitcoin script under 400K vbytes  (Read 52 times)
Sergio_Demian_Lerner (OP)
Hero Member
*****
expert
Offline Offline

Activity: 552
Merit: 629


View Profile WWW
April 27, 2024, 03:00:14 AM
Merited by hugeblack (6), ABCbits (1), garlonicon (1)
 #1

Martin Jonas (BitVMX team) created a SHA-256 code in Bitcoin script that hashes 64 bytes, and the code fits into a standard taproot script.  

The limiting factor is the maximum script stack (1000 elements). With a larger stack, it could probably be shrank to ~100 Kb.

This was a contribution to the BitVM2 implementation in Rust.

https://github.com/BitVM/BitVM/pull/65

It's interesting the use of nibbles (4-bit words) instead of 32-bit words to operate. That's perfect for tables involving two 4-bit operands (AND, OR, XOR, SHIFT, etc.).

Why create a SHA-256 implementation in script if there is a OP_SHA256 opcode?

Because Bitcoin script cannot expand the OP_SHA256 output value (32 bytes) into individual bytes in the stack. Therefore, OP_SHA256 cannot be used to check properties of the input and output inside the script. This prevents the use of OP_SHA256 to verify Lamport/Winternitz signatures.

(Note: Martin works @ https://fairgate.io and he is a contributor to the https://BitVMX.org project)
1715218616
Hero Member
*
Offline Offline

Posts: 1715218616

View Profile Personal Message (Offline)

Ignore
1715218616
Reply with quote  #2

1715218616
Report to moderator
1715218616
Hero Member
*
Offline Offline

Posts: 1715218616

View Profile Personal Message (Offline)

Ignore
1715218616
Reply with quote  #2

1715218616
Report to moderator
In order to achieve higher forum ranks, you need both activity points and merit points.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715218616
Hero Member
*
Offline Offline

Posts: 1715218616

View Profile Personal Message (Offline)

Ignore
1715218616
Reply with quote  #2

1715218616
Report to moderator
garlonicon
Hero Member
*****
Offline Offline

Activity: 803
Merit: 1932


View Profile
April 27, 2024, 06:20:15 AM
 #2

Quote
Because Bitcoin script cannot expand the OP_SHA256 output value (32 bytes) into individual bytes in the stack.
I think people should support OP_CAT soft-fork, because that single opcode can solve a lot of issues there.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!