hippius 0.1.0__py3-none-any.whl → 0.1.7__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.
@@ -1,21 +1,22 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hippius
3
- Version: 0.1.0
3
+ Version: 0.1.7
4
4
  Summary: Python SDK and CLI for Hippius blockchain storage
5
5
  Home-page: https://github.com/thenervelab/hippius-sdk
6
6
  Author: Dubs
7
7
  Author-email: dubs@dubs.rs
8
- Requires-Python: >=3.8,<4.0
8
+ Requires-Python: >=3.8, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*
9
9
  Classifier: Development Status :: 3 - Alpha
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.9
17
17
  Provides-Extra: clipboard
18
18
  Requires-Dist: base58 (>=2.1.1,<3.0.0)
19
+ Requires-Dist: cryptography (>=44.0.0,<45.0.0)
19
20
  Requires-Dist: ipfshttpclient (>=0.7.0,<0.8.0)
20
21
  Requires-Dist: pydantic (>=2.0.0,<3.0.0)
21
22
  Requires-Dist: pynacl (>=1.5.0,<2.0.0)
@@ -23,6 +24,7 @@ Requires-Dist: pyperclip (>=1.8.2,<2.0.0) ; extra == "clipboard"
23
24
  Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
24
25
  Requires-Dist: requests (>=2.28.1,<3.0.0)
25
26
  Requires-Dist: substrate-interface (>=1.4.2,<2.0.0)
27
+ Requires-Dist: zfec (>=1.5.3,<2.0.0)
26
28
  Project-URL: Documentation, https://github.com/thenervelab/hippius-sdk/docs
27
29
  Project-URL: Repository, https://github.com/thenervelab/hippius-sdk
28
30
  Description-Content-Type: text/markdown
@@ -65,7 +67,7 @@ client = HippiusClient()
65
67
  # Or specify custom endpoints
66
68
  client = HippiusClient(
67
69
  ipfs_gateway="https://ipfs.io", # For downloads (default)
68
- ipfs_api_url="http://relay-fr.hippius.network:5001", # For uploads (default)
70
+ ipfs_api_url="https://relay-fr.hippius.network", # For uploads (default)
69
71
  )
70
72
 
71
73
  # Upload a file to IPFS
