<oembed><type>rich</type><version>1.0</version><author_name>npub1m230cem2yh3mtdzkg32qhj73uytgkyg5ylxsu083n3tpjnajxx4qqa2np2</author_name><author_url>https://nostr.ae/npub1m230cem2yh3mtdzkg32qhj73uytgkyg5ylxsu083n3tpjnajxx4qqa2np2</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2019-10-04&#xA;📝 Original message:On Thu, Oct 03, 2019 at 10:02:14PM -0700, Jeremy via bitcoin-dev wrote:&#xA;&gt; Awhile back, Ethan and I discussed having, rather than OP_CAT, an&#xA;&gt; OP_SHA256STREAM that uses the streaming properties of a SHA256 hash&#xA;&gt; function to allow concatenation of an unlimited amount of data, provided&#xA;&gt; the only use is to hash it.&#xA;&gt; &#xA;&gt; You can then use it perhaps as follows:&#xA;&gt; &#xA;&gt; // start a new hash with item&#xA;&gt; OP_SHA256STREAM  (-1) -&gt; [state]&#xA;&gt; // Add item to the hash in state&#xA;&gt; OP_SHA256STREAM n [item] [state] -&gt; [state]&#xA;&gt; // Finalize&#xA;&gt; OP_SHA256STREAM (-2) [state] -&gt; [Hash]&#xA;&gt; &#xA;&gt; &lt;-1&gt; OP_SHA256STREAM &lt;tag&gt; &lt;subnode 2&gt; &lt;subnode 3&gt; &lt;3&gt; OP_SHA256STREAM &lt;-2&gt;&#xA;&gt; OP_SHA256STREAM&#xA;&#xA;One issue with this is the simplest implementation where the state is just raw&#xA;bytes would expose raw SHA256 midstates, allowing people to use them directly;&#xA;preventing that would require adding types to the stack. Specifically I could&#xA;write a script that rather than initializing the state correctly from the&#xA;official IV, instead takes an untrusted state as input.&#xA;&#xA;SHA256 isn&#39;t designed to be used in situations where adversaries control the&#xA;initialization vector. I personally don&#39;t know one way or the other if anyone&#xA;has analyzed this in detail, but I&#39;d be surprised if that&#39;s secure. I&#xA;considered adding midstate support to OpenTimestamps but decided against it for&#xA;exactly that reason.&#xA;&#xA;I don&#39;t have the link handy but there&#39;s even an example of an experienced&#xA;cryptographer on this very list (bitcoin-dev) proposing a design that falls&#xA;victim to this attack. It&#39;s a subtle issue and we probably don&#39;t want to&#xA;encourage it.&#xA;&#xA;-- &#xA;https://petertodd.org &#39;peter&#39;[:-1]@petertodd.org&#xA;-------------- next part --------------&#xA;A non-text attachment was scrubbed...&#xA;Name: signature.asc&#xA;Type: application/pgp-signature&#xA;Size: 833 bytes&#xA;Desc: not available&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20191004/9c383745/attachment.sig&gt;</html></oembed>