mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-10-27 16:02:05 +00:00
L2: generate_bip85_seed and create_profile_from_generated_seed now take words_num, accepting 12 or 24 and rejecting anything else with a clear message. The default stays 12 -- every existing profile uses it, 128 bits is entirely adequate, and moving the default would change nothing about existing vaults while surprising anyone creating a new one. 24 is offered because the master seed protects the whole vault and was the one secret shorter than the seeds derived beneath it, which already default to 24. L3: fixed structurally rather than by narrowing exception types. os.urandom(32) now sits OUTSIDE the try block, so no handler can stand between the entropy draw and the caller -- an entropy failure is unreachable by anything that could substitute a value. Also removes a redundant `except Exception` whose body was identical to the `Bip85Error` branch above it. The structural form is stronger than an exception list, and the test says so precisely: it asserts the OSError reaching the caller is the SAME OBJECT os.urandom threw, which holds only if nothing caught and repackaged it. Listing exception types would still leave a handler in the path for someone to widen later. Adds five tests: the identity assertion above, 12- and 24-word generation, the default staying 12, and rejection of 0/11/18/25/-12. Determinism gate green (89 tests, up from 84). The seed/profile regression subset is 143 passed with one failure -- test_profile_export_import_round_trip -- confirmed against the pre-change baseline as pre-existing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HtNMsKzzFTPURemX7tT19u
95 lines
3.3 KiB
Python
95 lines
3.3 KiB
Python
# constants.py
|
|
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
# Instantiate the logger
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# -----------------------------------
|
|
# Nostr Relay Connection Settings
|
|
# -----------------------------------
|
|
# Retry fewer times with a shorter wait by default. These values
|
|
# act as defaults that can be overridden via ``ConfigManager``
|
|
# entries ``nostr_max_retries`` and ``nostr_retry_delay``.
|
|
MAX_RETRIES = 2 # Default maximum number of retry attempts
|
|
RETRY_DELAY = 1 # Default seconds to wait before retrying
|
|
MIN_HEALTHY_RELAYS = 2 # Minimum relays that should return data on startup
|
|
|
|
# -----------------------------------
|
|
# Application Directory and Paths
|
|
# -----------------------------------
|
|
APP_DIR = Path.home() / ".seedpass"
|
|
PARENT_SEED_FILE = APP_DIR / "parent_seed.enc" # Encrypted parent seed
|
|
|
|
# -----------------------------------
|
|
# Checksum Files for Integrity
|
|
# -----------------------------------
|
|
SCRIPT_CHECKSUM_FILE = (
|
|
APP_DIR / "seedpass_script_checksum.txt"
|
|
) # Checksum for main script
|
|
|
|
|
|
def initialize_app() -> None:
|
|
"""Ensure the application directory exists."""
|
|
try:
|
|
APP_DIR.mkdir(exist_ok=True, parents=True)
|
|
logger.debug("Application directory created at %s", APP_DIR)
|
|
except Exception as exc:
|
|
logger.error("Failed to create application directory: %s", exc, exc_info=True)
|
|
|
|
|
|
# -----------------------------------
|
|
# Password Generation Constants
|
|
# -----------------------------------
|
|
DEFAULT_PASSWORD_LENGTH = 16 # Default length for generated passwords
|
|
MIN_PASSWORD_LENGTH = 8 # Minimum allowed password length
|
|
MAX_PASSWORD_LENGTH = 128 # Maximum allowed password length
|
|
|
|
# Characters considered safe for passwords when limiting punctuation
|
|
SAFE_SPECIAL_CHARS = "!@#$%^*-_+=?"
|
|
|
|
# Master seed word count.
|
|
# -----------------------------------
|
|
# 12 words = 128 bits, 24 words = 256 bits. The default stays 12: it is
|
|
# entirely adequate and every existing profile uses it, so changing the default
|
|
# would alter nothing about existing vaults but would surprise. 24 is offered
|
|
# because the master seed protects the whole vault and was previously the one
|
|
# secret shorter than the seeds derived beneath it, which default to 24
|
|
# (entropy audit L2, docs/entropy_audit_2026-07-31.md).
|
|
DEFAULT_SEED_WORD_COUNT = 12
|
|
SUPPORTED_SEED_WORD_COUNTS = frozenset({12, 24})
|
|
|
|
# Timeout in seconds before the vault locks due to inactivity
|
|
INACTIVITY_TIMEOUT = 15 * 60 # 15 minutes
|
|
|
|
# Duration in seconds that a notification remains active
|
|
NOTIFICATION_DURATION = 10
|
|
|
|
# -----------------------------------
|
|
# GUI Backend Configuration
|
|
# -----------------------------------
|
|
GUI_BACKEND_CONFIG = {
|
|
"linux": {
|
|
"pkg": "toga-gtk",
|
|
"version": "0.5.2",
|
|
"sha256": "15b346ac1a2584de5effe5e73a3888f055c68c93300aeb111db9d64186b31646",
|
|
},
|
|
"win32": {
|
|
"pkg": "toga-winforms",
|
|
"version": "0.5.2",
|
|
"sha256": "83181309f204bcc4a34709d23fdfd68467ae8ecc39c906d13c661cb9a0ef581b",
|
|
},
|
|
"darwin": {
|
|
"pkg": "toga-cocoa",
|
|
"version": "0.5.2",
|
|
"sha256": "a4d5d1546bf92372a6fb1b450164735fb107b2ee69d15bf87421fec3c78465f9",
|
|
},
|
|
}
|
|
|
|
# -----------------------------------
|
|
# Additional Constants (if any)
|
|
# -----------------------------------
|
|
# Add any other constants here as your project expands
|
|
DEFAULT_SEED_BACKUP_FILENAME = "parent_seed_backup.enc"
|