<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF9160 DK Ethereum Ecdsa &amp;quot;s problem&amp;quot;</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91484/nrf9160-dk-ethereum-ecdsa-s-problem</link><description>Hello! We are trying to sign our data using ECDSA ( https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/crypto/ecdsa/README.html ) . We are comparing the results with signs of other projects and we see that our program computes the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 17 Sep 2022 00:09:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91484/nrf9160-dk-ethereum-ecdsa-s-problem" /><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/386723?ContentTypeID=1</link><pubDate>Sat, 17 Sep 2022 00:09:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0236adf3-a572-419c-a69d-d7b335c5ecf2</guid><dc:creator>Gioele</dc:creator><description>&lt;p&gt;We understood that the problem is related to the ECDSA provided by Nordic that doesn&amp;#39;t take in input Keccak256.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/385102?ContentTypeID=1</link><pubDate>Wed, 07 Sep 2022 16:44:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2abfe866-96b4-4fa0-9fc0-2f44296095ff</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt; I have made an internal inquiry on this topic.&amp;nbsp;&lt;br /&gt;Since you try to implement Ethereum ECDSA, use keccak256 with secp256k1, and since it is hash algorithm we do not currently provide, we cannot provide full support related to your question.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I would suggest that you engage more with Ethereum&amp;nbsp; crypto and developer communities.&lt;br /&gt;There is a list of&amp;nbsp;&lt;a href="https://keccak.team/software.html"&gt;software resources&lt;/a&gt; &amp;nbsp;implementing keccak.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/384528?ContentTypeID=1</link><pubDate>Mon, 05 Sep 2022 10:07:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fbad8a0-e7dc-40c6-a63f-68de1dad3965</guid><dc:creator>Gioele</dc:creator><description>&lt;p&gt;We are using deterministic ECDSA in both.&amp;nbsp;&lt;span&gt;F&lt;/span&gt;&lt;span&gt;or some values the ECDSA result is wrong related to the &amp;quot;s value&amp;quot;.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;We noticed that when we make the Keccak256 of a standard number or a text the &amp;quot;r and s values&amp;quot; are correct, but when we make the keccack256 of RLP only the &amp;quot;r value&amp;quot; is correct.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/384523?ContentTypeID=1</link><pubDate>Mon, 05 Sep 2022 09:28:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e61a135-cd97-4a37-b7d5-0fb7f1918df5</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Do you get the same signature every time you run your python script?&amp;nbsp;Do you use deterministic ECDSA in your python project?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/384369?ContentTypeID=1</link><pubDate>Thu, 01 Sep 2022 15:25:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4dd60184-1b2e-4cdb-ad26-cfc9fd4504e4</guid><dc:creator>Gioele</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint8_t keccak256[32] = {
0x99, 0x68, 0x3d, 0xfd, 0x16, 0xa3, 0x65, 0xb2,
0xf1, 0x45, 0x82, 0x59, 0xd7, 0xaf, 0x30, 0x6d,
0xb5, 0x74, 0xa3, 0x4b, 0xe7, 0xf8, 0x6d, 0x21,
0x02, 0xca, 0xb0, 0x47, 0xb0, 0xee, 0x4c, 0xf3
};

static uint8_t m_priv_key[32] = {
0x1d, 0x68, 0xd6, 0x4b, 0xa9, 0x19, 0x60, 0x41,
0x1e, 0x4b, 0xb8, 0x5d, 0xd7, 0xd4, 0x61, 0x02,
0x2f, 0x70, 0x6c, 0x6d, 0xbe, 0x67, 0x6b, 0xf1,
0x3b, 0xdb, 0xfc, 0x3f, 0x7e, 0x1c, 0x13, 0x38
};



status = psa_import_key(&amp;amp;key_attributes, m_priv_key, sizeof(m_priv_key), &amp;amp;keypair_handle);
if (status != PSA_SUCCESS) {
LOG_INF(&amp;quot;psa_import_private_key failed! (Error: %d)&amp;quot;, status);
return APP_ERROR;
}