@@ -172,6 +174,167 @@ raw_result = client.download_file(encrypted_result['cid'], "still_encrypted.txt"
172
174
  content = client.cat(encrypted_result['cid'], decrypt=True)
173
175
  ```
174
176
 
177
+ ## Erasure Coding
178
+
179
+ Hippius SDK supports Reed-Solomon erasure coding for reliable and resilient file storage. This allows files to be split into chunks with added redundancy, so that the original file can be reconstructed even if some chunks are lost.
180
+
181
+ ### Erasure Coding Concepts
182
+
183
+ - **k**: The number of data chunks needed to reconstruct the original file
184
+ - **m**: The total number of chunks created (m > k)
185
+ - The file can be reconstructed from any k chunks out of m total chunks
186
+ - Higher redundancy (m-k) provides better protection against chunk loss
187
+
188
+ ### Using Erasure Coding
189
+
190
+ ```python
191
+ from hippius_sdk import HippiusClient
192
+
193
+ client = HippiusClient()
194
+
195
+ # Erasure code a file with default parameters (k=3, m=5)
196
+ result = client.erasure_code_file("large_file.mp4")
197
+ metadata_cid = result["metadata_cid"]
198
+
199
+ # Use custom parameters for more redundancy
200
+ result = client.erasure_code_file(
201
+ file_path="important_data.zip",
202
+ k=4, # Need 4 chunks to reconstruct
203
+ m=10, # Create 10 chunks total (6 redundant)
204
+ chunk_size=2097152, # 2MB chunks
205
+ encrypt=True # Encrypt before splitting
206
+ )
207
+
208
+ # Store erasure-coded file in Hippius marketplace
209
+ result = client.store_erasure_coded_file(
210
+ file_path="critical_backup.tar",
211
+ k=3,
212
+ m=5,
213
+ encrypt=True,
214
+ miner_ids=["miner1", "miner2", "miner3"]
215
+ )
216
+
217
+ # Reconstruct a file from its metadata
218
+ reconstructed_path = client.reconstruct_from_erasure_code(
219
+ metadata_cid=metadata_cid,
220
+ output_file="reconstructed_file.mp4"
221
+ )
222
+ ```
223
+
224
+ ### When to Use Erasure Coding
225
+
226
+ Erasure coding is particularly useful for:
227
+
228
+ - Large files where reliability is critical
229
+ - Long-term archival storage
230
+ - Data that must survive partial network failures
231
+ - Situations where higher redundancy is needed without full replication
232
+
233
+ ### Advanced Features
234
+
235
+ #### Small File Handling
236
+
237
+ The SDK automatically adjusts parameters for small files:
238
+
239
+ - If a file is too small to be split into `k` chunks, the SDK will adjust the chunk size
240
+ - For very small files, the content is split into exactly `k` sub-blocks
241
+ - Parameters are always optimized to provide the requested level of redundancy
242
+
243
+ #### Robust Storage in Marketplace
244
+
245
+ When using `store_erasure_coded_file`, the SDK now:
246
+
247
+ - Stores both the metadata file AND all encoded chunks in the marketplace
248
+ - Ensures miners can access all necessary data for redundancy and retrieval
249
+ - Reports total number of files stored for verification
250
+
251
+ #### CLI Commands
252
+
253
+ The CLI provides powerful commands for erasure coding:
254
+
255
+ ```bash
256
+ # Basic usage with automatic parameter adjustment
257
+ hippius erasure-code myfile.txt
258
+
259
+ # Specify custom parameters
260
+ hippius erasure-code large_video.mp4 --k 4 --m 8 --chunk-size 4194304
261
+
262
+ # For smaller files, using smaller parameters
263
+ hippius erasure-code small_doc.txt --k 2 --m 5 --chunk-size 4096
264
+
265
+ # Reconstruct a file from its metadata CID
266
+ hippius reconstruct QmMetadataCID reconstructed_file.mp4
267
+ ```
268
+
269
+ The CLI provides detailed output during the process, including:
270
+ - Automatic parameter adjustments for optimal encoding
271
+ - Progress of chunk creation and upload
272
+ - Storage confirmation in the marketplace
273
+ - Instructions for reconstruction
274
+
275
+ #### Erasure Coding
276
+
277
+ Erasure coding offers redundancy by splitting files into chunks:
278
+
279
+ ```bash
280
+ # Basic erasure coding with default parameters (k=3, m=5)
281
+ hippius erasure-code my_large_file.zip
282
+
283
+ # Erasure code with custom parameters for increased redundancy
284
+ hippius erasure-code my_important_file.mp4 --k 4 --m 10 --chunk-size 2097152 --encrypt
285
+ ```
286
+
287
+ To reconstruct a file from erasure-coded chunks:
288
+
289
+ ```bash
290
+ hippius reconstruct QmMetadataCID reconstructed_filename
291
+ ```
292
+
293
+ #### Listing Erasure Coded Files
294
+
295
+ To view only your erasure-coded files:
296
+
297
+ ```bash
298
+ # List all erasure-coded files
299
+ hippius ec-files
300
+
301
+ # Show all miners for each erasure-coded file
302
+ hippius ec-files --all-miners
303
+
304
+ # Show associated chunks for each erasure-coded file
305
+ hippius ec-files --show-chunks
306
+ ```
307
+
308
+ This command provides detailed information about each erasure-coded file including:
309
+ - Original file name
310
+ - Metadata CID
311
+ - File size
312
+ - Number of chunks
313
+ - Miners storing the file
314
+ - Reconstruction command
315
+
316
+ #### Troubleshooting
317
+
318
+ 1. **IPFS Connection Issues**: Make sure you have either:
319
+ - A local IPFS daemon running (`ipfs daemon` in a separate terminal)
320
+ - Or proper environment variables set in `.env` for remote connections
321
+
322
+ 2. **Missing Dependencies**: If you get import errors, ensure all dependencies are installed:
323
+ ```bash
324
+ poetry install --all-extras
325
+ ```
326
+
327
+ 3. **CLI Not Found**: If the `hippius` command isn't found after installing, try:
328
+ ```bash
329
+ # Verify it's installed
330
+ poetry show hippius
331
+
332
+ # Check your PATH
333
+ which hippius
334
+ ```
335
+
336
+ 4. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
337
+
175
338
  ## Command Line Interface
176
339
 
177
340
  The Hippius SDK includes a powerful command-line interface (CLI) that provides access to all major features of the SDK directly from your terminal.
@@ -222,6 +385,12 @@ hippius files 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
222
385
 
223
386
  # Show all miners for each file
224
387
  hippius files --all-miners
388
+
389
+ # View only erasure-coded files
390
+ hippius ec-files
391
+
392
+ # View erasure-coded files with details about chunks
393
+ hippius ec-files --show-chunks
225
394
  ```
226
395
 
227
396
  ### Encryption
@@ -240,6 +409,30 @@ hippius store my_file.txt --encrypt
240
409
  hippius download QmCID123 output_file.txt --decrypt
241
410
  ```
242
411
 
412
+ ### Erasure Coding
413
+
414
+ ```bash
415
+ # Erasure code a file with default parameters (k=3, m=5)
416
+ hippius erasure-code large_file.mp4
417
+
418
+ # Erasure code with custom parameters
419
+ hippius erasure-code important_data.zip --k 4 --m 10 --chunk-size 2097152 --encrypt
420
+
421
+ # Reconstruct a file from its metadata
422
+ hippius reconstruct QmMetadataCID reconstructed_file.mp4
423
+
424
+ # List all your erasure-coded files with metadata CIDs
425
+ hippius ec-files
426
+
427
+ # Show all miners for each erasure-coded file
428
+ hippius ec-files --all-miners
429
+
430
+ # Show detailed information including associated chunks
431
+ hippius ec-files --show-chunks
432
+ ```
433
+
434
+ The `ec-files` command makes it easy to track and manage your erasure-coded files separately from regular files. It provides the metadata CID needed for reconstruction and information about chunk distribution.
435
+
243
436
  ### Using Environment Variables
244
437
 
245
438
  The CLI automatically reads from your `.env` file for common settings:
@@ -320,6 +513,87 @@ The SDK provides robust connection handling for IPFS:
320
513
 
321
514
  This dual approach ensures maximum compatibility across different environments. The fallback happens automatically, so you don't need to worry about it.
322
515
 
516
+ ## Configuration
517
+
518
+ Hippius SDK now supports persistent configuration stored in your home directory at `~/.hippius/config.json`. This makes it easier to manage your settings without having to specify them each time or maintain environment variables.
519
+
520
+ ### Configuration Management
521
+
522
+ The configuration file is automatically created with default values when you first use the SDK. You can manage it using the CLI:
523
+
524
+ ```bash
525
+ # List all configuration settings
526
+ hippius config list
527
+
528
+ # Get a specific configuration value
529
+ hippius config get ipfs gateway
530
+
531
+ # Set a configuration value
532
+ hippius config set ipfs gateway https://ipfs.io
533
+
534
+ # Import settings from your .env file
535
+ hippius config import-env
536
+
537
+ # Reset configuration to default values
538
+ hippius config reset
539
+ ```
540
+
541
+ ### Configuration Structure
542
+
543
+ The configuration is organized in the following sections:
544
+
545
+ ```json
546
+ {
547
+ "ipfs": {
548
+ "gateway": "https://ipfs.io",
549
+ "api_url": "https://relay-fr.hippius.network",
550
+ "local_ipfs": false
551
+ },
552
+ "substrate": {
553
+ "url": "wss://rpc.hippius.network",
554
+ "seed_phrase": null,
555
+ "default_miners": []
556
+ },
557
+ "encryption": {
558
+ "encrypt_by_default": false,
559
+ "encryption_key": null
560
+ },
561
+ "erasure_coding": {
562
+ "default_k": 3,
563
+ "default_m": 5,
564
+ "default_chunk_size": 1048576
565
+ },
566
+ "cli": {
567
+ "verbose": false,
568
+ "max_retries": 3
569
+ }
570
+ }
571
+ ```
572
+
573
+ ### Environment Variables and Configuration
574
+
575
+ The SDK still supports environment variables for backward compatibility. You can import settings from your `.env` file to the configuration using:
576
+
577
+ ```bash
578
+ hippius config import-env
579
+ ```
580
+
581
+ ### Using Configuration in Code
582
+
583
+ ```python
584
+ from hippius_sdk import get_config_value, set_config_value, HippiusClient
585
+
586
+ # Get a configuration value
587
+ gateway = get_config_value("ipfs", "gateway")
588
+ print(f"Current gateway: {gateway}")
589
+
590
+ # Set a configuration value
591
+ set_config_value("ipfs", "gateway", "https://dweb.link")
592
+
593
+ # Client will automatically use configuration values
594
+ client = HippiusClient()
595
+ ```
596
+
323
597
  ## Development
324
598
 
325
599
  ```bash
@@ -473,3 +747,111 @@ Contributions are welcome! Please feel free to submit a Pull Request.
473
747
 
474
748
  This project is licensed under the MIT License - see the LICENSE file for details.
475
749
 
750
+ ### Seed Phrase Management
751
+
752
+ For enhanced security, Hippius SDK supports encrypting your Substrate seed phrase with a password:
753
+
754
+ ```bash
755
+ # Set a seed phrase in plain text
756
+ hippius seed set "your twelve word seed phrase here"
757
+
758
+ # Set a seed phrase and encrypt it with a password
759
+ hippius seed set "your twelve word seed phrase here" --encode
760
+ # You will be prompted to enter and confirm a password
761
+
762
+ # Check the status of your seed phrase
763
+ hippius seed status
764
+
765
+ # Encrypt an existing seed phrase with a password
766
+ hippius seed encode
767
+ # You will be prompted to enter and confirm a password
768
+
769
+ # Temporarily decrypt and view your seed phrase
770
+ hippius seed decode
771
+ # You will be prompted to enter your password
772
+ ```
773
+
774
+ > **Note:** Password-based encryption requires both the `pynacl` and `cryptography` Python packages, which are included as dependencies when you install Hippius SDK.
775
+
776
+ To use password-based seed phrase encryption:
777
+ 1. Set your seed phrase with encryption: `hippius seed set "your seed phrase" --encode`
778
+ 2. You'll be prompted to enter and confirm a secure password
779
+ 3. The seed phrase will be encrypted using your password and stored safely
780
+ 4. When the SDK needs to use your seed phrase, you'll be prompted for your password
781
+ 5. Your password is never stored - it's only used temporarily to decrypt the seed phrase
782
+
783
+ This provides enhanced security by:
784
+ - Protecting your seed phrase with a password only you know
785
+ - Never storing the seed phrase in plain text
786
+ - Using strong cryptography (PBKDF2 with SHA-256) to derive encryption keys
787
+ - Requiring your password every time the seed phrase is needed
788
+
789
+ When interacting with the Hippius SDK programmatically, you can provide the password when initializing clients:
790
+
791
+ ```python
792
+ from hippius_sdk import HippiusClient
793
+
794
+ # The client will prompt for password when needed to decrypt the seed phrase
795
+ client = HippiusClient()
796
+
797
+ # Or you can provide a password when initializing
798
+ client = HippiusClient(seed_phrase_password="your-password")
799
+ ```
800
+
801
+ ### Multi-Account Management
802
+
803
+ Hippius SDK now supports managing multiple named accounts, each with their own seed phrase:
804
+
805
+ ```bash
806
+ # Set a seed phrase for a named account
807
+ hippius seed set "your seed phrase here" --account "my-validator"
808
+
809
+ # Set another seed phrase for a different account
810
+ hippius seed set "another seed phrase" --account "my-developer-account" --encode
811
+
812
+ # List all configured accounts
813
+ hippius account list
814
+
815
+ # Switch the active account
816
+ hippius account switch my-developer-account
817
+
818
+ # Check the status of a specific account
819
+ hippius seed status --account my-validator
820
+
821
+ # Delete an account
822
+ hippius account delete my-developer-account
823
+ ```
824
+
825
+ Key features of the multi-account system:
826
+
827
+ 1. **Named Accounts**: Each account has a unique name for easy identification
828
+ 2. **SS58 Address Storage**: Addresses are stored unencrypted for convenient access
829
+ 3. **Active Account**: One account is designated as "active" and used by default
830
+ 4. **Shared Password**: All accounts use the same password for encryption
831
+ 5. **Separate Encryption**: Each account can choose whether to encrypt its seed phrase
832
+
833
+ To use multiple accounts in your code:
834
+
835
+ ```python
836
+ from hippius_sdk import HippiusClient, set_active_account, list_accounts
837
+
838
+ # List all accounts
839
+ accounts = list_accounts()
840
+ for name, data in accounts.items():
841
+ print(f"{name}: {data.get('ss58_address')}")
842
+
843
+ # Switch the active account
844
+ set_active_account("my-validator")
845
+
846
+ # Create a client with the active account
847
+ client = HippiusClient(seed_phrase_password="your-password")
848
+
849
+ # Or specify a different account to use
850
+ client = HippiusClient(
851
+ account_name="my-developer-account",
852
+ seed_phrase_password="your-password"
853
+ )
854
+ ```
855
+
856
+ The multi-account system makes it easier to manage multiple identities while maintaining security and convenience.
857
+
@@ -0,0 +1,10 @@
1
+ hippius_sdk/__init__.py,sha256=fs2pZ_wIl3eaUz6qFprcRsZhYakqv6-qm468NZh-8h4,1260
2
+ hippius_sdk/cli.py,sha256=RgRvBrrZ5PhFkfrkeGFP7byc1V_sbCJnLElrnCtr14A,76323
3
+ hippius_sdk/client.py,sha256=RV9MPs9nFW7dd8rVMgJ2giPrX6ETOnvlJDqm9uwuQi8,14908
4
+ hippius_sdk/config.py,sha256=NzAkmFaeE9-inHCCYL9cl97dZmSndx6OSgj9cQBWMAA,22872
5
+ hippius_sdk/ipfs.py,sha256=RKIDFuYqPFZfbHTi-oMa_IfAUUmtJX1nFOFnOKlnbBk,63972
6
+ hippius_sdk/substrate.py,sha256=ulLL3WcDHLm8eU_MuvqbzrCn2fbCdDDReJcxthMtFDw,29661
7
+ hippius-0.1.7.dist-info/METADATA,sha256=u_wKxSFdznRWbflR4OLBJ7XbFBXBEB_sQjohUv5UD9g,24689
8
+ hippius-0.1.7.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
9
+ hippius-0.1.7.dist-info/entry_points.txt,sha256=b1lo60zRXmv1ud-c5BC-cJcAfGE5FD4qM_nia6XeQtM,98
10
+ hippius-0.1.7.dist-info/RECORD,,
hippius_sdk/__init__.py CHANGED
@@ -4,8 +4,52 @@ Hippius SDK - Python interface for Hippius blockchain storage
4
4
 
5
5
  from hippius_sdk.client import HippiusClient
6
6
  from hippius_sdk.ipfs import IPFSClient
7
+ from hippius_sdk.config import (
8
+ get_config_value,
9
+ set_config_value,
10
+ get_encryption_key,
11
+ set_encryption_key,
12
+ load_config,
13
+ save_config,
14
+ initialize_from_env,
15
+ get_all_config,
16
+ reset_config,
17
+ get_seed_phrase,
18
+ set_seed_phrase,
19
+ encrypt_seed_phrase,
20
+ decrypt_seed_phrase,
21
+ get_active_account,
22
+ set_active_account,
23
+ list_accounts,
24
+ delete_account,
25
+ get_account_address,
26
+ )
7
27
 
8
28
  __version__ = "0.1.0"
9
- __all__ = ["HippiusClient", "IPFSClient"]
29
+ __all__ = [
30
+ "HippiusClient",
31
+ "IPFSClient",
32
+ "get_config_value",
33
+ "set_config_value",
34
+ "get_encryption_key",
35
+ "set_encryption_key",
36
+ "load_config",
37
+ "save_config",
38
+ "initialize_from_env",
39
+ "get_all_config",
40
+ "reset_config",
41
+ "get_seed_phrase",
42
+ "set_seed_phrase",
43
+ "encrypt_seed_phrase",
44
+ "decrypt_seed_phrase",
45
+ "get_active_account",
46
+ "set_active_account",
47
+ "list_accounts",
48
+ "delete_account",
49
+ "get_account_address",
50
+ ]
51
+
52
+ # Initialize configuration from environment variables for backward compatibility
53
+ initialize_from_env()
10
54
 
11
55
  # Note: Substrate functionality will be added in a future release