From ad0d48d616a6026d03cbb588f5583de63a2aa05d Mon Sep 17 00:00:00 2001 From: axiom Date: Tue, 16 Jul 2024 16:52:15 +0300 Subject: [PATCH 1/2] Add: const docs --- docs/const.rst | 21 ++++++++++ docs/toctree.rst | 1 + hdwallet/const.py | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 docs/const.rst diff --git a/docs/const.rst b/docs/const.rst new file mode 100644 index 0000000..e4b0112 --- /dev/null +++ b/docs/const.rst @@ -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: diff --git a/docs/toctree.rst b/docs/toctree.rst index ea231bc..b9f0993 100644 --- a/docs/toctree.rst +++ b/docs/toctree.rst @@ -20,3 +20,4 @@ HDWallet Elliptic Curve Cryptographys (ECCs) Hierarchical Deterministic's (HD's) Addresses + Consts diff --git a/hdwallet/const.py b/hdwallet/const.py index e33861b..8a4b946 100644 --- a/hdwallet/const.py +++ b/hdwallet/const.py @@ -39,6 +39,19 @@ def __init__(self, data: Union[set, tuple, dict], **kwargs): class SLIP10_ED25519_CONST: + """ + ``SLIP10-ED25519`` Constants. + + +-------------------------+-----------+--------------+ + | Name | Type | Value | + +=========================+===========+==============+ + | PRIVATE_KEY_BYTE_LENGTH | ``int`` | 32 | + +-------------------------+-----------+--------------+ + | PUBLIC_KEY_PREFIX | ``bytes`` | ``0x00`` | + +-------------------------+-----------+--------------+ + | PUBLIC_KEY_BYTE_LENGTH | ``int`` | 32 | + +-------------------------+-----------+--------------+ + """ PRIVATE_KEY_BYTE_LENGTH: int = 32 PUBLIC_KEY_PREFIX: bytes = b"\x00" @@ -46,11 +59,43 @@ class SLIP10_ED25519_CONST: class KHOLAW_ED25519_CONST(SLIP10_ED25519_CONST): + """ + ``KHOLAW-ED25519`` Constants. + + +-------------------------+-----------+--------------+ + | Name | Type | Value | + +=========================+===========+==============+ + | PRIVATE_KEY_BYTE_LENGTH | ``int`` | 64 | + +-------------------------+-----------+--------------+ + | PUBLIC_KEY_PREFIX | ``bytes`` | ``0x00`` | + +-------------------------+-----------+--------------+ + | PUBLIC_KEY_BYTE_LENGTH | ``int`` | 32 | + +-------------------------+-----------+--------------+ + """ PRIVATE_KEY_BYTE_LENGTH: int = 64 class SLIP10_SECP256K1_CONST: + """ + ``SLIP10-SECP256K1`` Constants. + + +-------------------------------------+-----------------------------------+-------------+ + | Name | Type | Value | + +=====================================+===================================+=============+ + | USE | ``Literal['coincurve', 'ecdsa']`` | 'coincurve' | + +-------------------------------------+-----------------------------------+-------------+ + | POINT_COORDINATE_BYTE_LENGTH | ``int`` | 32 | + +-------------------------------------+-----------------------------------+-------------+ + | PRIVATE_KEY_BYTE_LENGTH | ``int`` | 32 | + +-------------------------------------+-----------------------------------+-------------+ + | PUBLIC_KEY_PREFIX | ``bytes`` | ``0x04`` | + +-------------------------------------+-----------------------------------+-------------+ + | PUBLIC_KEY_COMPRESSED_BYTE_LENGTH | ``int`` | 33 | + +-------------------------------------+-----------------------------------+-------------+ + | PUBLIC_KEY_UNCOMPRESSED_BYTE_LENGTH | ``int`` | 65 | + +-------------------------------------+-----------------------------------+-------------+ + """ USE: Literal["coincurve", "ecdsa"] = "coincurve" POINT_COORDINATE_BYTE_LENGTH: int = 32 @@ -166,36 +211,90 @@ class XPublicKeyVersions(ExtendedKeyVersions): class PUBLIC_KEY_TYPES: + """ + ``PUBLIC_KEY_TYPES`` Constants. + + +----------------+-----------+-----------------+ + | Name | Type | Value | + +================+===========+=================+ + | COMPRESSED | ``str`` | 'uncompressed' | + +----------------+-----------+-----------------+ + | UNCOMPRESSED | ``str`` | '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 | Type | Value | + +================+===========+==================+ + | WIF | ``str`` | 'wif' | + +----------------+-----------+------------------+ + | WIF_COMPRESSED | ``str`` | '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 | Type | Value | + +================+===========+=================+ + | STANDARD | ``str`` | 'standard' | + +----------------+-----------+-----------------+ + | SEGWIT | ``str`` | '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 ] From 684bab57cfb72df8c203fa97703050af1578f914 Mon Sep 17 00:00:00 2001 From: axiom Date: Wed, 17 Jul 2024 09:30:26 +0300 Subject: [PATCH 2/2] Drop: type column from const docs --- hdwallet/const.py | 108 +++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/hdwallet/const.py b/hdwallet/const.py index 8a4b946..002310a 100644 --- a/hdwallet/const.py +++ b/hdwallet/const.py @@ -42,15 +42,15 @@ class SLIP10_ED25519_CONST: """ ``SLIP10-ED25519`` Constants. - +-------------------------+-----------+--------------+ - | Name | Type | Value | - +=========================+===========+==============+ - | PRIVATE_KEY_BYTE_LENGTH | ``int`` | 32 | - +-------------------------+-----------+--------------+ - | PUBLIC_KEY_PREFIX | ``bytes`` | ``0x00`` | - +-------------------------+-----------+--------------+ - | PUBLIC_KEY_BYTE_LENGTH | ``int`` | 32 | - +-------------------------+-----------+--------------+ + +-------------------------+--------------+ + | Name | Value | + +=========================+==============+ + | PRIVATE_KEY_BYTE_LENGTH | 32 | + +-------------------------+--------------+ + | PUBLIC_KEY_PREFIX | ``0x00`` | + +-------------------------+--------------+ + | PUBLIC_KEY_BYTE_LENGTH | 32 | + +-------------------------+--------------+ """ PRIVATE_KEY_BYTE_LENGTH: int = 32 @@ -62,15 +62,15 @@ class KHOLAW_ED25519_CONST(SLIP10_ED25519_CONST): """ ``KHOLAW-ED25519`` Constants. - +-------------------------+-----------+--------------+ - | Name | Type | Value | - +=========================+===========+==============+ - | PRIVATE_KEY_BYTE_LENGTH | ``int`` | 64 | - +-------------------------+-----------+--------------+ - | PUBLIC_KEY_PREFIX | ``bytes`` | ``0x00`` | - +-------------------------+-----------+--------------+ - | PUBLIC_KEY_BYTE_LENGTH | ``int`` | 32 | - +-------------------------+-----------+--------------+ + +-------------------------+--------------+ + | Name | Value | + +=========================+==============+ + | PRIVATE_KEY_BYTE_LENGTH | 64 | + +-------------------------+--------------+ + | PUBLIC_KEY_PREFIX | ``0x00`` | + +-------------------------+--------------+ + | PUBLIC_KEY_BYTE_LENGTH | 32 | + +-------------------------+--------------+ """ PRIVATE_KEY_BYTE_LENGTH: int = 64 @@ -80,21 +80,21 @@ class SLIP10_SECP256K1_CONST: """ ``SLIP10-SECP256K1`` Constants. - +-------------------------------------+-----------------------------------+-------------+ - | Name | Type | Value | - +=====================================+===================================+=============+ - | USE | ``Literal['coincurve', 'ecdsa']`` | 'coincurve' | - +-------------------------------------+-----------------------------------+-------------+ - | POINT_COORDINATE_BYTE_LENGTH | ``int`` | 32 | - +-------------------------------------+-----------------------------------+-------------+ - | PRIVATE_KEY_BYTE_LENGTH | ``int`` | 32 | - +-------------------------------------+-----------------------------------+-------------+ - | PUBLIC_KEY_PREFIX | ``bytes`` | ``0x04`` | - +-------------------------------------+-----------------------------------+-------------+ - | PUBLIC_KEY_COMPRESSED_BYTE_LENGTH | ``int`` | 33 | - +-------------------------------------+-----------------------------------+-------------+ - | PUBLIC_KEY_UNCOMPRESSED_BYTE_LENGTH | ``int`` | 65 | - +-------------------------------------+-----------------------------------+-------------+ + +-------------------------------------+-------------+ + | 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" @@ -214,13 +214,13 @@ class PUBLIC_KEY_TYPES: """ ``PUBLIC_KEY_TYPES`` Constants. - +----------------+-----------+-----------------+ - | Name | Type | Value | - +================+===========+=================+ - | COMPRESSED | ``str`` | 'uncompressed' | - +----------------+-----------+-----------------+ - | UNCOMPRESSED | ``str`` | 'compressed' | - +----------------+-----------+-----------------+ + +----------------+-----------------+ + | Name | Value | + +================+=================+ + | COMPRESSED | 'uncompressed' | + +----------------+-----------------+ + | UNCOMPRESSED | 'compressed' | + +----------------+-----------------+ """ UNCOMPRESSED: str = "uncompressed" @@ -244,13 +244,13 @@ class WIF_TYPES: """ ``WIF_TYPES`` Constants. - +----------------+-----------+------------------+ - | Name | Type | Value | - +================+===========+==================+ - | WIF | ``str`` | 'wif' | - +----------------+-----------+------------------+ - | WIF_COMPRESSED | ``str`` | 'wif-compressed' | - +----------------+-----------+------------------+ + +----------------+------------------+ + | Name | Value | + +================+==================+ + | WIF | 'wif' | + +----------------+------------------+ + | WIF_COMPRESSED | 'wif-compressed' | + +----------------+------------------+ """ WIF: str = "wif" @@ -274,13 +274,13 @@ class ELECTRUM_V2_MODES: """ ``PUBLIC_KEY_TYPES`` Constants. - +----------------+-----------+-----------------+ - | Name | Type | Value | - +================+===========+=================+ - | STANDARD | ``str`` | 'standard' | - +----------------+-----------+-----------------+ - | SEGWIT | ``str`` | 'segwit' | - +----------------+-----------+-----------------+ + +----------------+-----------------+ + | Name | Value | + +================+=================+ + | STANDARD | 'standard' | + +----------------+-----------------+ + | SEGWIT | 'segwit' | + +----------------+-----------------+ """ STANDARD: str = "standard"