Subject: Re: [bitcoindev] OP_CAT Enables Winternitz Signatures

From: Anthony Towns <[email-masked]>
Date: Sat, 5 Jul 2025 22:18:54 +1000

On Sun, Jun 08, 2025 at 03:20:08AM +0000, 'conduition' via Bitcoin Development Mailing List wrote:
> See a prototype implementation in pseudo-script on
> github here.
> 
> https://gist.github.com/conduition/c6fd78e90c21f669fad7e3b5fe113182

I think you can do the four-bit pair to eight-bit conversion slightly
better with:

DUP 8 GREATERTHANOREQUAL  # is the high-bit going to be set?
SWAP ROT SWAP  # drop that flag lower in the stack
DUP ADD DUP ADD DUP ADD DUP ADD ADD  # combine them mathematically
SWAP IF  # was the flag set?
  128 SWAP SUB  # subtract from 128 converts 0x8100-0xff00 to 0x81-0xff
  IFDUP NOT IF "0x80" ENDIF  # special case 0x80 "negative zero"
ELSE
  IFDUP NOT IF "0x00" ENDIF  # special case actual 0
ENDIF

Should save about 640 bytes of script (11%, 8% total), I think.

> PS If anyone would like to test this on signet, I'd
> be more than happy to help. I couldn't get my OP_CAT
> transactions mined for some reason so i stuck to regtest.

inquisition.bitcoin-signet.net was down for a few days when you posted
this, due to running out of disk space, which probably would have made
getting txs relayed pretty hard. You'd probably have more luck now.

Cheers,
aj

-- 
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email-masked].
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/aGkYLuZZz2itqVJx%40erisian.com.au.