diff --git a/README.md b/README.md index 99146b5..c729138 100644 --- a/README.md +++ b/README.md @@ -63,3 +63,17 @@ Tools for sharing secrets (like Bitcoin private keys), using shamir's secret sha >>> points_to_secret_int(shares[0:2]) 88985120633792790105905686761572077713049967498756747774697023364147812997770L + +### Custom formats + +#### Splitting into shares + + >>> from secretsharing import SecretSharer, base64_chars, base16_chars + >>> sharer = SecretSharer(secret_charset=base16_chars, share_charset=base64_chars) + >>> shares = sharer.split_secret("c4bbcb1fbec99d65bf59d85c8cb62ee2db963f0fe106f483d9afa73bd4e39a8a", 2, 3) + ['B-JpxCTUQ9D+q93JglQM9yRinI2Cyxe92FTBSYa93ppfY', 'C-HAmR0pjHuHwL4rozXnFY05ysIJVqtf3pob1HCMaaZUm', 'D-EXbhV+1SYQ1Z6NxBfBM/YQ+PaP4j8B5N92X1pa9LJJ0'] + +#### Recovering from shares + + >>> sharer.recover_secret(shares[0:2]) + 'c4bbcb1fbec99d65bf59d85c8cb62ee2db963f0fe106f483d9afa73bd4e39a8a' diff --git a/secretsharing/__init__.py b/secretsharing/__init__.py index 50af5e0..c5989af 100644 --- a/secretsharing/__init__.py +++ b/secretsharing/__init__.py @@ -10,4 +10,4 @@ __version__ = '0.2.0' from .sharing import * -from .charset import charset_to_int, int_to_charset +from .charset import * diff --git a/secretsharing/charset.py b/secretsharing/charset.py index 9438b04..af5b9fd 100644 --- a/secretsharing/charset.py +++ b/secretsharing/charset.py @@ -42,6 +42,11 @@ def change_charset(s, original_charset, target_charset): output_string = int_to_charset(intermediate_integer, target_charset) return output_string +""" Base16 includes numeric digits and the letters a through f. Here, + we use the lowecase letters. +""" +base16_chars = string.hexdigits[0:16] + """ The Base58 character set allows for strings that avoid visual ambiguity when typed. It consists of all the alphanumeric characters except for "0", "O", "I", and "l", which look similar in some fonts.