mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 07:18:47 +00:00
Merge pull request #164 from PR0M3TH3AN/e3lki3-codex/remove-bip85-from-requirements-and-clean-up-code
Remove bip85 dependency and unused code
This commit is contained in:
@@ -6,7 +6,6 @@ base58==2.1.1
|
|||||||
bcrypt==4.3.0
|
bcrypt==4.3.0
|
||||||
bech32==1.2.0
|
bech32==1.2.0
|
||||||
bip-utils==2.9.3
|
bip-utils==2.9.3
|
||||||
bip85==0.2.0
|
|
||||||
cbor2==5.6.5
|
cbor2==5.6.5
|
||||||
certifi==2025.6.15
|
certifi==2025.6.15
|
||||||
cffi==1.17.1
|
cffi==1.17.1
|
||||||
|
@@ -7,7 +7,6 @@ coincurve>=18.0.0
|
|||||||
mnemonic
|
mnemonic
|
||||||
aiohttp
|
aiohttp
|
||||||
bcrypt
|
bcrypt
|
||||||
bip85
|
|
||||||
pytest>=7.0
|
pytest>=7.0
|
||||||
pytest-cov
|
pytest-cov
|
||||||
pytest-xdist
|
pytest-xdist
|
||||||
|
@@ -23,12 +23,7 @@ import traceback
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
from bip_utils import Bip39SeedGenerator
|
from bip_utils import Bip39SeedGenerator
|
||||||
from local_bip85.bip85 import BIP85
|
|
||||||
|
|
||||||
try:
|
|
||||||
from monstr.encrypt import Keys
|
|
||||||
except ImportError: # Fall back to local coincurve implementation
|
|
||||||
from nostr.coincurve_keys import Keys
|
|
||||||
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
|
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
|
||||||
from cryptography.hazmat.primitives import hashes
|
from cryptography.hazmat.primitives import hashes
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
@@ -140,43 +135,6 @@ def derive_key_from_parent_seed(parent_seed: str, fingerprint: str = None) -> by
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
class KeyManager:
|
|
||||||
def __init__(self, parent_seed: str, fingerprint: str = None):
|
|
||||||
self.parent_seed = parent_seed
|
|
||||||
self.fingerprint = fingerprint
|
|
||||||
self.bip85 = self.initialize_bip85()
|
|
||||||
self.keys = self.generate_nostr_keys()
|
|
||||||
|
|
||||||
def initialize_bip85(self):
|
|
||||||
seed_bytes = Bip39SeedGenerator(self.parent_seed).Generate()
|
|
||||||
bip85 = BIP85(seed_bytes)
|
|
||||||
return bip85
|
|
||||||
|
|
||||||
def generate_nostr_keys(self) -> Keys:
|
|
||||||
"""
|
|
||||||
Derives a unique Nostr key pair for the given fingerprint using BIP-85.
|
|
||||||
|
|
||||||
:return: An instance of Keys containing the Nostr key pair.
|
|
||||||
"""
|
|
||||||
# Use a derivation path that includes the fingerprint
|
|
||||||
# Convert fingerprint to an integer index (e.g., using a hash function)
|
|
||||||
index = (
|
|
||||||
int(hashlib.sha256(self.fingerprint.encode()).hexdigest(), 16) % (2**31)
|
|
||||||
if self.fingerprint
|
|
||||||
else 0
|
|
||||||
)
|
|
||||||
|
|
||||||
# Derive entropy for Nostr key (32 bytes)
|
|
||||||
entropy_bytes = self.bip85.derive_entropy(
|
|
||||||
app=BIP85.Applications.ENTROPY, index=index, size=32
|
|
||||||
)
|
|
||||||
|
|
||||||
# Generate Nostr key pair from entropy
|
|
||||||
private_key_hex = entropy_bytes.hex()
|
|
||||||
keys = Keys(priv_key=private_key_hex)
|
|
||||||
return keys
|
|
||||||
|
|
||||||
|
|
||||||
def derive_index_key_seed_only(seed: str) -> bytes:
|
def derive_index_key_seed_only(seed: str) -> bytes:
|
||||||
"""Derive a deterministic Fernet key from only the BIP-39 seed."""
|
"""Derive a deterministic Fernet key from only the BIP-39 seed."""
|
||||||
seed_bytes = Bip39SeedGenerator(seed).Generate()
|
seed_bytes = Bip39SeedGenerator(seed).Generate()
|
||||||
|
Reference in New Issue
Block a user