Author

Topic: [PoC] SHA256/BLAKE3 hash multiple stack items without OP_CAT (Read 140 times)

copper member
Activity: 33
Merit: 152
As expected, the total bytes for this opcode is quite long, but it seems to be doable.

The interesting part is that you seemed to have also implemented an OP_XOR, OP_OR, OP_AND, OP_MUL, OP_SHIFT and a bunch of other opcodes in the process of making this work.

So do you think there is a case where you can also show that these other disabled opcodes could be enabled back?

Yep, here are polyfills for OP_XOR/OP_AND/OP_OR for 31 bit unsigned script numbers:

OP_XOR:
Code:
OP_0
OP_TOALTSTACK
OP_DUP
<1073741824>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1073741824>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<1073741824>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1073741824>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<1073741824>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<536870912>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<536870912>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<536870912>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<536870912>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<536870912>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<268435456>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<268435456>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<268435456>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<268435456>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<268435456>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<134217728>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<134217728>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<134217728>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<134217728>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<134217728>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<67108864>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<67108864>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<67108864>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<67108864>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<67108864>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<33554432>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<33554432>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<33554432>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<33554432>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<33554432>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<16777216>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<16777216>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<16777216>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<16777216>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<16777216>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<8388608>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<8388608>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<8388608>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<8388608>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<8388608>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<4194304>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<4194304>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<4194304>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<4194304>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<4194304>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<2097152>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<2097152>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<2097152>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<2097152>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<2097152>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<1048576>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1048576>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<1048576>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1048576>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<1048576>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<524288>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<524288>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<524288>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<524288>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<524288>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<262144>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<262144>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<262144>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<262144>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<262144>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<131072>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<131072>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<131072>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<131072>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<131072>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<65536>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<65536>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<65536>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<65536>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<65536>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<32768>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<32768>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<32768>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<32768>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<32768>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<16384>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<16384>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<16384>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<16384>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_NUMNOTEQUAL
OP_IF
<16384>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<8192>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<8192>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
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P_IF
OP_0
OP_ELSE
<536870912>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<536870912>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<536870912>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<536870912>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<268435456>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<268435456>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<268435456>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<268435456>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<268435456>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<134217728>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<134217728>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<134217728>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<134217728>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<134217728>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<67108864>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<67108864>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<67108864>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<67108864>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<67108864>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<33554432>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<33554432>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<33554432>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<33554432>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<33554432>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<16777216>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<16777216>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<16777216>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<16777216>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<16777216>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<8388608>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<8388608>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<8388608>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<8388608>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<8388608>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<4194304>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<4194304>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<4194304>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<4194304>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<4194304>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<2097152>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<2097152>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<2097152>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<2097152>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<2097152>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<1048576>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1048576>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<1048576>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1048576>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<1048576>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<524288>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<524288>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<524288>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<524288>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<524288>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<262144>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<262144>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<262144>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<262144>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<262144>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<131072>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<131072>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<131072>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<131072>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<131072>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<65536>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<65536>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<65536>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<65536>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLAND
OP_IF
<65536>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<32768>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<32768>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_D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DIF
OP_BOOLAND
OP_IF
OP_FROMALTSTACK
OP_1
OP_ADD
OP_ELSE
OP_FROMALTSTACK
OP_ENDIF

OP_OR:
Code:
OP_0
OP_TOALTSTACK
OP_DUP
<1073741824>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1073741824>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<1073741824>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1073741824>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<1073741824>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<536870912>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<536870912>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<536870912>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<536870912>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<536870912>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<268435456>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<268435456>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<268435456>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<268435456>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<268435456>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<134217728>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<134217728>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<134217728>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<134217728>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<134217728>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<67108864>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<67108864>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<67108864>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<67108864>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<67108864>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<33554432>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<33554432>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<33554432>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<33554432>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<33554432>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<16777216>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<16777216>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<16777216>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<16777216>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<16777216>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<8388608>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<8388608>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<8388608>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<8388608>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<8388608>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<4194304>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<4194304>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<4194304>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<4194304>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<4194304>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<2097152>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<2097152>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<2097152>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<2097152>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<2097152>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<1048576>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1048576>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<1048576>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<1048576>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<1048576>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<524288>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<524288>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<524288>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<524288>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<524288>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<262144>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<262144>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<262144>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<262144>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
<262144>
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
<131072>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<131072>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
<131072>
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
<131072>
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_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_ROT
OP_DUP
OP_4
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
OP_4
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
OP_4
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_DUP
OP_2
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
OP_2
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_DUP
OP_2
OP_LESSTHAN
OP_IF
OP_0
OP_ELSE
OP_2
OP_SUB
OP_1
OP_ENDIF
OP_ROT
OP_BOOLOR
OP_IF
OP_2
OP_FROMALTSTACK
OP_ADD
OP_TOALTSTACK
OP_ENDIF
OP_BOOLOR
OP_IF
OP_FROMALTSTACK
OP_1
OP_ADD
OP_ELSE
OP_FROMALTSTACK
OP_ENDIF

