From 4490cda05e681504f2d3a9b04825aa4a2151c173 Mon Sep 17 00:00:00 2001 From: lance allen Date: Thu, 22 Feb 2018 00:40:28 -0800 Subject: [PATCH] updating index file and adding new seed documentation --- docs/source/index.rst | 1 + docs/source/seed.rst | 94 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 docs/source/seed.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 00ff5ae..8940d2e 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -24,6 +24,7 @@ Project homepage: https://github.com/emesik/monero-python transactions daemon backends + seed misc exceptions license diff --git a/docs/source/seed.rst b/docs/source/seed.rst new file mode 100644 index 0000000..b101ee7 --- /dev/null +++ b/docs/source/seed.rst @@ -0,0 +1,94 @@ +Mnemonic seeds +============== + +You can utilize the ``Seed`` class in order to generate or supply a 25 word mnemonic seed. From this mnemonic seed you can derive public and private spend keys, public and private view keys, and public wallet address. Read more about mnemonic seeds `here`_. + +.. _here: https://getmonero.org/resources/moneropedia/mnemonicseed.html + +.. warning:: This class deals with highly sensitive strings in both inputs and outputs. + The mnemonic seed and it's hexadecimal representation are essentially full + access keys to your Monero funds and should be handled with the utmost care. + + +Generating a new seed +----------------------- + +By default, constructing the ``Seed`` class without any parameters will generate a new 25 word mnemonic seed from a 32 byte hexadecimal string using ``os.urandom(32)``. Class construction sets the attributes ``phrase`` and ``hex`` - the 25 word mnemonic seed and it's hexadecimal representation. + + +.. code-block:: python + + In [1]: from monero.seed import Seed + + In [2]: s = Seed() + + In [3]: s.phrase + Out [3]: 'fewest lipstick auburn cocoa macro circle hurried impel macro hatchet jeopardy swung aloof spiders gags jaws abducts buying alpine athlete junk patio academy loudly academy' + + In [4]: s.hex + Out [4]: u'73192a945d7400a3a76a941be451a9623f37dd834006d02140a6a762b9142d80' + + +Supplying your own seed +------------------------ + +If you have an existing mnemonic word or hexadecimal seed that you would like to derive keys for, simply pass the seed as a string to the ``Seed`` class. Class construction will automatically detect the seed type and encode or decode to set both ``phrase`` and ``hex`` attributes. + +.. code-block:: python + + In [1]: from monero.seed import Seed + + In [2]: s = Seed("73192a945d7400a3a76a941be451a9623f37dd834006d02140a6a762b9142d80") + + In [3]: s.phrase + Out [3]: 'fewest lipstick auburn cocoa macro circle hurried impel macro hatchet jeopardy swung aloof spiders gags jaws abducts buying alpine athlete junk patio academy loudly academy' + + In [4]: s.hex + Out [4]: u'73192a945d7400a3a76a941be451a9623f37dd834006d02140a6a762b9142d80' + + + In [5]: p = Seed("fewest lipstick auburn cocoa macro circle hurried impel macro hatchet jeopardy swung aloof spiders gags jaws abducts buying alpine athlete junk patio academy loudly academy") + + In [6]: p.phrase + Out [6]: 'fewest lipstick auburn cocoa macro circle hurried impel macro hatchet jeopardy swung aloof spiders gags jaws abducts buying alpine athlete junk patio academy loudly academy' + + In [7]: p.hex + Out [7]: u'73192a945d7400a3a76a941be451a9623f37dd834006d02140a6a762b9142d80' + + +Deriving account keys +---------------------- + +Once the ``Seed`` class is constructed, you can derive `all of the keys`_ associated with the account. + +.. _all of the keys: https://getmonero.org/resources/moneropedia/account.html + +.. code-block:: python + + In [1]: from monero.seed import Seed + + In [2]: s = Seed("fewest lipstick auburn cocoa macro circle hurried impel macro hatchet jeopardy swung aloof spiders gags jaws abducts buying alpine athlete junk patio academy loudly academy") + + In [3]: s.secret_spend_key() + Out [3]: '0b7a7bac8a5b6de2f483d703ef82b1bb3e37dd834006d02140a6a762b9142d00' + + In [4]: s.secret_view_key() + Out [4]: '75ec665f4912cec813ff7f20bc75b1f375ee2f8d4bb7631ae8d1af302732a609' + + In [5]: s.public_spend_key() + Out [5]: 'd5db200426637399f0076090dea01394afc2b157f94d287516911dbbcf8b2275' + + In [6]: s.public_view_key() + Out [6]: 'cd235f236224b8a5f1e12568927e01a2879bfd49cec2517b0717adb97fe8ae39' + + In [7]: s.public_address() + Out [7]: '49j9ikUyGfkSkPV8TY66p2RsSs6xL7NR5LauJTt7y6LZLhpakUnjcddUksdDgccVPEUBk2obnM1YUMaXKsGsCnow7WYjktm' + + + + +API reference +------------- + +.. automodule:: monero.seed + :members: