mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 00:09:04 +00:00
Add BIP85 derivation helpers and tests
This commit is contained in:
@@ -19,6 +19,7 @@ import hashlib
|
||||
import string
|
||||
import random
|
||||
import traceback
|
||||
import base64
|
||||
from typing import Optional
|
||||
from termcolor import colored
|
||||
from pathlib import Path
|
||||
@@ -332,3 +333,19 @@ class PasswordGenerator:
|
||||
logger.error(f"Error ensuring password complexity: {e}", exc_info=True)
|
||||
print(colored(f"Error: Failed to ensure password complexity: {e}", "red"))
|
||||
raise
|
||||
|
||||
|
||||
def derive_totp_secret(bip85: BIP85, idx: int) -> str:
|
||||
"""Derive a TOTP secret for the given index using BIP85."""
|
||||
entropy = bip85.derive_entropy(index=idx, bytes_len=10, app_no=2)
|
||||
return base64.b32encode(entropy).decode("utf-8")
|
||||
|
||||
|
||||
def derive_ssh_key(bip85: BIP85, idx: int) -> bytes:
|
||||
"""Derive 32 bytes of entropy suitable for an SSH key."""
|
||||
return bip85.derive_entropy(index=idx, bytes_len=32, app_no=32)
|
||||
|
||||
|
||||
def derive_seed_phrase(bip85: BIP85, idx: int, words: int = 24) -> str:
|
||||
"""Derive a new BIP39 seed phrase using BIP85."""
|
||||
return bip85.derive_mnemonic(index=idx, words_num=words)
|
||||
|
Reference in New Issue
Block a user