pqc/ntru__poly_8c.html
travis-ci b333b7d765 Lastest doxygen docs updated
travis build: 29
	commit: 03f3b4b230
	auto-pushed to gh-pages
2014-06-08 23:33:25 +00:00

779 lines
35 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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.7"/>
<title>post quantum cryptography: /home/travis/build/hasufell/pqc/src/ntru_poly.c 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="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</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 style="padding-left: 0.5em;">
<div id="projectname">post quantum cryptography
</div>
<div id="projectbrief">Highly optimized implementation of the NTRUEncrypt algorithm</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.7 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&#160;List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></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 id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">ntru_poly.c File Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>operations on polynomials
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;<a class="el" href="ntru__err_8h_source.html">ntru_err.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ntru__mem_8h_source.html">ntru_mem.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ntru__params_8h_source.html">ntru_params.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ntru__poly_8h_source.html">ntru_poly.h</a>&quot;</code><br />
<code>#include &lt;stdarg.h&gt;</code><br />
<code>#include &lt;stdbool.h&gt;</code><br />
<code>#include &lt;stdint.h&gt;</code><br />
<code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;sys/types.h&gt;</code><br />
<code>#include &lt;fmpz_poly.h&gt;</code><br />
<code>#include &lt;fmpz.h&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for ntru_poly.c:</div>
<div class="dyncontent">
<div class="center"><img src="ntru__poly_8c__incl.png" border="0" usemap="#_2home_2travis_2build_2hasufell_2pqc_2src_2ntru__poly_8c" alt=""/></div>
<map name="_2home_2travis_2build_2hasufell_2pqc_2src_2ntru__poly_8c" id="_2home_2travis_2build_2hasufell_2pqc_2src_2ntru__poly_8c">
<area shape="rect" id="node3" href="ntru__err_8h.html" title="error handling " alt="" coords="104,195,181,224"/><area shape="rect" id="node5" href="ntru__mem_8h.html" title="header for ntru_mem.c " alt="" coords="5,117,96,147"/><area shape="rect" id="node9" href="ntru__params_8h.html" title="NTRU parameters. " alt="" coords="205,195,309,224"/><area shape="rect" id="node13" href="ntru__poly_8h.html" title="header for ntru_poly.c " alt="" coords="308,117,393,147"/></map>
</div>
</div>
<p><a href="ntru__poly_8c_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="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a891af13dc4355c9fab9ca3fafcac8054"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#a891af13dc4355c9fab9ca3fafcac8054">poly_mod2_to_modq</a> (const fmpz_poly_t a, fmpz_poly_t Fq, const <a class="el" href="structntru__params.html">ntru_params</a> *params)</td></tr>
<tr class="separator:a891af13dc4355c9fab9ca3fafcac8054"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaaac83ec72414aa208832442657c3520"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#aaaac83ec72414aa208832442657c3520">fmpz_cmp_si_n</a> (const fmpz_t f, slong g)</td></tr>
<tr class="separator:aaaac83ec72414aa208832442657c3520"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20f86085d5eb5372fd25dc270069d38c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#a20f86085d5eb5372fd25dc270069d38c">poly_new</a> (fmpz_poly_t new_poly, int const *const c, const size_t len)</td></tr>
<tr class="separator:a20f86085d5eb5372fd25dc270069d38c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a27ff2116f70bcbf5028219adcae4c5f0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#a27ff2116f70bcbf5028219adcae4c5f0">poly_delete</a> (fmpz_poly_t poly)</td></tr>
<tr class="separator:a27ff2116f70bcbf5028219adcae4c5f0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3f53c63383ff301b20dcede0783869a7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#a3f53c63383ff301b20dcede0783869a7">poly_delete_array</a> (fmpz_poly_t **poly_array)</td></tr>
<tr class="separator:a3f53c63383ff301b20dcede0783869a7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a83297bc2ab5b6e7ce42553570dd8268f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#a83297bc2ab5b6e7ce42553570dd8268f">poly_delete_all</a> (fmpz_poly_t poly,...)</td></tr>
<tr class="separator:a83297bc2ab5b6e7ce42553570dd8268f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae7d0d8364dba689df3fb4904610634cc"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#ae7d0d8364dba689df3fb4904610634cc">fmpz_poly_mod_unsigned</a> (fmpz_poly_t a, const uint32_t mod)</td></tr>
<tr class="separator:ae7d0d8364dba689df3fb4904610634cc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7c4f5e96355518dc97a23da8f34b661a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#a7c4f5e96355518dc97a23da8f34b661a">fmpz_poly_mod</a> (fmpz_poly_t a, const uint32_t mod)</td></tr>
<tr class="separator:a7c4f5e96355518dc97a23da8f34b661a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab1f966fe680d1ce7c19c8c812d1932a7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#ab1f966fe680d1ce7c19c8c812d1932a7">fmpz_poly_set_coeff_fmpz_n</a> (fmpz_poly_t poly, slong n, const fmpz_t x)</td></tr>
<tr class="separator:ab1f966fe680d1ce7c19c8c812d1932a7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a59da1b7962829af8f18d58c05f588606"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#a59da1b7962829af8f18d58c05f588606">fmpz_invmod_ui</a> (fmpz_t f, const fmpz_t g, const uint32_t mod)</td></tr>
<tr class="separator:a59da1b7962829af8f18d58c05f588606"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad2a11e832808ef1cfee0eed1cc02f4b9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#ad2a11e832808ef1cfee0eed1cc02f4b9">fmpz_add_n</a> (fmpz_t f, const fmpz_t g, const fmpz_t h)</td></tr>
<tr class="separator:ad2a11e832808ef1cfee0eed1cc02f4b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae96f479ddd97af709a0ed50817fd3fb3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#ae96f479ddd97af709a0ed50817fd3fb3">poly_starmultiply</a> (const fmpz_poly_t a, const fmpz_poly_t b, fmpz_poly_t c, const <a class="el" href="structntru__params.html">ntru_params</a> *params, uint32_t modulus)</td></tr>
<tr class="separator:ae96f479ddd97af709a0ed50817fd3fb3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ace66beb516186e52f9b5b1ed8a397849"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#ace66beb516186e52f9b5b1ed8a397849">poly_inverse_poly_q</a> (const fmpz_poly_t a, fmpz_poly_t Fq, const <a class="el" href="structntru__params.html">ntru_params</a> *params)</td></tr>
<tr class="separator:ace66beb516186e52f9b5b1ed8a397849"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae77b2014df42e5ed612206d5930ac608"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#ae77b2014df42e5ed612206d5930ac608">poly_inverse_poly_p</a> (const fmpz_poly_t a, fmpz_poly_t Fp, const <a class="el" href="structntru__params.html">ntru_params</a> *params)</td></tr>
<tr class="separator:ae77b2014df42e5ed612206d5930ac608"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a80a8ce0f2944bc3df94291ef2f781498"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#a80a8ce0f2944bc3df94291ef2f781498">poly_draw</a> (const fmpz_poly_t poly)</td></tr>
<tr class="separator:a80a8ce0f2944bc3df94291ef2f781498"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aec098d00160d2d502eb1f8a7c3fa5453"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ntru__poly_8c.html#aec098d00160d2d502eb1f8a7c3fa5453">poly_draw_pretty</a> (const fmpz_poly_t poly)</td></tr>
<tr class="separator:aec098d00160d2d502eb1f8a7c3fa5453"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>operations on polynomials </p>
<p>This files purpose is to handle polynomials in general, allowing modification, arithmetic and common algorithms like inverting them. </p>
<p>Definition in file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ad2a11e832808ef1cfee0eed1cc02f4b9"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void fmpz_add_n </td>
<td>(</td>
<td class="paramtype">fmpz_t&#160;</td>
<td class="paramname"><em>f</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const fmpz_t&#160;</td>
<td class="paramname"><em>g</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const fmpz_t&#160;</td>
<td class="paramname"><em>h</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>The same as fmpz_add() except that it handles NULL pointer for g and h. </p>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00222">222</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="aaaac83ec72414aa208832442657c3520"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int fmpz_cmp_si_n </td>
<td>(</td>
<td class="paramtype">const fmpz_t&#160;</td>
<td class="paramname"><em>f</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">slong&#160;</td>
<td class="paramname"><em>g</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>The same as fmpz_cmp_si except that it will interpret f as a 0-coefficient if it is a NULL pointer.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">f</td><td>the fmpz value to use for comparison </td></tr>
<tr><td class="paramname">g</td><td>the signed long integer to use for comparison </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>negative value if f &lt; g, positiv evalue if g &lt; f, otherwise 0 </dd></dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00093">93</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="a59da1b7962829af8f18d58c05f588606"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int fmpz_invmod_ui </td>
<td>(</td>
<td class="paramtype">fmpz_t&#160;</td>
<td class="paramname"><em>f</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const fmpz_t&#160;</td>
<td class="paramname"><em>g</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint32_t&#160;</td>
<td class="paramname"><em>mod</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Wrapper around fmpz_invmod() where we convert mod to an fmpz_t implicitly.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">f</td><td>result [out] </td></tr>
<tr><td class="paramname">g</td><td>the inverse </td></tr>
<tr><td class="paramname">mod</td><td>the modulo </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00210">210</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="a7c4f5e96355518dc97a23da8f34b661a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void fmpz_poly_mod </td>
<td>(</td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint32_t&#160;</td>
<td class="paramname"><em>mod</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Calls fmpz_poly_get_nmod_poly() and fmpz_poly_set_nmod_poly() in a row, so we don't have to deal with the intermediate nmod_poly_t type if we don't need it.</p>
<p>This also normalises the coefficients to the interval -m/2 &lt;= r &lt; m/2.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">a</td><td>the polynom to apply the modulus to </td></tr>
<tr><td class="paramname">mod</td><td>the modulus </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00182">182</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="ae7d0d8364dba689df3fb4904610634cc"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void fmpz_poly_mod_unsigned </td>
<td>(</td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint32_t&#160;</td>
<td class="paramname"><em>mod</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Calls fmpz_poly_get_nmod_poly() and fmpz_poly_set_nmod_poly_unsigned() in a row, so we don't have to deal with the intermediate nmod_poly_t type if we don't need it.</p>
<p>This also normalises the coefficients to the interval 0 &lt;= r &lt; m.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">a</td><td>the polynom to apply the modulus to </td></tr>
<tr><td class="paramname">mod</td><td>the modulus </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00166">166</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="ab1f966fe680d1ce7c19c8c812d1932a7"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void fmpz_poly_set_coeff_fmpz_n </td>
<td>(</td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>poly</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">slong&#160;</td>
<td class="paramname"><em>n</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const fmpz_t&#160;</td>
<td class="paramname"><em>x</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>The same as fmpz_poly_set_coeff_fmpz() except that it will take care of null-pointer coefficients and use fmpz_poly_set_coeff_si() in that case.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">poly</td><td>the polynom we want to change a coefficient of </td></tr>
<tr><td class="paramname">n</td><td>the coefficient we want to set </td></tr>
<tr><td class="paramname">x</td><td>the value to assign to the coefficient </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00198">198</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="a27ff2116f70bcbf5028219adcae4c5f0"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void poly_delete </td>
<td>(</td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>poly</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>This deletes the internal structure of a polynomial, and frees the pointer.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">poly</td><td>the polynomial to delete </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00123">123</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="a83297bc2ab5b6e7ce42553570dd8268f"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void poly_delete_all </td>
<td>(</td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>poly</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">&#160;</td>
<td class="paramname"><em>...</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>This deletes the internal structure of all polynomials, and frees the pointers. You must call this with NULL as last argument!</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">poly</td><td>the polynomial to delete </td></tr>
<tr><td class="paramname">...</td><td>follow up polynomials </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00149">149</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="a3f53c63383ff301b20dcede0783869a7"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void poly_delete_array </td>
<td>(</td>
<td class="paramtype">fmpz_poly_t **&#160;</td>
<td class="paramname"><em>poly_array</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Delete the internal structure of a polynomial array which must be NULL terminated. It is expected that poly_array is not on the stack and was obtained by a function like ascii_to_poly().</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">poly_array</td><td>the polynomial array </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00131">131</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="a80a8ce0f2944bc3df94291ef2f781498"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void poly_draw </td>
<td>(</td>
<td class="paramtype">const fmpz_poly_t&#160;</td>
<td class="paramname"><em>poly</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Draws a polynomial to stdout.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">poly</td><td>draw this </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00574">574</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="aec098d00160d2d502eb1f8a7c3fa5453"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void poly_draw_pretty </td>
<td>(</td>
<td class="paramtype">const fmpz_poly_t&#160;</td>
<td class="paramname"><em>poly</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Draws a polynomial to stdout, in pretty format.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">poly</td><td>draw this </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00583">583</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="ae77b2014df42e5ed612206d5930ac608"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool poly_inverse_poly_p </td>
<td>(</td>
<td class="paramtype">const fmpz_poly_t&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>Fp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structntru__params.html">ntru_params</a> *&#160;</td>
<td class="paramname"><em>params</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Compute the inverse of a polynomial in (Z/pZ)[X]/(X^N - 1). See NTRU Cryptosystems Tech Report #014 "Almost Inverses
and Fast NTRU Key Creation."</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">a</td><td>polynomial to invert </td></tr>
<tr><td class="paramname">Fp</td><td>polynomial [out] </td></tr>
<tr><td class="paramname">params</td><td>NTRU parameters </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if invertible, false if not </dd></dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00409">409</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="ace66beb516186e52f9b5b1ed8a397849"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool poly_inverse_poly_q </td>
<td>(</td>
<td class="paramtype">const fmpz_poly_t&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>Fq</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structntru__params.html">ntru_params</a> *&#160;</td>
<td class="paramname"><em>params</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Compute the inverse of a polynomial in modulo a power of 2, which is q. This is based off the pseudo-code for "Inversion
in (Z/2Z)[X](X^N - 1)" and "Inversion in (Z/p^r Z)[X](X^N - 1)". See NTRU Cryptosystems Tech Report #014 "Almost Inverses
and Fast NTRU Key Creation."</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">a</td><td>polynomial to invert (is allowed to be the same as param Fq) </td></tr>
<tr><td class="paramname">Fq</td><td>polynomial [out] </td></tr>
<tr><td class="paramname">params</td><td>NTRU parameters </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if invertible, false if not </dd></dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00297">297</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="a891af13dc4355c9fab9ca3fafcac8054"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static void poly_mod2_to_modq </td>
<td>(</td>
<td class="paramtype">const fmpz_poly_t&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>Fq</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structntru__params.html">ntru_params</a> *&#160;</td>
<td class="paramname"><em>params</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>Find the inverse polynomial modulo a power of 2, which is q.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">a</td><td>polynomial to invert </td></tr>
<tr><td class="paramname">Fq</td><td>polynomial [out] </td></tr>
<tr><td class="paramname">params</td><td>NTRU parameters </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00063">63</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="a20f86085d5eb5372fd25dc270069d38c"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void poly_new </td>
<td>(</td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>new_poly</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int const *const&#160;</td>
<td class="paramname"><em>c</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const size_t&#160;</td>
<td class="paramname"><em>len</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initializes and builds a polynomial with the coefficient values of c[] of size len within NTRU parameters and returns a newly allocated polynomial. For an empty polynom, both c and len can be NULL/0.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">new_poly</td><td>the polynomial to initialize and fill with coefficients [out] </td></tr>
<tr><td class="paramname">c</td><td>array of polynomial coefficients, can be NULL </td></tr>
<tr><td class="paramname">len</td><td>size of the coefficient array, can be 0 </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>newly allocated polynomial pointer, must be freed with fmpz_poly_clear() </dd></dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00110">110</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
<a class="anchor" id="ae96f479ddd97af709a0ed50817fd3fb3"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void poly_starmultiply </td>
<td>(</td>
<td class="paramtype">const fmpz_poly_t&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const fmpz_poly_t&#160;</td>
<td class="paramname"><em>b</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">fmpz_poly_t&#160;</td>
<td class="paramname"><em>c</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structntru__params.html">ntru_params</a> *&#160;</td>
<td class="paramname"><em>params</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>modulus</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Starmultiplication, as follows: c = a * b mod (x^N 1)</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">a</td><td>polynom to multiply (can be the same as c) </td></tr>
<tr><td class="paramname">b</td><td>polynom to multiply </td></tr>
<tr><td class="paramname">c</td><td>polynom [out] </td></tr>
<tr><td class="paramname">params</td><td>NTRU parameters </td></tr>
<tr><td class="paramname">modulus</td><td>whether we use p or q </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ntru__poly_8c_source.html#l00239">239</a> of file <a class="el" href="ntru__poly_8c_source.html">ntru_poly.c</a>.</p>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Jun 8 2014 23:33:23 for post quantum cryptography by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.7
</small></address>
</body>
</html>