<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>EIP-712 on truegav</title>
		<link>/tags/eip-712/</link>
		<description>Recent content in EIP-712 on truegav</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Wed, 18 May 2022 14:00:00 +0530</lastBuildDate>
		
			<atom:link href="/tags/eip-712/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>OpenZeppelin fixed this five years ago and your code still has it, why</title>
				<link>/posts/openzeppelin-fixed-this-five-years-ago/</link>
				<pubDate>Wed, 18 May 2022 14:00:00 +0530</pubDate>
				<guid>/posts/openzeppelin-fixed-this-five-years-ago/</guid>
				<description>&lt;h2 id=&#34;two-functions&#34;&gt;Two functions&lt;/h2&gt;&#xA;&lt;p&gt;Solidity provides two encoding functions for preparing data before hashing. &lt;code&gt;abi.encode&lt;/code&gt; pads every argument to a full 32 bytes with zero-fill. &lt;code&gt;abi.encodePacked&lt;/code&gt; concatenates raw bytes with nothing separating adjacent arguments.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-solidity&#34; data-lang=&#34;solidity&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;abi&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;encodePacked&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;address&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mh&#34;&gt;0xdead&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;),&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;uint256&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mh&#34;&gt;0xbeef&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;abi&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;encodePacked&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;address&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mh&#34;&gt;0xdead000000000000000000000000000000000000&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;),&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;uint16&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mh&#34;&gt;0xbeef&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These two calls produce identical byte output. An address with trailing zero bytes next to a small uint packs into the exact same bytestring as a different address next to a large uint. Hash this output and use it as a signature commitment. An attacker can forge equivalent messages by shifting the type boundary between the arguments because the padding that differentiates them does not exist.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
