<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[wolfSSL - Embedded SSL Library — Add two ecc points?]]></title>
		<link>https://www.wolfssl.com/forums/topic792-add-two-ecc-points.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic792.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Add two ecc points?.]]></description>
		<lastBuildDate>Thu, 12 May 2016 08:21:39 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Add two ecc points?]]></title>
			<link>https://www.wolfssl.com/forums/post2496.html#p2496</link>
			<description><![CDATA[<p>Hi Chris,</p><p>I&#039;m trying to implement &quot;Elliptic Curve Qu-Vanstone Implicit Certificate Scheme&quot; based on <a href="http://www.secg.org/sec4-1.0.pdf">http://www.secg.org/sec4-1.0.pdf</a>.</p><p>I tried to modify my function like this:<br /></p><div class="codebox"><pre><code>int wc_ecc_add2point(ecc_point* P, ecc_point* Q, ecc_point* R, mp_int* modulus){
    mp_digit mp;
    mp_int mu;
    ecc_point *tP, *tQ;
    int err;
    /* init montgomery reduction */
    if ((err = mp_montgomery_setup(modulus, &amp;mp)) != MP_OKAY) {
      return err;
    }
    if ((err = mp_init(&amp;mu)) != MP_OKAY) {
        return err;
    }
    if ((err = mp_montgomery_calc_normalization(&amp;mu, modulus)) != MP_OKAY) {
        mp_clear(&amp;mu);
        return err;
    }
    tP = wc_ecc_new_point();
    tQ = wc_ecc_new_point();
    if (err == MP_OKAY) {
           if (mp_cmp_d(&amp;mu, 1) == MP_EQ) {
               err = mp_copy(P-&gt;x, tP-&gt;x);
               if (err == MP_OKAY)
                   err = mp_copy(P-&gt;y, tP-&gt;y);
               if (err == MP_OKAY)
                   err = mp_copy(P-&gt;z, tP-&gt;z);
           } else {
               err = mp_mulmod(P-&gt;x, &amp;mu, modulus, tP-&gt;x);
               if (err == MP_OKAY)
                   err = mp_mulmod(P-&gt;y, &amp;mu, modulus, tP-&gt;y);
               if (err == MP_OKAY)
                   err = mp_mulmod(P-&gt;z, &amp;mu, modulus, tP-&gt;z);
           }
       }
    if (err == MP_OKAY) {
           if (mp_cmp_d(&amp;mu, 1) == MP_EQ) {
               err = mp_copy(Q-&gt;x, tQ-&gt;x);
               if (err == MP_OKAY)
                   err = mp_copy(Q-&gt;y, tQ-&gt;y);
               if (err == MP_OKAY)
                   err = mp_copy(Q-&gt;z, tQ-&gt;z);
           } else {
               err = mp_mulmod(Q-&gt;x, &amp;mu, modulus, tQ-&gt;x);
               if (err == MP_OKAY)
                   err = mp_mulmod(Q-&gt;y, &amp;mu, modulus, tQ-&gt;y);
               if (err == MP_OKAY)
                   err = mp_mulmod(Q-&gt;z, &amp;mu, modulus, tQ-&gt;z);
           }
       }
    if((err = ecc_projective_add_point(tP, tQ, R, modulus, &amp;mp))!=MP_OKAY){
        return err;
    }

    if((err = ecc_map(R, modulus, &amp;mp))!=MP_OKAY) {
        return err;
    }
    return MP_OKAY;
}</code></pre></div><p>To expose wc_ecc_add2point as a part of public API, I added the prototype of the function on ecc.h like this: </p><div class="codebox"><pre><code>WOLFSSL_API
int wc_ecc_add2point(ecc_point* P, ecc_point* Q, ecc_point* R, mp_int* modulus);</code></pre></div><p>And then I called it in an other function in ssl.c:<br /></p><div class="codebox"><pre><code>    ecc_point* base, *eccD;
    const ecc_set_type* dp =  &amp;ecc_sets[curve_index];
        int err;
    base = wc_ecc_new_point();

    /*Get domain curve parameters*/
        err = mp_read_radix(&amp;prime, (char *) dp-&gt;prime, 16);
    if (err == MP_OKAY)
        err = mp_read_radix(&amp;order, (char *) dp-&gt;order, 16);
    if (err == MP_OKAY)
        err = mp_read_radix(base-&gt;x, (char *) dp-&gt;Gx, 16);
    if (err == MP_OKAY)
        err = mp_read_radix(base-&gt;y, (char *) dp-&gt;Gy, 16);
    if (err == MP_OKAY)
        mp_set(base-&gt;z, 1);
    eccD = wc_ecc_new_point();
    err = wc_ecc_add2point(base, base, eccD, &amp;prime);</code></pre></div><p>And the result was seem &#039;OK&#039;. <strong>eccD </strong>point was actually double <strong>base </strong>point. But I still don&#039;t know whether my implement (the way I used ecc_projective_add_point function) is correct or not? And the way I use to expose the function as a part of public API of wolfSSL is right?</p><p>Can you give me advice?</p><p>Thank You,</p>]]></description>
			<author><![CDATA[null@example.com (hdan)]]></author>
			<pubDate>Thu, 12 May 2016 08:21:39 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2496.html#p2496</guid>
		</item>
		<item>
			<title><![CDATA[Re: Add two ecc points?]]></title>
			<link>https://www.wolfssl.com/forums/post2494.html#p2494</link>
			<description><![CDATA[<p>Hi hdan,</p><p>Can you tell me where the above was failing for you, and how you are calling that function?&nbsp; Are you initializing/importing the ecc_point&#039;s somewhere else?</p><p>Do you mind if I ask what your end goal is for adding ECC points?&nbsp; I just want to verify we don&#039;t already have the functionality you are looking for elsewhere.</p><p>Thanks,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Tue, 10 May 2016 21:43:17 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2494.html#p2494</guid>
		</item>
		<item>
			<title><![CDATA[Re: Add two ecc points?]]></title>
			<link>https://www.wolfssl.com/forums/post2493.html#p2493</link>
			<description><![CDATA[<p>Hi Chrisc,</p><p>Thank you for your answer!<br />I&#039;m try to use ecc_projective_add_point() function, but the result isn&#039;t as expecting. It seems like I used it incorrectly. The following is the function which I write to add two ecc points:</p><div class="codebox"><pre><code>int wc_ecc_add2point(ecc_point* P, ecc_point* Q, ecc_point* R, mp_int* modulus){
    mp_digit mp;
    int err;
    if ((err = mp_montgomery_setup(modulus, &amp;mp)) != MP_OKAY) {
      return err;
    }
    if((err = ecc_projective_add_point(P, Q, R, modulus, &amp;mp))!=MP_OKAY){
        return err;
    }
    if((err = ecc_map(R, modulus, &amp;mp))!=MP_OKAY) {
        return err;
    }
    return MP_OKAY;
}</code></pre></div><p>Is it ok if I use P and Q in affine coordinate format to put on ecc_projective_add_point() function?<br />Please help me how to use this function.&nbsp; <br />Thank You!</p>]]></description>
			<author><![CDATA[null@example.com (hdan)]]></author>
			<pubDate>Tue, 10 May 2016 09:03:05 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2493.html#p2493</guid>
		</item>
		<item>
			<title><![CDATA[Re: Add two ecc points?]]></title>
			<link>https://www.wolfssl.com/forums/post2491.html#p2491</link>
			<description><![CDATA[<p>Hi,</p><p>wolfCrypt&#039;s ECC implementation has the functionality to add two points internally, but doesn&#039;t currently expose it as part of the public API.&nbsp; The internal implementation is located in the ecc_projective_add_point() function of ./wolfcrypt/src/ecc.c.</p><p>Can you elaborate on your desired use case of ECC point addition?</p><p>Thanks,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Mon, 09 May 2016 21:02:21 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2491.html#p2491</guid>
		</item>
		<item>
			<title><![CDATA[Add two ecc points?]]></title>
			<link>https://www.wolfssl.com/forums/post2490.html#p2490</link>
			<description><![CDATA[<p>Hi,</p><p>Do wolfssl support addition two ecc points?</p><p>Thank You!</p>]]></description>
			<author><![CDATA[null@example.com (hdan)]]></author>
			<pubDate>Mon, 09 May 2016 16:04:02 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2490.html#p2490</guid>
		</item>
	</channel>
</rss>