For OP_LSHIFT, you can left shift by 1 by multiplying by two:
Code:
OP_DUP
OP_ADD

So to left shift by 3, for example, you just do 3 left shifts by 1:
Code:
OP_DUP
OP_ADD

OP_DUP
OP_ADD

OP_DUP
OP_ADD

If your number is greater than or equal to 2^30, however, you need to first clear the topbit before doing the shift, which can be accomplished by the following:
Code:
// start clear top bit
<1073741824>
OP_2DUP
OP_GREATERTHANOREQUAL
OP_IF
OP_SUB // subtract 2^30
OP_ELSE
OP_DROP // ignore 2^30 and leave the number unmodified
OP_ENDIF
// end clear top bit

OP_DUP
OP_ADD
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
As expected, the total bytes for this opcode is quite long, but it seems to be doable.

The interesting part is that you seemed to have also implemented an OP_XOR, OP_OR, OP_AND, OP_MUL, OP_SHIFT and a bunch of other opcodes in the process of making this work.

So do you think there is a case where you can also show that these other disabled opcodes could be enabled back?
copper member
Activity: 33
Merit: 152
In support of the BIP to enable OP_CAT, we challenged ourselves to implement hashes that could use multiple computed stack items as a preimage without OP_CAT.

In the end, we implemented both SHA256 and BLAKE3:



You can view the source + test out both hashes here:
https://bitide.qedprotocol.com/?importProject=https%3A%2F%2Fbtcscripts.qed.run%2Fexamples%2Fhash_demo.json&openFile=scripts%2Fblake3_demo_1.js

See the video above for usage. For both scripts, the inputs are represented as U32s grouped as .
For example, if you want to compute the blake3 hash of the data 'c85b298792a5b8d0082c2ed839c3830bcd4a6f18b827f6ce5ecf8838b1917e6a78ac10ef3e97660 c3529ca929dbbb207f6cb9279c49a4df29f67201776962c7c', you first split it the input data into U32s and get the following items on the stack:
Code:
OP_1
<120150984>
OP_1
<1354278290>
OP_1
<1479420936>
OP_0
<193184569>
OP_0
<409946829>
OP_1
<1324754872>
OP_0
<948490078>
OP_0
<1786679729>
OP_1
<1863363704>
OP_0
<208049982>
OP_1
<315238709>
OP_0
<129153949>
OP_0
<2039663606>
OP_1
<1917688516>
OP_0
<387999647>
OP_0
<2083296886>

To do this automatically, just use:
Code:
var cfg = sch.getLimbsConfig([1, 31]); // define a U32 integer stack group which has two limbs:  
var testInputs = sch.hexToU32Array('c85b298792a5b8d0082c2ed839c3830bcd4a6f18b827f6ce5ecf8838b1917e6a78ac10ef3e97660c3529ca929dbbb207f6cb9279c49a4df29f67201776962c7c', false);
testInputs.forEach(x => {
  b.constants(cfg.splitParts(x));
});

b.OP_HASH_U32_BLAKE3_256(testInputs.length); // 16 = number of uint32s in preimage

The result of OP_HASH_U32_BLAKE3_256 is the following stack:
Code:
OP_1
<674114300>
OP_1
<1860412368>
OP_1
<642631595>
OP_0
<1768883315>
OP_0
<1529469502>
OP_1
<1658424509>
OP_0
<1384360961>
OP_0
<918971398>

Which is the U32 representation of fc2a2ea8d0a3e3eeabc74da673046f693eda295bbd8cd9e201ac83520664c636.

And in fact blake3("c85b298792a5b8d0082c2ed839c3830bcd4a6f18b827f6ce5ecf8838b1917e6a78ac10ef3e97660 c3529ca929dbbb207f6cb9279c49a4df29f67201776962c7c") = fc2a2ea8d0a3e3eeabc74da673046f693eda295bbd8cd9e201ac83520664c636!


The scripts are chonkers but do work on the latest version of Bitcoin Core (if you want to test it on a real node, docker pull the latest version of BitIDE and replace bitide.qedprotocol.com in the link above with localhost:1337).

If you like these kind of impossible ports, show some love by supporting the long over due proposals to re-enable useful features on Bitcoin and make these scripts obsolete!
Jump to: