Skip to content

Commit

Permalink
docs: add html documenation (#5)
Browse files Browse the repository at this point in the history
* spec: add cases for padding

* docs: add inline documenation

* docs: update readme

* docs: add html documenation
  • Loading branch information
q9f authored Oct 31, 2021
1 parent 5c59fff commit ba69776
Show file tree
Hide file tree
Showing 14 changed files with 3,265 additions and 77 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@

a native library implementing `bip-0039` mnemonics purely for the crystal language.

> _this bip (0039) describes the implementation of a mnemonic code or mnemonic sentence -- a group of easy to remember words -- for the generation of deterministic wallets._
>
> _it consists of two parts: generating the mnemonic and converting it into a binary seed. this seed can be later used to generate deterministic wallets using bip-0032 or similar methods._
ref: [bitcoin/bips/bip-0039](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)

# installation

add the `bip39` library to your `shard.yml`

```yaml
dependencies:
secp256k1:
bip39:
github: q9f/bip39.cr
version: "~> 0.1"
```
Expand All @@ -27,6 +33,35 @@ dependencies:
require "bip39"
```

you can generate and recover mnemonics fully adhering to the [bip-0039 specification](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki).

```crystal
m0 = Bip0039::Mnemonic.new
# => <Bip0039::Mnemonic:0x7f51769bcd20 @ent=128, @seed=183297182565288719506055787609377395053>
m0.to_words
# => ["measure", "come", "cube", "ostrich", "wide", "inspire", "hello", "essay", "ready", "cute", "reform", "sustain"]
m0.to_hex
# => "89e5c0d5ce7faaea9ab269b2c6d6d16d"
```

the default entropy is of 128 bits. this shard can generate seeds of of 128/160/192/224/256-bit entropy. just initialize mnemonics with the bit-size, e.g., `Bip0039::Mnemonic.new 256`.

it's easily possible to recover bip-0039 mnemonics from a phrase or a seed by simply passing it to the constructor.

```crystal
m1 = Bip0039::Mnemonic.new ["measure", "come", "cube", "ostrich", "wide", "inspire", "hello", "essay", "ready", "cute", "reform", "sustain"]
# => <Bip0039::Mnemonic:0x7f37ca6e4c80 @ent=128, @seed=183297182565288719506055787609377395053>
m1.to_hex
# => "89e5c0d5ce7faaea9ab269b2c6d6d16d"
m2 = Bip0039::Mnemonic.new "89e5c0d5ce7faaea9ab269b2c6d6d16d"
# => <Bip0039::Mnemonic:0x7f37ca6e4be0 @ent=128, @seed=183297182565288719506055787609377395053>
m2.to_words
# => ["measure", "come", "cube", "ostrich", "wide", "inspire", "hello", "essay", "ready", "cute", "reform", "sustain"]
```

# documentation

the full library documentation can be found here: [q9f.github.io/bip39.cr](https://q9f.github.io/bip39.cr/)
Expand Down
191 changes: 191 additions & 0 deletions docs/Bip0039.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 1.2.0">
<meta name="crystal_docs.project_version" content="q9f/docs/html-dev">
<meta name="crystal_docs.project_name" content="bip39">



<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/doc.js"></script>

<meta name="repository-name" content="bip39">
<title>Bip0039 - bip39 q9f/docs/html-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "";
</script>
</head>
<body>

<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>

<div class="project-summary">
<h1 class="project-name">
<a href="index.html">
bip39
</a>
</h1>

<span class="project-version">
q9f/docs/html-dev
</span>
</div>
</div>

<div class="search-results hidden">
<ul class="search-list"></ul>
</div>

<div class="types-list">
<ul>

<li class="parent open current" data-id="bip39/Bip0039" data-name="bip0039">
<a href="Bip0039.html">Bip0039</a>

<ul>

<li class=" " data-id="bip39/Bip0039/Mnemonic" data-name="bip0039::mnemonic">
<a href="Bip0039/Mnemonic.html">Mnemonic</a>

</li>

<li class=" " data-id="bip39/Bip0039/Util" data-name="bip0039::util">
<a href="Bip0039/Util.html">Util</a>

</li>

</ul>


</li>

</ul>

</div>
</div>


<div class="main-content">
<h1 class="type-name">

<span class="kind">module</span> Bip0039

</h1>





<h2>
<a id="overview" class="anchor" href="#overview">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Overview
</h2>

<p>Implements 128/160/192/224/256-bit <code>BIP-0039</code> Mnemonics.
Ref: <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">bitcoin/bips/bip-0039</a></p>














<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>


bip39.cr

<br/>


util.cr

<br/>


version.cr

<br/>





<h2>
<a id="constant-summary" class="anchor" href="#constant-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constant Summary
</h2>

<dl>

<dt class="entry-const" id="VERSION">
<strong>VERSION</strong> = <code><span class="s">&quot;0.1.0&quot;</span></code>
</dt>

<dd class="entry-const-doc">
<p>The <code><a href="Bip0039.html#VERSION">VERSION</a></code> of the <code><a href="Bip0039.html">Bip0039</a></code> module.</p>
</dd>


</dl>











<div class="methods-inherited">

</div>









</div>

</body>
</html>
Loading

0 comments on commit ba69776

Please sign in to comment.