Skip to content

Commit

Permalink
Update docs to output generated at bfa98a5
Browse files Browse the repository at this point in the history
  • Loading branch information
cforeman-cqc committed Jan 17, 2024
1 parent 830e116 commit 8d8aa12
Show file tree
Hide file tree
Showing 28 changed files with 419 additions and 1,459 deletions.
2 changes: 1 addition & 1 deletion _modules/cryptomite/circulant.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../gettingstarted.html">Selecting a Randomness Extractor</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cryptomite.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../performance.html">Performance</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Example Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _modules/cryptomite/dodis.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../gettingstarted.html">Selecting a Randomness Extractor</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cryptomite.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../performance.html">Performance</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Example Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _modules/cryptomite/toeplitz.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../gettingstarted.html">Selecting a Randomness Extractor</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cryptomite.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../performance.html">Performance</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Example Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _modules/cryptomite/trevisan.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../gettingstarted.html">Selecting a Randomness Extractor</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cryptomite.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../performance.html">Performance</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Example Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _modules/cryptomite/utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../gettingstarted.html">Selecting a Randomness Extractor</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cryptomite.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../performance.html">Performance</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks.html">Example Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<li class="toctree-l1"><a class="reference internal" href="../gettingstarted.html">Selecting a Randomness Extractor</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cryptomite.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../performance.html">Performance</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notebooks.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notebooks.html">Example Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bibliography.html">Bibliography</a></li>
</ul>
Expand Down
154 changes: 154 additions & 0 deletions _sources/examples/example.ipynb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "512571e4",
"metadata": {},
"source": [
"# Basic Usage\n",
"\n",
"In this notebook, we give a few examples of how to use ``Cryptomite`` and accompanying utility functions."
]
},
{
"cell_type": "markdown",
"id": "1a031d29",
"metadata": {},
"source": [
"## Quick Start\n",
"\n",
":code:`pip install cryptomite`"
]
},
{
"cell_type": "markdown",
"id": "4b899d5b",
"metadata": {},
"source": [
"## Generating an extractor\n",
"\n",
"Using ``Cryptomite``, extractors can be generated directly by giving the input length (in bits) :code:`n` and output length (in bits) :code:`m`, or for the Trevisan extractor, giving the input length :code:`n`, output length :code:`m` and maximum error, :code:`error`.\n",
"We generate all the extractors of ``Cryptomite`` below, for an example :code:`n`, :code:`m`, :code:`error`:\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "5f168725",
"metadata": {},
"outputs": [],
"source": [
"import cryptomite\n",
"n, m, error = 100, 90, 0.0001\n",
"circulant = cryptomite.Circulant(n, m)\n",
"dodis = cryptomite.Dodis(n, m)\n",
"toeplitz = cryptomite.Toeplitz(n, m)\n",
"trevisan = cryptomite.Trevisan(n, m, error)"
]
},
{
"cell_type": "markdown",
"id": "23b75513",
"metadata": {},
"source": [
"## Extraction\n",
"\n",
"Now the extractors have been generated, we show how to perform extraction. \n",
"The extractors take as input a list of input bits and a list of (weak) seed bits, and outputs a new list of bits.\n",
"Note that each extractor of ``Cryptomite`` requires a different amount of seed bits, the calculation of this is left to the user (manually or using our :code:`from_params` utility functions) and denoted :code:`seed_length` in the following example code.\n",
"In this example, we generate both the input string and the (weak) seed using :code:`randint` function from the :code:`random` Python library - which a user would replace with their desired generation methods:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0d28807c",
"metadata": {},
"outputs": [],
"source": [
"from random import randint\n",
"input_bits = [randint(0, 1) for _ in range(n)]\n",
"circulant.extract(input_bits, [randint(0, 1) for _ in range(seed_length)])\n",
"dodis.extract(input_bits, [randint(0, 1) for _ in range(seed_length)])\n",
"toeplitz.extract(input_bits, [randint(0, 1) for _ in range(seed_length)])\n",
"trevisan.extract(input_bits, [randint(0, 1) for _ in range(seed_length)])"
]
},
{
"cell_type": "markdown",
"id": "42f7f24f",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"Alternatively, all ``Cryptomite`` extractors (except Trevisan) can be generated without needing to calculate the output length or required seed length yourself using the :code:`from_params` utility functions. \n",
"This is performed by providing the input min-entropy, seed min-entropy, log2 of the error, input length, seed length, and whether to calculate the output length in the (quantum-proof) Markov model, for example"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "19ba95c7",
"metadata": {},
"outputs": [],
"source": [
"import cryptomite\n",
"from math import log2\n",
"input_length, seed_length = 100, 100\n",
"input_entropy, seed_entropy = 60, 80\n",
"error = 0.00001\n",
"markov_q_proof = False\n",
"log2_error = log2(error)\n",
"circulant = cryptomite.circulant.from_params(input_entropy,\n",
" seed_entropy,\n",
" log2_error,\n",
" input_length,\n",
" seed_length,\n",
" markov_q_proof)\n",
"dodis = cryptomite.dodis.from_params(input_entropy,\n",
" seed_entropy,\n",
" log2_error,\n",
" input_length,\n",
" seed_length,\n",
" markov_q_proof)\n",
"toeplitz = cryptomite.Toeplitz.from_params(input_entropy,\n",
" seed_entropy,\n",
" log2_error,\n",
" input_length,\n",
" seed_length,\n",
" markov_q_proof)"
]
},
{
"cell_type": "markdown",
"id": "fb5cbab8",
"metadata": {},
"source": [
"In this case, a **valid** extractor is generated from the specified parameters (i.e. one that adheres to the required input and seed length criteria for that extractor).\n",
"Any changes to input length, seed length, input entropy and seed entropy printed."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 8d8aa12

Please sign in to comment.