dash-docs/en/doxygen/html/ecmult__const__impl_8h.html

320 lines
20 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Dash Core: src/secp256k1/src/ecmult_const_impl.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="bitcoin_logo_doxygen.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Dash Core
&#160;<span id="projectnumber">0.12.2.1</span>
</div>
<div id="projectbrief">P2P Digital Currency</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('ecmult__const__impl_8h.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">ecmult_const_impl.h File Reference</div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="scalar_8h_source.html">scalar.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="group_8h_source.html">group.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ecmult__const_8h_source.html">ecmult_const.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ecmult__impl_8h_source.html">ecmult_impl.h</a>&quot;</code><br />
</div>
<p><a href="ecmult__const__impl_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a7ca5efdae3396a6261bcc836e4a32739"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ecmult__const__impl_8h.html#a7ca5efdae3396a6261bcc836e4a32739">WNAF_BITS</a>&#160;&#160;&#160;256</td></tr>
<tr class="separator:a7ca5efdae3396a6261bcc836e4a32739"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a23d9fb349265ae338b9977f7f7aab065"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ecmult__const__impl_8h.html#a23d9fb349265ae338b9977f7f7aab065">WNAF_SIZE</a>(w)&#160;&#160;&#160;((<a class="el" href="ecmult__const__impl_8h.html#a7ca5efdae3396a6261bcc836e4a32739">WNAF_BITS</a> + (w) - 1) / (w))</td></tr>
<tr class="separator:a23d9fb349265ae338b9977f7f7aab065"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a541e7c0e2d2f68e2b1b03729d93b4ca7"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ecmult__const__impl_8h.html#a541e7c0e2d2f68e2b1b03729d93b4ca7">ECMULT_CONST_TABLE_GET_GE</a>(r, pre, n, w)</td></tr>
<tr class="separator:a541e7c0e2d2f68e2b1b03729d93b4ca7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ac252ac4f8c905ddc178ce056bd45b8ec"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ecmult__const__impl_8h.html#ac252ac4f8c905ddc178ce056bd45b8ec">secp256k1_wnaf_const</a> (int *wnaf, <a class="el" href="structsecp256k1__scalar.html">secp256k1_scalar</a> s, int w)</td></tr>
<tr class="separator:ac252ac4f8c905ddc178ce056bd45b8ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a89f4e02fa2a4630ae0c5e302457f7931"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ecmult__const__impl_8h.html#a89f4e02fa2a4630ae0c5e302457f7931">secp256k1_ecmult_const</a> (<a class="el" href="structsecp256k1__gej.html">secp256k1_gej</a> *r, const <a class="el" href="structsecp256k1__ge.html">secp256k1_ge</a> *a, const <a class="el" href="structsecp256k1__scalar.html">secp256k1_scalar</a> *scalar)</td></tr>
<tr class="separator:a89f4e02fa2a4630ae0c5e302457f7931"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a541e7c0e2d2f68e2b1b03729d93b4ca7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a541e7c0e2d2f68e2b1b03729d93b4ca7">&#9670;&nbsp;</a></span>ECMULT_CONST_TABLE_GET_GE</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define ECMULT_CONST_TABLE_GET_GE</td>
<td>(</td>
<td class="paramtype">&#160;</td>
<td class="paramname">r, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">&#160;</td>
<td class="paramname">pre, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">&#160;</td>
<td class="paramname">n, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">&#160;</td>
<td class="paramname">w&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line"><span class="keywordflow">do</span> { \</div><div class="line"> int <a class="code" href="namespacelinearize-data.html#af01cfbce273b138c21938509627f15aa">m</a>; \</div><div class="line"> int abs_n = (<a class="code" href="namespacefix-copyright-headers.html#aed10e06fbf20b2e50f73ff2d61f59e45">n</a>) * (((<a class="code" href="namespacefix-copyright-headers.html#aed10e06fbf20b2e50f73ff2d61f59e45">n</a>) &gt; 0) * 2 - 1); \</div><div class="line"> int idx_n = abs_n / 2; \</div><div class="line"> secp256k1_fe neg_y; \</div><div class="line"> VERIFY_CHECK(((<a class="code" href="namespacefix-copyright-headers.html#aed10e06fbf20b2e50f73ff2d61f59e45">n</a>) &amp; 1) == 1); \</div><div class="line"> VERIFY_CHECK((<a class="code" href="namespacefix-copyright-headers.html#aed10e06fbf20b2e50f73ff2d61f59e45">n</a>) &gt;= -((1 &lt;&lt; ((w)-1)) - 1)); \</div><div class="line"> VERIFY_CHECK((<a class="code" href="namespacefix-copyright-headers.html#aed10e06fbf20b2e50f73ff2d61f59e45">n</a>) &lt;= ((1 &lt;&lt; ((w)-1)) - 1)); \</div><div class="line"> VERIFY_SETUP(<a class="code" href="field__10x26__impl_8h.html#aa213f05a02544f894a8829f672b6e4ea">secp256k1_fe_clear</a>(&amp;(r)-&gt;x)); \</div><div class="line"> VERIFY_SETUP(<a class="code" href="field__10x26__impl_8h.html#aa213f05a02544f894a8829f672b6e4ea">secp256k1_fe_clear</a>(&amp;(r)-&gt;y)); \</div><div class="line"> for (<a class="code" href="namespacelinearize-data.html#af01cfbce273b138c21938509627f15aa">m</a> = 0; <a class="code" href="namespacelinearize-data.html#af01cfbce273b138c21938509627f15aa">m</a> &lt; <a class="code" href="ecmult__impl_8h.html#a97c6c6e5aa98f202eec77c4c931e02f1">ECMULT_TABLE_SIZE</a>(w); <a class="code" href="namespacelinearize-data.html#af01cfbce273b138c21938509627f15aa">m</a>++) { \</div><div class="line"> <span class="comment">/* This loop is used to avoid secret data in array indices. See</span></div><div class="line"><span class="comment"> * the comment in ecmult_gen_impl.h for rationale. */</span> \</div><div class="line"> secp256k1_fe_cmov(&amp;(r)-&gt;x, &amp;(pre)[<a class="code" href="namespacelinearize-data.html#af01cfbce273b138c21938509627f15aa">m</a>].x, <a class="code" href="namespacelinearize-data.html#af01cfbce273b138c21938509627f15aa">m</a> == idx_n); \</div><div class="line"> secp256k1_fe_cmov(&amp;(r)-&gt;y, &amp;(pre)[<a class="code" href="namespacelinearize-data.html#af01cfbce273b138c21938509627f15aa">m</a>].y, <a class="code" href="namespacelinearize-data.html#af01cfbce273b138c21938509627f15aa">m</a> == idx_n); \</div><div class="line"> } \</div><div class="line"> (r)-&gt;infinity = 0; \</div><div class="line"> secp256k1_fe_negate(&amp;neg_y, &amp;(r)-&gt;y, 1); \</div><div class="line"> secp256k1_fe_cmov(&amp;(r)-&gt;y, &amp;neg_y, (<a class="code" href="namespacefix-copyright-headers.html#aed10e06fbf20b2e50f73ff2d61f59e45">n</a>) != abs_n); \</div><div class="line">} <span class="keywordflow">while</span>(0)</div><div class="ttc" id="field__10x26__impl_8h_html_aa213f05a02544f894a8829f672b6e4ea"><div class="ttname"><a href="field__10x26__impl_8h.html#aa213f05a02544f894a8829f672b6e4ea">secp256k1_fe_clear</a></div><div class="ttdeci">static SECP256K1_INLINE void secp256k1_fe_clear(secp256k1_fe *a)</div><div class="ttdef"><b>Definition:</b> <a href="field__10x26__impl_8h_source.html#l00299">field_10x26_impl.h:299</a></div></div>
<div class="ttc" id="ecmult__impl_8h_html_a97c6c6e5aa98f202eec77c4c931e02f1"><div class="ttname"><a href="ecmult__impl_8h.html#a97c6c6e5aa98f202eec77c4c931e02f1">ECMULT_TABLE_SIZE</a></div><div class="ttdeci">#define ECMULT_TABLE_SIZE(w)</div><div class="ttdef"><b>Definition:</b> <a href="ecmult__impl_8h_source.html#l00028">ecmult_impl.h:28</a></div></div>
<div class="ttc" id="namespacelinearize-data_html_af01cfbce273b138c21938509627f15aa"><div class="ttname"><a href="namespacelinearize-data.html#af01cfbce273b138c21938509627f15aa">linearize-data.m</a></div><div class="ttdeci">m</div><div class="ttdef"><b>Definition:</b> <a href="linearize-data_8py_source.html#l00260">linearize-data.py:260</a></div></div>
<div class="ttc" id="namespacefix-copyright-headers_html_aed10e06fbf20b2e50f73ff2d61f59e45"><div class="ttname"><a href="namespacefix-copyright-headers.html#aed10e06fbf20b2e50f73ff2d61f59e45">fix-copyright-headers.n</a></div><div class="ttdeci">int n</div><div class="ttdef"><b>Definition:</b> <a href="fix-copyright-headers_8py_source.html#l00046">fix-copyright-headers.py:46</a></div></div>
</div><!-- fragment -->
<p class="definition">Definition at line <a class="el" href="ecmult__const__impl_8h_source.html#l00023">23</a> of file <a class="el" href="ecmult__const__impl_8h_source.html">ecmult_const_impl.h</a>.</p>
<p class="reference">Referenced by <a class="el" href="ecmult__const__impl_8h_source.html#l00125">secp256k1_ecmult_const()</a>.</p>
</div>
</div>
<a id="a7ca5efdae3396a6261bcc836e4a32739"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7ca5efdae3396a6261bcc836e4a32739">&#9670;&nbsp;</a></span>WNAF_BITS</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define WNAF_BITS&#160;&#160;&#160;256</td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="ecmult__const__impl_8h_source.html#l00018">18</a> of file <a class="el" href="ecmult__const__impl_8h_source.html">ecmult_const_impl.h</a>.</p>
<p class="reference">Referenced by <a class="el" href="ecmult__const__impl_8h_source.html#l00057">secp256k1_wnaf_const()</a>.</p>
</div>
</div>
<a id="a23d9fb349265ae338b9977f7f7aab065"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a23d9fb349265ae338b9977f7f7aab065">&#9670;&nbsp;</a></span>WNAF_SIZE</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define WNAF_SIZE</td>
<td>(</td>
<td class="paramtype">&#160;</td>
<td class="paramname">w</td><td>)</td>
<td>&#160;&#160;&#160;((<a class="el" href="ecmult__const__impl_8h.html#a7ca5efdae3396a6261bcc836e4a32739">WNAF_BITS</a> + (w) - 1) / (w))</td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="ecmult__const__impl_8h_source.html#l00020">20</a> of file <a class="el" href="ecmult__const__impl_8h_source.html">ecmult_const_impl.h</a>.</p>
<p class="reference">Referenced by <a class="el" href="ecmult__const__impl_8h_source.html#l00125">secp256k1_ecmult_const()</a>, <a class="el" href="ecmult__const__impl_8h_source.html#l00057">secp256k1_wnaf_const()</a>, and <a class="el" href="tests_8c_source.html#l02382">test_constant_wnaf()</a>.</p>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="a89f4e02fa2a4630ae0c5e302457f7931"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a89f4e02fa2a4630ae0c5e302457f7931">&#9670;&nbsp;</a></span>secp256k1_ecmult_const()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static void secp256k1_ecmult_const </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structsecp256k1__gej.html">secp256k1_gej</a> *&#160;</td>
<td class="paramname"><em>r</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structsecp256k1__ge.html">secp256k1_ge</a> *&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structsecp256k1__scalar.html">secp256k1_scalar</a> *&#160;</td>
<td class="paramname"><em>scalar</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="ecmult__const__impl_8h_source.html#l00125">125</a> of file <a class="el" href="ecmult__const__impl_8h_source.html">ecmult_const_impl.h</a>.</p>
</div>
</div>
<a id="ac252ac4f8c905ddc178ce056bd45b8ec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac252ac4f8c905ddc178ce056bd45b8ec">&#9670;&nbsp;</a></span>secp256k1_wnaf_const()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static int secp256k1_wnaf_const </td>
<td>(</td>
<td class="paramtype">int *&#160;</td>
<td class="paramname"><em>wnaf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structsecp256k1__scalar.html">secp256k1_scalar</a>&#160;</td>
<td class="paramname"><em>s</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>w</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Convert a number to WNAF notation. The number becomes represented by sum(2^{wi} * wnaf[i], i=0..return_val) with the following guarantees:</p><ul>
<li>each wnaf[i] an odd integer between -(1 &lt;&lt; w) and (1 &lt;&lt; w)</li>
<li>each wnaf[i] is nonzero</li>
<li>the number of words set is returned; this is always (WNAF_BITS + w - 1) / w</li>
</ul>
<p>Adapted from <code>The Width-w NAF Method Provides Small Memory and Fast Elliptic Scalar Multiplications Secure against Side Channel Attacks</code>, Okeya and Tagaki. M. Joye (Ed.) CT-RSA 2003, LNCS 2612, pp. 328-443, 2003. Springer-Verlagy Berlin Heidelberg 2003</p>
<p>Numbers reference steps of <code>Algorithm SPA-resistant Width-w NAF with Odd Scalar</code> on pp. 335 </p>
<p class="definition">Definition at line <a class="el" href="ecmult__const__impl_8h_source.html#l00057">57</a> of file <a class="el" href="ecmult__const__impl_8h_source.html">ecmult_const_impl.h</a>.</p>
<p class="reference">Referenced by <a class="el" href="bench__internal_8c_source.html#l00240">bench_wnaf_const()</a>, <a class="el" href="ecmult__const__impl_8h_source.html#l00125">secp256k1_ecmult_const()</a>, and <a class="el" href="tests_8c_source.html#l02382">test_constant_wnaf()</a>.</p>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_44f34d1e62fda08bdb4ca69ab2d205ae.html">secp256k1</a></li><li class="navelem"><a class="el" href="dir_8db2ef784512d48b2a7d00369dfaac28.html">src</a></li><li class="navelem"><a class="el" href="ecmult__const__impl_8h.html">ecmult_const_impl.h</a></li>
<li class="footer">Generated on Thu Dec 14 2017 13:15:11 for Dash Core by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
</ul>
</div>
</body>
</html>