<?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>ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17650/ecc-wrong-public-key-is-generated</link><description>Hi,
I want to produce a shared secret key between a Smartphone and a NRF52 in order to encrypt data later with AES-128 (example of key sharing: here ). 
 To do that i need to implement a ECDH (Elliptic Curve Diffie Hellman) in application level (not</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Feb 2017 09:47:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17650/ecc-wrong-public-key-is-generated" /><item><title>RE: ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/thread/67875?ContentTypeID=1</link><pubDate>Fri, 24 Feb 2017 09:47:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:699e7b37-d831-45ae-8529-014b75d12896</guid><dc:creator>Maxim</dc:creator><description>&lt;p&gt;Hi, i&amp;#39;m agree with you, even the type uint64_t is limited to 18446744073709551615. The easiest way is to calculate this is to use only hexadecimal but if you really want to use decimal you must divide the Hexadecimal result in 8 bytes parts (uint64_t) and print them apart. I&amp;#39;ve implemented this solution with hexadecimal in my projet and it works really well ! In addition you can check your result with an hexa to decimal converter like this &lt;a href="https://www.mathsisfun.com/binary-decimal-hexadecimal-converter.html"&gt;link text&lt;/a&gt; and comparte the key generated from the ECDH website you given.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/thread/67874?ContentTypeID=1</link><pubDate>Fri, 24 Feb 2017 01:16:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8130f343-69d5-47bc-8b51-35e7c93b6ba7</guid><dc:creator>Shiroyama</dc:creator><description>&lt;p&gt;Hello, i face the same problem to calculate to public key. I use the &lt;a href="http://www-cs-students.stanford.edu/%7Etjw/jsbn/ecdh.html"&gt;website&lt;/a&gt; you given to calculate the key, but the input and output should be displayed in decimalism. How can i switch my key from hexadecimal to decimalism? The number is so large that my calculator not working. Could you tell me the method to calculate it?Thank you !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/thread/67873?ContentTypeID=1</link><pubDate>Mon, 14 Nov 2016 14:28:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54229261-bc26-42dd-bb16-bca6b22021e5</guid><dc:creator>Maxim</dc:creator><description>&lt;p&gt;Yeah, it Works  but it&amp;#39;s a bit difficult !!!
But i&amp;#39;ve found an easier version, i&amp;#39;ve reverse the private key AND the public key to obtain the same result from this &lt;a href="http://www-cs-students.stanford.edu/%7Etjw/jsbn/ecdh.html"&gt;site&lt;/a&gt; but we must compute key shared key with no inversion on the public and private key.
I&amp;#39;ve use this function :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void reverse(uint8_t* p_arr, uint32_t len) // inverse Big-Endian
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{
uint32_t i;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for (i = 0; i &amp;lt; len/2 ; i++)
{
    uint8_t tmp = p_arr[i];
    p_arr[i] = p_arr[len - i - 1];
    p_arr[len - i - 1] = tmp;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;thanks you very much !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/thread/67871?ContentTypeID=1</link><pubDate>Mon, 14 Nov 2016 13:50:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f27f9b5c-eac6-4551-a716-bd15e2534138</guid><dc:creator>syntroniks</dc:creator><description>&lt;p&gt;Hey Maxim, check out page 16 and reverse the byte order&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/thread/67870?ContentTypeID=1</link><pubDate>Mon, 14 Nov 2016 09:07:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c07ec0fa-5e11-4181-9d34-3109616a9bd1</guid><dc:creator>Maxim</dc:creator><description>&lt;p&gt;I think the problem came from the definition of the function, in the file curve-specific.inc (in micro-ecc) the curve secp255r1 is defined by:&lt;/p&gt;
&lt;p&gt;P= FF, FF, FF, FF, FF, FF, FF, FF FF, FF, FF, FF, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00, FF, FF, FF, FF
B= 51, 25, 63, FC, C2, CA, B9, F3 84, 9E, 17, A7, AD, FA, E6, BC, FF, FF, FF, FF, FF, FF, FF, FF, 00, 00, 00, 00, FF, FF, FF, FF
G=  96, C2, 98, D8, 45, 39, A1, F4, A0, 33, EB, 2D, 81, 7D, 03, 77 ,F2, 40, A4, 63, E5, E6, BC, F8, 47, 42, 2C, E1, F2, D1, 17, 6B
F5, 51, BF, 37, 68, 40, B6, CB, CE, 5E, 31, 6B, 57, 33, CE, 2B,16, 9E, 0F, 7C, 4A, EB, E7, 8E, 9B, 7F, 1A, FE, E2, 42, E3, 4F
N= 4B, 60, D2, 27, 3E, 3C, CE, 3B, F6, B0, 53, CC, B0, 06, 1D, 65, BC, 86, 98, 76, 55, BD, EB, B3, E7, 93, 3A, AA, D8, 35, C6, 5A&lt;/p&gt;
&lt;p&gt;But these parameters are different from the curve that i&amp;#39;ve implemeted in android defined &lt;a href="http://www.secg.org/SEC2-Ver-1.0.pdf"&gt;here&lt;/a&gt; Page15&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/thread/67872?ContentTypeID=1</link><pubDate>Mon, 14 Nov 2016 08:10:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f068542c-6d24-43bf-9555-2b39628881d5</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;A public key will not be a random number, it will be generated based on the private key, using a function that  &amp;quot;doesn&amp;#39;t have&amp;quot; an inverse function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/thread/67869?ContentTypeID=1</link><pubDate>Fri, 11 Nov 2016 14:40:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7019eb12-f45f-4b63-84c0-12d2806fa2e3</guid><dc:creator>Maxim</dc:creator><description>&lt;p&gt;I&amp;#39;ve already try this method, when I reverse the private key the result is different of what I&amp;#39;m expecting.
But I&amp;#39;m now sure that the calculation are correct in the uECC because if i&amp;#39;m generate 2 public keys from 2 different private keys , the calculation of the 2 shared key are the same. So the generated public keys are not random numbers. Thanks for your answer !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/thread/67867?ContentTypeID=1</link><pubDate>Fri, 11 Nov 2016 12:31:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afadffbe-bf6d-4868-8937-8ad9ab4b83ee</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;It is also possible to use nrfutil to generate keys, &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.tools%2Fdita%2Ftools%2Fnrfutil%2Fnrfutil_keys_generate_display.html&amp;amp;cp=5_4_5"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The generated keys from nrfutil can be formatted directly in c-code/style.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ECC wrong public key is generated</title><link>https://devzone.nordicsemi.com/thread/67868?ContentTypeID=1</link><pubDate>Thu, 10 Nov 2016 15:17:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33520f81-b3f7-49c9-bc6f-353ff3358087</guid><dc:creator>syntroniks</dc:creator><description>&lt;p&gt;First: Do you have uECC_VLI_NATIVE_LITTLE_ENDIAN=1 defined for your ecc library generation?&lt;/p&gt;
&lt;p&gt;Second: Try reversing your private key. (last byte becomes 0x11, first byte becomes 0xDF)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>