status = psa_sign_hash(keypair_handle,
PSA_ALG_DETERMINISTIC_ECDSA(PSA_ALG_SHA_256),
keccak256,
sizeof(m_plain_text),
m_signature,
sizeof(m_signature),
&amp;amp;output_len);
if (status != PSA_SUCCESS) {
LOG_INF(&amp;quot;psa_sign_hash failed! (Error: %d)&amp;quot;, status);
return APP_ERROR;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is the code of the ECDSA example by Nordic and this gives us an incorrect &amp;quot;s value&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;signed_tx = web3.eth.account.signTransaction(tx, private_key)
tx = {
&amp;#39;nonce&amp;#39;: nonce,
&amp;#39;to&amp;#39;: to_acc,
&amp;#39;value&amp;#39;: web3.toWei(1, &amp;#39;ether&amp;#39;),
&amp;#39;gas&amp;#39;: 2000000,
&amp;#39;gasPrice&amp;#39;: web3.toWei(&amp;#39;50&amp;#39;, &amp;#39;gwei&amp;#39;)
}

private_key = &amp;#39;1d68d64ba91960411e4bb85dd7d461022f706c6dbe676bf13bdbfc3f7e1c1338&amp;#39;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is the code in python that give us the correct &amp;quot;s value&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/384316?ContentTypeID=1</link><pubDate>Thu, 01 Sep 2022 11:35:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ec3d231-0dff-4f8f-844b-ee4623dfcb0b</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Thank you for this information. &lt;br /&gt;&lt;br /&gt;I would appreciate it if you could answer following 2 questions.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user=""]We think that there is a mistake with the procedure to obtain the &amp;quot;s value&amp;quot;.[/quote]
&lt;p&gt;Could you provide more information about the procedure that you used in both cases?&lt;/p&gt;
[quote user="dejans"]&lt;blockquote&gt;&lt;div&gt;Gioele said:&lt;/div&gt;&lt;div&gt;This is the correct output that comes from another Python Project:&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;Gioele said:&lt;/div&gt;&lt;div&gt;This is the output that comes from the ECDSA provided by Nordic.&lt;/div&gt;&lt;/blockquote&gt;[/quote]
&lt;p&gt;Could you provide more information about the way in which you calculated the values you provided?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/384207?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 18:23:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b7c4feb-7d3c-4b91-84d4-e0ab9db59842</guid><dc:creator>Gioele</dc:creator><description>[quote userid="111786" url="~/f/nordic-q-a/91484/nrf9160-dk-ethereum-ecdsa-s-problem/384203"]What is our &amp;quot;s&amp;quot; that is wrong?&lt;br /&gt;[/quote]
&lt;p&gt;&lt;span style="background-color:#00ff00;"&gt;Correct&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;f86d0c850ba43b7400831e8480946fb6ba99b8a9f1330c1e83ec309c1dab81906e63880de0b6b3a7640000801ca0c4a47c3979ee3f169f2b1ad8b4754a0ea66297594af3b8d9e6f9a1dd01bd8152a0&lt;span style="background-color:#00ff00;"&gt;142e95021d0d979b1e49744421cbb0dbadcf48b3eba2b20957740f57a8e56d3b&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ff0000;color:#000000;"&gt;Wrong&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;f86d0c850ba43b7400831e8480946fb6ba99b8a9f1330c1e83ec309c1dab81906e63880de0b6b3a7640000801ca0c4a47c3979ee3f169f2b1ad8b4754a0ea66297594af3b8d9e6f9a1dd01bd8152a0&lt;span style="background-color:#ff0000;"&gt;ebd16afde2f26864e1b68bbbde344f230cdf9432c3a5ee32685e4f352750d406&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#00ff00;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The first output comes from the Python program (web3 library), and the second output comes from the Nordic ECDSA example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/384203?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 17:19:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:409ab39e-fdea-4522-be8d-9a307444350b</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Going back to my previous questions,&lt;/p&gt;
[quote user=""]We are comparing the results with signs of other projects and we see that our program computes&amp;nbsp;the same sign but we&amp;nbsp;ascertain that our &amp;quot;s&amp;quot; is wrong.[/quote]
&lt;p&gt;What is our &amp;quot;s&amp;quot; that is wrong?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user=""]The&amp;nbsp;ECDSA sample doesn&amp;#39;t provide the Keccak256 algorithm so we implemented it ourselves. We think that there is a mistake with the procedure to obtain the &amp;quot;s value&amp;quot;.[/quote]
&lt;p&gt;Where do you think is an error? What procedure do you refer to?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="Gioele"]This is the correct output that comes from another Python Project:[/quote]
&lt;p&gt;&lt;/p&gt;
[quote user="Gioele"]This is the output that comes from the ECDSA provided by Nordic.[/quote]
&lt;p&gt;Could you explain in detail how you got both of these outputs?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/384191?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 15:29:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d61e135-e42d-47ab-9a97-372831a05cdc</guid><dc:creator>Gioele</dc:creator><description>[quote userid="111786" url="~/f/nordic-q-a/91484/nrf9160-dk-ethereum-ecdsa-s-problem/384188"]Could you elaborate on this?&lt;br /&gt;[/quote]
&lt;p&gt;When we talk about ECDSA we find out two important values that are r and s. These 2 values are appended to other characters to form the final output.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is the correct output that comes from another Python Project:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;f86d0c850ba43b7400831e8480946fb6ba99b8a9f1330c1e83ec309c1dab81906e63880de0b6b3a7640000801ca0c4a47c3979ee3f169f2b1ad8b4754a0ea66297594af3b8d9e6f9a1dd01bd8152a0142e95021d0d979b1e49744421cbb0dbadcf48b3eba2b20957740f57a8e56d3b&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is the output that comes from the ECDSA provided by Nordic.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;f86d0c850ba43b7400831e8480946fb6ba99b8a9f1330c1e83ec309c1dab81906e63880de0b6b3a7640000801ca0c4a47c3979ee3f169f2b1ad8b4754a0ea66297594af3b8d9e6f9a1dd01bd8152a0ebd16afde2f26864e1b68bbbde344f230cdf9432c3a5ee32685e4f352750d406&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There is something that doesn&amp;#39;t work, in detail we can see that the problem is related to the &amp;quot;s value&amp;quot; that is different, and that is wrong.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 DK Ethereum Ecdsa "s problem"</title><link>https://devzone.nordicsemi.com/thread/384188?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 15:16:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d54c0f6-36cd-4d99-b053-90096fe9303c</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]We are comparing the results with signs of other projects and we see that our program computes&amp;nbsp;the same sign but we&amp;nbsp;ascertain that our &amp;quot;s&amp;quot; is wrong.[/quote]
&lt;p&gt;Could you elaborate on this?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user=""]We think that there is a mistake with the procedure to obtain the &amp;quot;s value&amp;quot;.[/quote]
&lt;p&gt;Could you elaborate on this as well?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>