Skip to content

Commit

Permalink
Merge pull request #29 from chainxlab/axiom90/const-docs
Browse files Browse the repository at this point in the history
Axiom90/const docs
  • Loading branch information
meherett authored Jul 18, 2024
2 parents 386af5f + 684bab5 commit 5478171
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/const.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
=====
Const
=====

.. autoclass:: hdwallet.const.SLIP10_ED25519_CONST
:members:

.. autoclass:: hdwallet.const.KHOLAW_ED25519_CONST
:members:

.. autoclass:: hdwallet.const.SLIP10_SECP256K1_CONST
:members:

.. autoclass:: hdwallet.const.PUBLIC_KEY_TYPES
:members:

.. autoclass:: hdwallet.const.WIF_TYPES
:members:

.. autoclass:: hdwallet.const.ELECTRUM_V2_MODES
:members:
1 change: 1 addition & 0 deletions docs/toctree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ HDWallet
Elliptic Curve Cryptographys (ECCs) <ecc.rst>
Hierarchical Deterministic's (HD's) <hds.rst>
Addresses <addresses.rst>
Consts <const.rst>
99 changes: 99 additions & 0 deletions hdwallet/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,63 @@ def __init__(self, data: Union[set, tuple, dict], **kwargs):


class SLIP10_ED25519_CONST:
"""
``SLIP10-ED25519`` Constants.
+-------------------------+--------------+
| Name | Value |
+=========================+==============+
| PRIVATE_KEY_BYTE_LENGTH | 32 |
+-------------------------+--------------+
| PUBLIC_KEY_PREFIX | ``0x00`` |
+-------------------------+--------------+
| PUBLIC_KEY_BYTE_LENGTH | 32 |
+-------------------------+--------------+
"""

PRIVATE_KEY_BYTE_LENGTH: int = 32
PUBLIC_KEY_PREFIX: bytes = b"\x00"
PUBLIC_KEY_BYTE_LENGTH: int = 32


class KHOLAW_ED25519_CONST(SLIP10_ED25519_CONST):
"""
``KHOLAW-ED25519`` Constants.
+-------------------------+--------------+
| Name | Value |
+=========================+==============+
| PRIVATE_KEY_BYTE_LENGTH | 64 |
+-------------------------+--------------+
| PUBLIC_KEY_PREFIX | ``0x00`` |
+-------------------------+--------------+
| PUBLIC_KEY_BYTE_LENGTH | 32 |
+-------------------------+--------------+
"""

PRIVATE_KEY_BYTE_LENGTH: int = 64


class SLIP10_SECP256K1_CONST:
"""
``SLIP10-SECP256K1`` Constants.
+-------------------------------------+-------------+
| Name | Value |
+=====================================+=============+
| USE | 'coincurve' |
+-------------------------------------+-------------+
| POINT_COORDINATE_BYTE_LENGTH | 32 |
+-------------------------------------+-------------+
| PRIVATE_KEY_BYTE_LENGTH | 32 |
+-------------------------------------+-------------+
| PUBLIC_KEY_PREFIX | ``0x04`` |
+-------------------------------------+-------------+
| PUBLIC_KEY_COMPRESSED_BYTE_LENGTH | 33 |
+-------------------------------------+-------------+
| PUBLIC_KEY_UNCOMPRESSED_BYTE_LENGTH | 65 |
+-------------------------------------+-------------+
"""

USE: Literal["coincurve", "ecdsa"] = "coincurve"
POINT_COORDINATE_BYTE_LENGTH: int = 32
Expand Down Expand Up @@ -166,36 +211,90 @@ class XPublicKeyVersions(ExtendedKeyVersions):


class PUBLIC_KEY_TYPES:
"""
``PUBLIC_KEY_TYPES`` Constants.
+----------------+-----------------+
| Name | Value |
+================+=================+
| COMPRESSED | 'uncompressed' |
+----------------+-----------------+
| UNCOMPRESSED | 'compressed' |
+----------------+-----------------+
"""

UNCOMPRESSED: str = "uncompressed"
COMPRESSED: str = "compressed"

@classmethod
def get_types(cls) -> List[str]:
"""
Get a list of all public key types.
:return: List of public key types.
:rtype: List[str]
"""

return [
cls.UNCOMPRESSED, cls.COMPRESSED
]


class WIF_TYPES:
"""
``WIF_TYPES`` Constants.
+----------------+------------------+
| Name | Value |
+================+==================+
| WIF | 'wif' |
+----------------+------------------+
| WIF_COMPRESSED | 'wif-compressed' |
+----------------+------------------+
"""

WIF: str = "wif"
WIF_COMPRESSED: str = "wif-compressed"

@classmethod
def get_types(cls) -> List[str]:
"""
Get a list of all WIF types.
:return: List of WIF types.
:rtype: List[str]
"""

return [
cls.WIF, cls.WIF_COMPRESSED
]


class ELECTRUM_V2_MODES:
"""
``PUBLIC_KEY_TYPES`` Constants.
+----------------+-----------------+
| Name | Value |
+================+=================+
| STANDARD | 'standard' |
+----------------+-----------------+
| SEGWIT | 'segwit' |
+----------------+-----------------+
"""

STANDARD: str = "standard"
SEGWIT: str = "segwit"

@classmethod
def get_modes(cls) -> List[str]:
"""
Get a list of all Electrum V2 modes.
:return: List of Electrum V2 modes.
:rtype: List[str]
"""

return [
cls.STANDARD, cls.SEGWIT
]
Expand Down

0 comments on commit 5478171

Please sign in to comment.