diff --git a/miners/__init__.py b/miners/__init__.py new file mode 100644 index 000000000..634683517 --- /dev/null +++ b/miners/__init__.py @@ -0,0 +1 @@ +# RustChain miners package \ No newline at end of file diff --git a/miners/checksums.sha256 b/miners/checksums.sha256 index 0bcc0a5a2..4da5e4ebb 100644 --- a/miners/checksums.sha256 +++ b/miners/checksums.sha256 @@ -1,7 +1,7 @@ -63aacaffe93a3631f6cf5fbb3156d8458b11d7f79a72f4b30375f1520cda5e2e linux/rustchain_linux_miner.py +4e4784f25ef975e2f3f4e05e846774949638fc8ec6c2189a1968fcb531a4284d linux/rustchain_linux_miner.py bdd982c7bbb53d5d37c0accb2bbc9e7e3b22e12fa9031c8fba11c4ee9c9f7819 linux/fingerprint_checks.py +fac32a5c3b9d9ef5348d115ae19e5cdf8a46aa9e2af55f12951f5dea018d7ad8 macos/rustchain_mac_miner_v2.5.py 9e6a09e5ffad37ca6f24d293980f4c42ae5ec9b8b0d6b98048eeb06614e0251f macos/rustchain_mac_miner_v2.4.py -edd6fa034be308ac4c9d759b8da5c200129b57c5617b8432a89b2f142a5e9a8e macos/rustchain_mac_miner_v2.5.py bdd982c7bbb53d5d37c0accb2bbc9e7e3b22e12fa9031c8fba11c4ee9c9f7819 macos/fingerprint_checks.py cdbff3b324659aacc7aad130384f29b327da79b86f228d7a65a48c51b48bcb3e linux/requirements-miner.txt f00a048b05994dcabc336fb530fe1c1c3564e13e6f064f7e80daddd048299707 linux/miner_crypto.py diff --git a/miners/fingerprint_checks.py b/miners/fingerprint_checks.py new file mode 100644 index 000000000..f96f127e9 --- /dev/null +++ b/miners/fingerprint_checks.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +""" +RIP-PoA Hardware Fingerprint Validation — Platform Auto-Detect Wrapper +====================================================================== + +Auto-detects the current OS and delegates to the correct platform-specific +implementation (linux/, windows/, macos/). This allows running + + python3 miners/fingerprint_checks.py + +from the repository root on any supported platform. + +The platform-specific files are byte-for-byte identical; the subdirectory +layout exists for discoverability and to keep each platform miner +self-contained (each miner lives in its own directory with its own +fingerprint_checks.py, requirements, etc.). +""" + +import importlib.util +import os +import platform +import sys + +# ── Determine the platform-specific module path ──────────────────────────── + +_platform = platform.system().lower() +_script_dir = os.path.dirname(os.path.abspath(__file__)) + +if _platform == "linux": + _subdir = "linux" +elif _platform == "windows": + _subdir = "windows" +elif _platform == "darwin": + _subdir = "macos" +else: + # Fallback: try linux first (most generic), then windows + for _candidate in ("linux", "windows"): + _path = os.path.join(_script_dir, _candidate, "fingerprint_checks.py") + if os.path.exists(_path): + _subdir = _candidate + break + else: + raise ImportError( + f"Unsupported platform {_platform!r} and no platform-specific " + f"fingerprint_checks module found under miners/" + ) + +_fp_path = os.path.join(_script_dir, _subdir, "fingerprint_checks.py") + +# ── Load the platform-specific module ────────────────────────────────────── + +_spec = importlib.util.spec_from_file_location( + f"fingerprint_checks_{_subdir}", _fp_path +) +_mod = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_mod) + +# ── Re-export every public name ──────────────────────────────────────────── +# This makes "from fingerprint_checks import validate_all_checks" work +# regardless of whether the import resolved through the wrapper or directly. + +for _attr in dir(_mod): + if not _attr.startswith("_"): + globals()[_attr] = getattr(_mod, _attr) + +# ── Allow running directly ───────────────────────────────────────────────── + +if __name__ == "__main__": + passed, results = validate_all_checks() + print("\n\nDetailed Results:") + import json + print(json.dumps(results, indent=2, default=str)) + sys.exit(0 if passed else 1) \ No newline at end of file diff --git a/miners/linux/rustchain_linux_miner.py b/miners/linux/rustchain_linux_miner.py index c012ef031..de19616a0 100755 --- a/miners/linux/rustchain_linux_miner.py +++ b/miners/linux/rustchain_linux_miner.py @@ -32,11 +32,17 @@ # Import fingerprint checks try: - from fingerprint_checks import validate_all_checks + # Try platform-prefixed path first (works from any working directory) + from miners.linux.fingerprint_checks import validate_all_checks FINGERPRINT_AVAILABLE = True except ImportError: - FINGERPRINT_AVAILABLE = False - print("[WARN] fingerprint_checks.py not found - fingerprint attestation disabled") + try: + # Fall back to direct import (works when running from miners/linux/) + from fingerprint_checks import validate_all_checks + FINGERPRINT_AVAILABLE = True + except ImportError: + FINGERPRINT_AVAILABLE = False + print("[WARN] fingerprint_checks.py not found - fingerprint attestation disabled") # Import Warthog dual-mining sidecar try: diff --git a/miners/macos/rustchain_mac_miner_v2.5.py b/miners/macos/rustchain_mac_miner_v2.5.py index 68369000f..437c5d8cd 100644 --- a/miners/macos/rustchain_mac_miner_v2.5.py +++ b/miners/macos/rustchain_mac_miner_v2.5.py @@ -52,11 +52,17 @@ def error(msg): return msg # Import fingerprint checks try: - from fingerprint_checks import validate_all_checks + # Try platform-prefixed path first (works from any working directory) + from miners.macos.fingerprint_checks import validate_all_checks FINGERPRINT_AVAILABLE = True except ImportError: - FINGERPRINT_AVAILABLE = False - print(warning("[WARN] fingerprint_checks.py not found - fingerprint attestation disabled")) + try: + # Fall back to direct import (works when running from miners/macos/) + from fingerprint_checks import validate_all_checks + FINGERPRINT_AVAILABLE = True + except ImportError: + FINGERPRINT_AVAILABLE = False + print(warning("[WARN] fingerprint_checks.py not found - fingerprint attestation disabled")) # Import CPU architecture detection try: diff --git a/miners/windows/rustchain_miner_setup.bat b/miners/windows/rustchain_miner_setup.bat index 957ae0832..c80912049 100755 --- a/miners/windows/rustchain_miner_setup.bat +++ b/miners/windows/rustchain_miner_setup.bat @@ -6,7 +6,7 @@ set "PYTHON_URL=https://www.python.org/ftp/python/3.11.5/python-3.11.5-amd64.exe set "PYTHON_INSTALLER=%SCRIPT_DIR%python-3.11.5-amd64.exe" set "MINER_URL=https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/windows/rustchain_windows_miner.py" set "MINER_SCRIPT=%SCRIPT_DIR%rustchain_windows_miner.py" -set "MINER_SHA256=99ac84a489ebc8c1987eddc02dfbaf8672a9d440cc2cc9e1166c6ba25f4e8184" +set "MINER_SHA256=86bd4f9704d89864055df8f572f594535c22f8cc98f20d5d11bdd081b27da3b6" set "CRYPTO_URL=https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/windows/miner_crypto.py" set "CRYPTO_SCRIPT=%SCRIPT_DIR%miner_crypto.py" set "CRYPTO_SHA256=f00a048b05994dcabc336fb530fe1c1c3564e13e6f064f7e80daddd048299707" diff --git a/miners/windows/rustchain_windows_miner.py b/miners/windows/rustchain_windows_miner.py index 28db49b73..9ae3cab3b 100644 --- a/miners/windows/rustchain_windows_miner.py +++ b/miners/windows/rustchain_windows_miner.py @@ -45,13 +45,20 @@ # previously dropped in a refactor and produced silent earning regressions # for every v3.1.0/v3.1.1-bundled install. Restored 2026-05-28 for v3.1.2. try: - from fingerprint_checks import validate_all_checks + # Try platform-prefixed path first (works from any working directory) + from miners.windows.fingerprint_checks import validate_all_checks FINGERPRINT_AVAILABLE = True _FP_IMPORT_ERROR = "" -except Exception as e: - FINGERPRINT_AVAILABLE = False - _FP_IMPORT_ERROR = str(e) - validate_all_checks = None +except Exception: + try: + # Fall back to direct import (works when running from miners/windows/) + from fingerprint_checks import validate_all_checks + FINGERPRINT_AVAILABLE = True + _FP_IMPORT_ERROR = "" + except Exception as e: + FINGERPRINT_AVAILABLE = False + _FP_IMPORT_ERROR = str(e) + validate_all_checks = None # ── Ed25519 signing (GPT-5.4 audit finding #2) ── # Optional: if miner_crypto.py + PyNaCl are available, sign attestations diff --git a/setup_miner.py b/setup_miner.py index 538825b48..c9a86f3bf 100644 --- a/setup_miner.py +++ b/setup_miner.py @@ -20,15 +20,15 @@ MINER_ARTIFACTS = { "Linux": { "url": "https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/linux/rustchain_linux_miner.py", - "sha256": "63aacaffe93a3631f6cf5fbb3156d8458b11d7f79a72f4b30375f1520cda5e2e", + "sha256": "4e4784f25ef975e2f3f4e05e846774949638fc8ec6c2189a1968fcb531a4284d", }, "Darwin": { "url": "https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/macos/rustchain_mac_miner_v2.5.py", - "sha256": "edd6fa034be308ac4c9d759b8da5c200129b57c5617b8432a89b2f142a5e9a8e", + "sha256": "fac32a5c3b9d9ef5348d115ae19e5cdf8a46aa9e2af55f12951f5dea018d7ad8", }, "Windows": { "url": "https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/windows/rustchain_windows_miner.py", - "sha256": "99ac84a489ebc8c1987eddc02dfbaf8672a9d440cc2cc9e1166c6ba25f4e8184", + "sha256": "86bd4f9704d89864055df8f572f594535c22f8cc98f20d5d11bdd081b27da3b6", }, }