libcrypto 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,318 @@
1
+ Metadata-Version: 2.4
2
+ Name: libcrypto
3
+ Version: 1.0.1
4
+ Summary: A professional library For Cryptography and Cryptocurrencies in Python.
5
+ Home-page: https://github.com/pymmdrza/libcrypto
6
+ Author: Mmdrza
7
+ Author-email: Mmdrza <pymmdrza@gmail.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://libcrypto.readthedocs.io/
10
+ Project-URL: Repository, https://github.com/Pymmdrza/libcrypto
11
+ Project-URL: Bug Tracker, https://github.com/Pymmdrza/libcrypto/issues
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: Security :: Cryptography
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: pycryptodome
26
+ Requires-Dist: ecdsa
27
+ Requires-Dist: rich
28
+ Requires-Dist: typer
29
+ Dynamic: author
30
+ Dynamic: home-page
31
+ Dynamic: license-file
32
+ Dynamic: requires-python
33
+
34
+ # LibCrypto - Cryptocurrency Wallet Library
35
+
36
+ A comprehensive, self-contained Python cryptocurrency wallet library that provides all necessary tools for generating and managing cryptocurrency wallet keys and addresses **without any external dependencies**.
37
+
38
+ ## 🚀 Features
39
+
40
+ ### Core Functionality
41
+ - **BIP39 Mnemonic Phrases**: Generate and validate secure mnemonic phrases (12, 15, 18, 21, 24 words)
42
+ - **BIP32 HD Wallets**: Hierarchical deterministic wallet support with full BIP44 compliance
43
+ - **Multi-Currency Support**: Generate addresses for 13+ cryptocurrencies
44
+ - **Key Format Conversions**: Convert between hex, WIF, bytes, decimal, and mnemonic formats
45
+ - **Zero Dependencies**: Uses only Python standard library and included C extensions
46
+
47
+ ### Supported Cryptocurrencies
48
+ - **Bitcoin (BTC)** - P2PKH, P2SH, P2WPKH, P2WSH (SegWit)
49
+ - **Ethereum (ETH)** - Native addresses with EIP-55 checksum
50
+ - **Litecoin (LTC)** - All Bitcoin-compatible formats
51
+ - **Bitcoin Cash (BCH)** - Legacy and CashAddr formats
52
+ - **Bitcoin Gold (BTG)** - All standard formats
53
+ - **Dogecoin (DOGE)** - P2PKH and P2SH
54
+ - **Dash** - P2PKH and P2SH
55
+ - **Digibyte (DGB)** - All standard formats
56
+ - **Zcash (ZEC)** - T-addresses
57
+ - **Tron (TRX)** - Native TRX addresses
58
+ - **Solana (SOL)** - Base58 encoded addresses
59
+ - **Avalanche (AVAX)** - C-Chain addresses
60
+ - **TON** - Native TON addresses
61
+ - **Ripple (XRP)** - Classic addresses
62
+
63
+ ### Address Formats
64
+ - **P2PKH**: Pay to Public Key Hash (1...)
65
+ - **P2SH**: Pay to Script Hash (3...)
66
+ - **P2WPKH**: Pay to Witness Public Key Hash (bc1...)
67
+ - **P2WSH**: Pay to Witness Script Hash (bc1...)
68
+ - **Ethereum**: Keccak256-based addresses (0x...)
69
+
70
+ ## 📦 Installation
71
+
72
+ ```bash
73
+ # Clone the repository
74
+ git clone <repository-url>
75
+ cd libcrypto
76
+
77
+ # Install in development mode
78
+ pip install -e .
79
+ ```
80
+
81
+ ## 🔧 Quick Start
82
+
83
+ ### Generate a New Mnemonic and Wallet
84
+
85
+ ```python
86
+ import mnemonic
87
+ from wallet import HDWallet, PrivateKey, AddressGenerator
88
+
89
+ # Generate a new 12-word mnemonic
90
+ new_mnemonic = mnemonic.generate_mnemonic(12)
91
+ print(f"Generated mnemonic: {new_mnemonic}")
92
+
93
+ # Create HD wallet from mnemonic
94
+ wallet = HDWallet.from_mnemonic(new_mnemonic)
95
+
96
+ # Get Bitcoin address (BIP44 path: m/44'/0'/0'/0/0)
97
+ btc_key = wallet.derive_address_key(coin_type=0, address_index=0)
98
+ btc_address = AddressGenerator.from_public_key(
99
+ btc_key.public_key, 'p2pkh', 'bitcoin'
100
+ )
101
+ print(f"Bitcoin address: {btc_address}")
102
+
103
+ # Get Ethereum address (BIP44 path: m/44'/60'/0'/0/0)
104
+ eth_key = wallet.derive_address_key(coin_type=60, address_index=0)
105
+ eth_address = AddressGenerator.from_public_key(
106
+ eth_key.public_key, 'ethereum', 'ethereum'
107
+ )
108
+ print(f"Ethereum address: {eth_address}")
109
+ ```
110
+
111
+ ### Import Existing Mnemonic
112
+
113
+ ```python
114
+ import mnemonic
115
+ from wallet import HDWallet
116
+
117
+ # Import existing mnemonic
118
+ existing_mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
119
+
120
+ # Validate mnemonic
121
+ if mnemonic.validate_mnemonic(existing_mnemonic):
122
+ print("✅ Mnemonic is valid")
123
+
124
+ # Create wallet
125
+ wallet = HDWallet.from_mnemonic(existing_mnemonic)
126
+
127
+ # Get master keys
128
+ print(f"Master private key: {wallet.get_master_private_key()}")
129
+ print(f"Master public key: {wallet.get_master_public_key()}")
130
+ else:
131
+ print("❌ Invalid mnemonic")
132
+ ```
133
+
134
+ ### Private Key Operations
135
+
136
+ ```python
137
+ from wallet import PrivateKey
138
+
139
+ # Generate a new private key
140
+ private_key = PrivateKey.generate()
141
+
142
+ # Convert to different formats
143
+ print(f"Hex: {private_key.hex}")
144
+ print(f"WIF: {private_key.to_wif()}")
145
+ print(f"Decimal: {private_key.decimal}")
146
+
147
+ # Get public key and address
148
+ public_key = private_key.get_public_key()
149
+ btc_address = public_key.get_address('p2pkh', 'bitcoin')
150
+ print(f"Bitcoin address: {btc_address}")
151
+
152
+ # Import from hex
153
+ hex_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
154
+ imported_key = PrivateKey.from_hex(hex_key)
155
+ print(f"Imported key WIF: {imported_key.to_wif()}")
156
+ ```
157
+
158
+ ### Multiple Address Generation
159
+
160
+ ```python
161
+ from wallet import HDWallet, AddressGenerator
162
+
163
+ # Create wallet from mnemonic
164
+ mnemonic_phrase = "your twelve word mnemonic phrase goes here example test words"
165
+ wallet = HDWallet.from_mnemonic(mnemonic_phrase)
166
+
167
+ # Generate first 5 Bitcoin addresses
168
+ for i in range(5):
169
+ key = wallet.derive_address_key(coin_type=0, address_index=i)
170
+
171
+ # Generate different Bitcoin address formats
172
+ p2pkh = AddressGenerator.from_public_key(key.public_key, 'p2pkh', 'bitcoin')
173
+ p2wpkh = AddressGenerator.from_public_key(key.public_key, 'p2wpkh', 'bitcoin')
174
+
175
+ print(f"Address {i}:")
176
+ print(f" P2PKH: {p2pkh}")
177
+ print(f" P2WPKH: {p2wpkh}")
178
+ ```
179
+
180
+ ### Multi-Currency Wallet
181
+
182
+ ```python
183
+ from wallet import HDWallet, AddressGenerator
184
+ from Util.constants import BIP44_COIN_TYPES
185
+
186
+ # Create wallet
187
+ wallet = HDWallet.from_mnemonic("your mnemonic here")
188
+
189
+ # Generate addresses for different cryptocurrencies
190
+ currencies = ['bitcoin', 'ethereum', 'litecoin', 'dogecoin']
191
+
192
+ for currency in currencies:
193
+ coin_type = BIP44_COIN_TYPES[currency]
194
+ key = wallet.derive_address_key(coin_type=coin_type, address_index=0)
195
+
196
+ if currency == 'ethereum':
197
+ address = AddressGenerator.from_public_key(key.public_key, 'ethereum', 'ethereum')
198
+ else:
199
+ address = AddressGenerator.from_public_key(key.public_key, 'p2pkh', currency)
200
+
201
+ print(f"{currency.capitalize()}: {address}")
202
+ ```
203
+
204
+ ## API Overview
205
+
206
+ ### Mnemonic Module (`mnemonic.py`)
207
+ - `generate_mnemonic(word_count)` - Generate new mnemonic
208
+ - `validate_mnemonic(mnemonic)` - Validate existing mnemonic
209
+ - `mnemonic_to_seed(mnemonic, passphrase)` - Convert to seed
210
+
211
+ ### HD Wallet (`wallet.HDWallet`)
212
+ - `from_mnemonic(mnemonic, passphrase, network)` - Create from mnemonic
213
+ - `derive_account(coin_type, account)` - Derive account key
214
+ - `derive_address_key(coin_type, account, change, address_index)` - Derive address key
215
+
216
+ ### Private Key (`wallet.PrivateKey`)
217
+ - `generate(network)` - Generate new key
218
+ - `from_hex(hex_str, network)` - Import from hex
219
+ - `from_wif(wif)` - Import from WIF
220
+ - `to_wif(compressed)` - Export to WIF
221
+ - `get_public_key(compressed)` - Get public key
222
+
223
+ ### Public Key (`wallet.PublicKey`)
224
+ - `from_hex(hex_str, compressed)` - Import from hex
225
+ - `get_address(address_type, network)` - Generate address
226
+ - `to_compressed()` / `to_uncompressed()` - Format conversion
227
+
228
+ ### Address Generator (`wallet.AddressGenerator`)
229
+ - `from_public_key(public_key, address_type, network)` - Generate address
230
+ - `generate_multiple_formats(public_key, network)` - All formats
231
+ - `validate_address(address, network)` - Validate address
232
+
233
+ ## Security Features
234
+
235
+ - **Cryptographically Secure**: Uses `secrets` module for random number generation
236
+ - **Proper Entropy**: Validates entropy for mnemonic generation
237
+ - **Checksum Validation**: All mnemonics include BIP39 checksum verification
238
+ - **Constant-Time Operations**: Where possible, uses constant-time implementations
239
+ - **Zero External Dependencies**: Reduces attack surface by avoiding third-party libraries
240
+
241
+
242
+
243
+ ## Advanced Usage
244
+
245
+ ### Custom Derivation Paths
246
+
247
+ ```python
248
+ from wallet import HDWallet
249
+
250
+ wallet = HDWallet.from_mnemonic("your mnemonic")
251
+
252
+ # Custom derivation path
253
+ custom_path = "m/44'/0'/0'/0/5" # 6th address
254
+ custom_key = wallet.master_node.derive_path(custom_path)
255
+
256
+ # Account-level derivation for exchange integration
257
+ account_key = wallet.derive_account(coin_type=0, account=1) # Second account
258
+ ```
259
+
260
+ ### Batch Address Generation
261
+
262
+ ```python
263
+ from wallet import HDWallet, AddressGenerator
264
+
265
+ def generate_address_batch(mnemonic, coin_type, count=100):
266
+ """Generate a batch of addresses efficiently."""
267
+ wallet = HDWallet.from_mnemonic(mnemonic)
268
+ addresses = []
269
+
270
+ for i in range(count):
271
+ key = wallet.derive_address_key(coin_type=coin_type, address_index=i)
272
+ address = AddressGenerator.from_public_key(key.public_key, 'p2pkh', 'bitcoin')
273
+ addresses.append({
274
+ 'index': i,
275
+ 'address': address,
276
+ 'private_key': key.private_key.hex(),
277
+ 'public_key': key.public_key.hex()
278
+ })
279
+
280
+ return addresses
281
+
282
+ # Generate first 100 Bitcoin addresses
283
+ btc_addresses = generate_address_batch("your mnemonic", coin_type=0, count=100)
284
+ ```
285
+
286
+ ## Performance
287
+
288
+ Typical performance on modern hardware:
289
+ - **Mnemonic generation**: < 100ms
290
+ - **Address generation**: < 50ms per address
291
+ - **Key derivation**: < 200ms for complex paths
292
+ - **Memory usage**: < 50MB for typical operations
293
+
294
+ ## Contributing
295
+
296
+ 1. Fork the repository
297
+ 2. Create a feature branch
298
+ 3. Make your changes
299
+ 4. Add tests for new functionality
300
+ 5. Submit a pull request
301
+
302
+ ## License
303
+
304
+ This project is licensed under the MIT License - see the LICENSE file for details.
305
+
306
+ ## Standards Compliance
307
+
308
+ - **BIP-39**: Mnemonic code for generating deterministic keys
309
+ - **BIP-32**: Hierarchical Deterministic (HD) Wallets
310
+ - **BIP-44**: Multi-Account Hierarchy for Deterministic Wallets
311
+ - **EIP-55**: Mixed-case checksum address encoding (Ethereum)
312
+ - **RFC-6979**: Deterministic Usage of DSA and ECDSA
313
+
314
+
315
+ ---
316
+
317
+ **LibCrypto** - Professional Cryptocurrency Wallet Library with Zero Dependencies
318
+
@@ -0,0 +1,18 @@
1
+ libcrypto/__init__.py,sha256=IIlgCxgdRP3t_O28bO-gH3xCaipVK1Vl0vZv-NNe6RQ,1520
2
+ libcrypto/_version.py,sha256=DSDyLW2lPzd96MgdTJ1v2YoJcpnh3k-GDDmngzKiFdA,485
3
+ libcrypto/addresses.py,sha256=_rwJbuIJA9Pt-mD7SpEHoUCyNlC0ghXURLI71ZDKTJA,7491
4
+ libcrypto/bip32.py,sha256=uzhd0l9FPgNRWzpfhcpZedyJo48y6UrrB_1cPVeoW7E,8466
5
+ libcrypto/cli.py,sha256=JU_q0WQ03bX9q2DwNdGzvRKv7FSB6g9nw9GmTsbE7fw,5733
6
+ libcrypto/constants.py,sha256=nzBgMErTnlTN3Ibya9T2aAKRMb-14z0u5ZtrEUBpzPA,23087
7
+ libcrypto/formats.py,sha256=gfxf1SkJ-xn-CuuNQM4prkl4mtg9ef2zl5K5G8_X85g,5305
8
+ libcrypto/hash.py,sha256=f9Rt89n9LbZ8i77uPaXK0ZUFhTMEuf4ux1mSVKy-i-8,2326
9
+ libcrypto/keys.py,sha256=_HIoHrGcoHTqJ2qQsZroTHEexyLIM5Mn5t9eMMMdqP4,5051
10
+ libcrypto/mnemonic.py,sha256=cmHFX1B4YGGN3pIaFDuffrpKKkTCAXya5W58oA77KBk,4677
11
+ libcrypto/secp256k1.py,sha256=4FH_byTr2fXms4q3BtSHVBs-4NPE2gyDaS_lS4oeDWw,3873
12
+ libcrypto/wallet.py,sha256=LWjhwKe7nKonB6oaKOggMdPstIrXYKJhJcYPCcKqU6c,5835
13
+ libcrypto-1.0.1.dist-info/licenses/LICENSE,sha256=VmwUVixn0u8rR_TF0dIoqv7CK0a5WBoFX8zQvIYa4eE,1071
14
+ libcrypto-1.0.1.dist-info/METADATA,sha256=_WhWWgV3pQqhHeopK6C6ZviCCALacQmtV2uF6a1CSH8,10299
15
+ libcrypto-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ libcrypto-1.0.1.dist-info/entry_points.txt,sha256=P1JmZQ0W2Mi9rD37f9yFG2hYxGInDUY9i9erY_hldTY,48
17
+ libcrypto-1.0.1.dist-info/top_level.txt,sha256=CP4_HN2d5lfT-Jo0IQgNdbGYjk4PSDHK0EU4xfaKmGc,10
18
+ libcrypto-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ libcrypto = libcrypto.cli:app
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 LibCrypto Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ libcrypto