mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
143 lines
6.3 KiB
HTML
143 lines
6.3 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/html; charset=utf-8" />
|
|
|
|
<title>Hashes — Bigchain 0.0.1 documentation</title>
|
|
|
|
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: './',
|
|
VERSION: '0.0.1',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
<link rel="top" title="Bigchain 0.0.1 documentation" href="index.html" />
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
|
|
|
|
</head>
|
|
<body role="document">
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body" role="main">
|
|
|
|
<p>Cryptographic algorithms and python implementations that we use.</p>
|
|
<p>The implementations that we have chosen for now are just for fast prototyping. Some of them are pure python
|
|
implementations which may be slow. As future work we should look at other alternatives</p>
|
|
<div class="section" id="hashes">
|
|
<span id="hashes"></span><h1>Hashes<a class="headerlink" href="#hashes" title="Permalink to this headline">¶</a></h1>
|
|
<p>For hashing we are using the sha3-256 algorithm and <a class="reference external" href="https://bitbucket.org/tiran/pykeccak">pysha3</a> as the python
|
|
implementation. We store the hex encoded hash in the bigchain.</p>
|
|
<div class="section" id="example">
|
|
<span id="example"></span><h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">hashlib</span>
|
|
<span class="c1"># monkey patch hashlib with sha3 functions</span>
|
|
<span class="kn">import</span> <span class="nn">sha3</span>
|
|
|
|
<span class="n">data</span> <span class="o">=</span> <span class="s2">"message"</span>
|
|
<span class="n">tx_hash</span> <span class="o">=</span> <span class="n">hashlib</span><span class="o">.</span><span class="n">sha3_256</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="o">.</span><span class="n">hexdigest</span><span class="p">()</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="keys">
|
|
<span id="keys"></span><h1>Keys<a class="headerlink" href="#keys" title="Permalink to this headline">¶</a></h1>
|
|
<p>For signing and veryfing signatures we are using the ECDSA with 192bit key lengths and
|
|
<a class="reference external" href="https://github.com/warner/python-ecdsa">python-ecdsa</a> as the python implementation.</p>
|
|
<p>The public-key or verification key are converted to string and hex encoded before storing them to the blockchain</p>
|
|
<div class="section" id="example">
|
|
<span id="id1"></span><h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">binascii</span>
|
|
<span class="kn">from</span> <span class="nn">ecdsa</span> <span class="kn">import</span> <span class="n">SigningKey</span>
|
|
|
|
<span class="c1"># generate signing key in hex encoded form</span>
|
|
<span class="n">sk</span> <span class="o">=</span> <span class="n">SigningKey</span><span class="o">.</span><span class="n">generate</span><span class="p">()</span>
|
|
<span class="n">sk_hex</span> <span class="o">=</span> <span class="n">binascii</span><span class="o">.</span><span class="n">hexlify</span><span class="p">(</span><span class="n">sk</span><span class="o">.</span><span class="n">to_string</span><span class="p">())</span>
|
|
|
|
<span class="c1"># get signing key from hex</span>
|
|
<span class="n">sk</span> <span class="o">=</span> <span class="n">SigningKey</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">binascii</span><span class="o">.</span><span class="n">unhexlify</span><span class="p">(</span><span class="n">sk_hex</span><span class="p">))</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
|
<div class="sphinxsidebarwrapper">
|
|
<h3><a href="index.html">Table Of Contents</a></h3>
|
|
<ul>
|
|
<li><a class="reference internal" href="#">Hashes</a><ul>
|
|
<li><a class="reference internal" href="#example">Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a class="reference internal" href="#keys">Keys</a><ul>
|
|
<li><a class="reference internal" href="#example">Example</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<div class="relations">
|
|
<h3>Related Topics</h3>
|
|
<ul>
|
|
<li><a href="index.html">Documentation overview</a><ul>
|
|
</ul></li>
|
|
</ul>
|
|
</div>
|
|
<div role="note" aria-label="source link">
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="_sources/Cryptography.txt"
|
|
rel="nofollow">Show Source</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchbox" style="display: none" role="search">
|
|
<h3>Quick search</h3>
|
|
<form class="search" action="search.html" method="get">
|
|
<input type="text" name="q" />
|
|
<input type="submit" value="Go" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
<p class="searchtip" style="font-size: 90%">
|
|
Enter search terms or a module, class or function name.
|
|
</p>
|
|
</div>
|
|
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="footer">
|
|
©2016, ascribe GmbH.
|
|
|
|
|
|
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.3.5</a>
|
|
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.7</a>
|
|
|
|
|
|
|
<a href="_sources/Cryptography.txt"
|
|
rel="nofollow">Page source</a>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html> |