Author: ZmnSCPxj 2019-10-06 08:46:59
Published on: 2019-10-06T08:46:59+00:00
In a discussion on the Lightning-dev mailing list, Jeremy had raised a point about constructing midstate using scriptPubKey with SHA256STREAM. However, ZmnSCPxj argued that there is no real advantage of using SHA256STREAM over OP_CAT as both are limited by the size of the script. Additionally, theoretically, `OP_CAT` is less efficient than `OP_SHASTREAM`. This is because `OP_CAT` may lead to possible O( n^2 ) behavior if new backing memory must be allocated elsewhere and the existing data copied. Meanwhile, `OP_SHASTREAM` would not require any copying or new allocations once the stream state is in place. However, it was noted that a sufficiently-limited maximum `OP_CAT` output would be helpful in reducing the worst-case `OP_CAT` behavior but 64 bytes feels too small, especially for Merkle tree proofs.
Updated on: 2023-06-13T21:41:32.712810+00:00