Skip to content

Commit

Permalink
update sharer class names
Browse files Browse the repository at this point in the history
  • Loading branch information
shea256 committed May 29, 2014
1 parent f97fed4 commit 0e813c7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ Tools for sharing secrets (like Bitcoin private keys), using shamir's secret sha

### Bitcoin Private Keys

#### Splitting into reliably transcribable shares
#### Splitting into reliably transcribable b32 shares

>>> from secretsharing import BitcoinSecretSharer
>>> from secretsharing import BitcoinToB32SecretSharer
>>> secret = "5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS"
>>> sharer = BitcoinSecretSharer()
>>> shares = sharer.split_secret(secret, 2, 3)
>>> b32_sharer = BitcoinToB32SecretSharer()
>>> shares = b32_sharer.split_secret(secret, 2, 3)
['B-RJ6Y56OSUWDY5VAAGC6XLSTM64CAJ2LPBNB7NKATJCWC7VSHIP5DQIVMR6OGJ4GB', 'C-CT5R24XAR5B732JWYQKSYOYBSF5VHI73HLY24QCFRJR5XUW64C4JWYN6SRGWVCUG', 'D-T54KX27OPEAGZ7TNK5WOFK4WFPZKEXUHNKPWLWDXZQNYPT3WPV3P5IGQTD7HAJDG']

#### Splitting into reliably transcribable zb32 shares

>>> from secretsharing import BitcoinToZB32SecretSharer
>>> secret = "5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS"
>>> zb32_sharer = BitcoinToZB32SecretSharer()
>>> shares = zb32_sharer.split_secret(secret, 2, 3)
['b-aweuzkm9jmfgd7x4k595bzcm3er3epf4dprfwzpprqa3exbuocs9byn4owfuqbo', 'n-btetgqqu8doacarsbyfdzpyycyj6gfdeaaxrpfx33pdjk4ou1d5owjdmdi1iegm9', 'd-njh33f14q7smucmh8iq8uaewc8mzub3mzptrwsegfiz3hc1fozkkjtguc4trh6sq']

#### Recovering from shares
Expand Down
2 changes: 1 addition & 1 deletion secretsharing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:license: MIT, see LICENSE for more details.
"""

__version__ = '0.2.0'
__version__ = '0.2.1'

from .sharing import *
from .charset import *
9 changes: 8 additions & 1 deletion secretsharing/sharing.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,14 @@ class PlaintextToHexSecretSharer(SecretSharer):
def __init__(self):
SecretSharer.__init__(self, string.printable, string.hexdigits[0:16])

class BitcoinSecretSharer(SecretSharer):
class BitcoinToB32SecretSharer(SecretSharer):
""" Good for converting Bitcoin secret keys into shares that can be
reliably and conveniently transcribed.
"""
def __init__(self):
SecretSharer.__init__(self, charset.base58_chars, charset.base32_chars)

class BitcoinToZB32SecretSharer(SecretSharer):
""" Good for converting Bitcoin secret keys into shares that can be
reliably and conveniently transcribed.
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='secretsharing',
version='0.2.0',
version='0.2.1',
url='https://github.com/rxl/secretsharing',
license='MIT',
author='Halfmoon Labs',
Expand Down
16 changes: 14 additions & 2 deletions tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,27 @@ def test_hex_to_hex_sharing(self):
recovered_secret = self.split_and_recover_secret(secret, sharer, 3, 5)
assert(recovered_secret == secret)

def test_ascii_to_hex_sharing(self):
def test_printable_ascii_to_hex_sharing(self):
secret = "correct horse battery staple"
sharer = PlaintextToHexSecretSharer()
recovered_secret = self.split_and_recover_secret(secret, sharer, 3, 5)
assert(recovered_secret == secret)

def test_b58_to_zb32_sharing(self):
secret = "5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS"
sharer = BitcoinSecretSharer()
sharer = BitcoinToZB32SecretSharer()
recovered_secret = self.split_and_recover_secret(secret, sharer, 3, 5)
assert(recovered_secret == secret)

def test_b58_to_b32_sharing(self):
secret = "5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS"
sharer = BitcoinToB32SecretSharer()
recovered_secret = self.split_and_recover_secret(secret, sharer, 3, 5)
assert(recovered_secret == secret)

def test_hex_to_base64_sharing(self):
secret = "c4bbcb1fbec99d65bf59d85c8cb62ee2db963f0fe106f483d9afa73bd4e39a8a"
sharer = SecretSharer(secret_charset=base16_chars, share_charset=base64_chars)
recovered_secret = self.split_and_recover_secret(secret, sharer, 3, 5)
assert(recovered_secret == secret)

Expand Down

0 comments on commit 0e813c7

Please sign in to comment.