-r--r--r-- 6291 libntruprime-20240910/doc/html/api.html raw
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
html{overflow-y:scroll;background-color:#004591}
body{font-family:"Noto Sans","Droid Sans","DejaVu Sans","Arial",sans-serif;line-height:1.5}
tt,code{background-color:#f0f0f0;font-family:"Noto Sans Mono","Droid Sans Mono","DejaVu Sans Mono","Courier New",monospace,sans-serif;font-size:1em;}
pre{margin-left:3em}
p,ul,ol,blockquote,pre{font-size:1.0em;line-height:1.6}
li p{font-size:1.0em}
blockquote p{font-size:1.0em}
h1{font-size:1.5em}
h2{font-size:1.3em}
h3{font-size:1.0em}
h1 a{text-decoration:none}
table{border-collapse:collapse}
th,td{border:1px solid black}
table a{text-decoration:none}
table tr{font-size:1.0em;line-height:1.6em}
table tr{font-size:1.0em;line-height:1.5}
tbody tr:nth-child(12n+1){background-color:#f0ffff}
tbody tr:nth-child(12n+2){background-color:#f0ffff}
tbody tr:nth-child(12n+3){background-color:#f0ffff}
tbody tr:nth-child(12n+4){background-color:#f0ffff}
tbody tr:nth-child(12n+5){background-color:#f0ffff}
tbody tr:nth-child(12n+6){background-color:#f0ffff}
tbody tr:nth-child(12n+7){background-color:#fffff0}
tbody tr:nth-child(12n+8){background-color:#fffff0}
tbody tr:nth-child(12n+9){background-color:#fffff0}
tbody tr:nth-child(12n+10){background-color:#fffff0}
tbody tr:nth-child(12n+11){background-color:#fffff0}
tbody tr:nth-child(12n+12){background-color:#fffff0}
.headline{padding:0;font-weight:bold;font-size:1.0em;vertical-align:top;padding-bottom:0.5em;color:#ffffff;background-color:#004591}
.navt{display:block;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;margin:0;padding:0;vertical-align:center;font-size:1.0em}
.here{background-color:#004591}
.here{color:#ffffff}
.away{background-color:#004591}
.away a{text-decoration:none;display:block;color:#ffffff}
.away a:hover,.away a:active{text-decoration:underline}
.main{padding:5px}
.main{background-color:#ffffff}
.pagetitle{font-size:1.4em;font-weight:bold}
@media only screen and (min-width:512px) {
.fixed{margin:0;padding:0;width:160px;height:100%;position:fixed;overflow:auto}
.main{margin-left:170px}
}
</style>
<title>
libntruprime: API</title>
</head>
<body>
<div class=fixed>
<div class=headline>
libntruprime</div>
<div class="navt away"><a href=index.html>Intro</a>
</div><div class="navt away"><a href=download.html>Download</a>
</div><div class="navt away"><a href=install.html>Install</a>
</div><div class="navt away"><a href=test.html>Test</a>
</div><div class="navt here">API
</div><div class="navt away"><a href=cli.html>CLI</a>
</div><div class="navt away"><a href=security.html>Security</a>
</div><div class="navt away"><a href=verification.html>Verification</a>
</div><div class="navt away"><a href=speed.html>Speed</a>
</div><div class="navt away"><a href=internals.html>Internals</a>
</div><div class="navt away"><a href=people.html>People</a>
</div><div class="navt away"><a href=license.html>License</a>
</div></div>
<div class=main>
<div class=pagetitle>libntruprime: API</div>
<h3>NAME</h3>
<p>sntrup - C API for the libntruprime implementation of the Streamlined NTRU Prime cryptosystem</p>
<h3>SYNOPSIS</h3>
<p>Using libntruprime:</p>
<pre><code>#include <ntruprime.h>
</code></pre>
<p>Link with <code>-lntruprime</code>.</p>
<p>Key generation (for, e.g., <code>sntrup1277</code>):</p>
<pre><code>unsigned char pk[sntrup1277_PUBLICKEYBYTES];
unsigned char sk[sntrup1277_SECRETKEYBYTES];
sntrup1277_keypair(pk,sk);
</code></pre>
<p>Encapsulation (for, e.g., <code>sntrup1277</code>):</p>
<pre><code>unsigned char ct[sntrup1277_CIPHERTEXTBYTES];
unsigned char k[sntrup1277_BYTES];
const unsigned char pk[sntrup1277_PUBLICKEYBYTES];
sntrup1277_enc(ct,k,pk);
</code></pre>
<p>Decapsulation (for, e.g., <code>sntrup1277</code>):</p>
<pre><code>unsigned char k[sntrup1277_BYTES];
const unsigned char ct[sntrup1277_CIPHERTEXTBYTES];
const unsigned char sk[sntrup1277_SECRETKEYBYTES];
sntrup1277_dec(k,ct,sk);
</code></pre>
<h3>DESCRIPTION</h3>
<p>libntruprime is an implementation
of the <a href="https://ntruprime.cr.yp.to">Streamlined NTRU Prime</a> cryptosystem.
The C API for libntruprime
provides the following functions:</p>
<pre><code>sntrup{653,761,857,953,1013,1277}_keypair
sntrup{653,761,857,953,1013,1277}_enc
sntrup{653,761,857,953,1013,1277}_dec
</code></pre>
<p>All of these functions follow the
<a href="https://bench.cr.yp.to/call-kem.html">SUPERCOP API for KEMs</a>
except that</p>
<ul>
<li>the function names are libntruprime-specific instead of <code>crypto_kem_*</code>,</li>
<li>message lengths are <code>long long</code> instead of <code>unsigned long long</code>, and</li>
<li>the functions return <code>void</code> instead of <code>int</code>.</li>
</ul>
<p>The details below use <code>sntrup1277</code> as an example.</p>
<h3>KEY GENERATION</h3>
<p>The <code>sntrup1277_keypair</code> function randomly generates
Alice's secret key
<code>sk[0]</code>, <code>sk[1]</code>, ..., <code>sk[sntrup1277_SECRETKEYBYTES-1]</code>
and
Alice's corresponding public key
<code>pk[0]</code>, <code>pk[1]</code>, ..., <code>pk[sntrup1277_PUBLICKEYBYTES-1]</code>.</p>
<h3>ENCAPSULATION</h3>
<p>The <code>sntrup1277_enc</code> function randomly generates
a ciphertext <code>ct[0]</code>, <code>ct[1]</code>, ..., <code>ct[sntrup1277_CIPHERTEXTBYTES-1]</code>
and the corresponding session key
<code>k[0]</code>, <code>k[1]</code>, ..., <code>k[sntrup1277_BYTES-1]</code>
given Alice's public key
<code>pk[0]</code>, <code>pk[1]</code>, ..., <code>pk[sntrup1277_PUBLICKEYBYTES-1]</code>.</p>
<h3>DECAPSULATION</h3>
<p>The <code>sntrup1277_dec</code> function,
given Alice's secret key
<code>sk[0]</code>, <code>sk[1]</code>, ..., <code>sk[sntrup1277_SECRETKEYBYTES-1]</code>,
computes the session key
<code>k[0]</code>, <code>k[1]</code>, ..., <code>k[sntrup1277_BYTES-1]</code>
corresponding to a ciphertext
<code>ct[0]</code>, <code>ct[1]</code>, ..., <code>ct[sntrup1277_CIPHERTEXTBYTES-1]</code>
that was encapsulated to Alice.</p>
<h3>SEE ALSO</h3>
<p><strong>sntrup</strong>(1), <strong>randombytes</strong>(3)</p><hr><font size=1><b>Version:</b>
This is version 2024.08.12 of the "API" web page.
</font>
</div>
</body>
</html>