<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>ECDSA on truegav</title>
		<link>/tags/ecdsa/</link>
		<description>Recent content in ECDSA on truegav</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Wed, 10 Apr 2024 14:00:00 +0530</lastBuildDate>
		
			<atom:link href="/tags/ecdsa/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Every single signature you have ever verified has a twin</title>
				<link>/posts/every-signature-has-a-twin/</link>
				<pubDate>Wed, 10 Apr 2024 14:00:00 +0530</pubDate>
				<guid>/posts/every-signature-has-a-twin/</guid>
				<description>&lt;h2 id=&#34;the-sibling&#34;&gt;The sibling&lt;/h2&gt;&#xA;&lt;p&gt;Every ECDSA signature &lt;code&gt;(r, s, v)&lt;/code&gt; possesses an identical twin &lt;code&gt;(r, n - s, v XOR 1)&lt;/code&gt;. Same private key signed both. Same message was hashed. &lt;code&gt;ecrecover&lt;/code&gt; returns the identical address for both. Your protocol processes them as distinct authorizations because the raw bytes differ.&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-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;r&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;v&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;original_sig&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;n&#34;&gt;s2&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;%&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;SECP256K1_ORDER&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;n&#34;&gt;v2&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;v&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;^&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&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;c1&#34;&gt;# (r, s2, v2) recovers to the same address&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The secp256k1 curve is symmetric. For every valid point &lt;code&gt;(x, y)&lt;/code&gt; that exists on the curve, &lt;code&gt;(x, -y)&lt;/code&gt; also exists. The &lt;code&gt;s&lt;/code&gt; component of the signature encodes which y-coordinate was selected during the signing process. Flip &lt;code&gt;s&lt;/code&gt; modulo the curve order and flip the parity bit in &lt;code&gt;v&lt;/code&gt;. You have now manufactured a second, completely valid, cryptographically indistinguishable signature for the identical message from the identical key. You never touched the private key. You performed modular arithmetic that a motivated fourteen year old could execute.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
