Post
Topic
Board Off-topic
Re: Spectral Math Unlocks Bitcoin Private Keys?
by
PAPASO
on 11/05/2025, 02:35:22 UTC
#  MSE < 1e-7

import numpy as np
import matplotlib.pyplot as plt

# Step 1:  (n=1000)
n_samples = 1000
k_values = np.linspace(1e3, 1e6, n_samples)  # 更大 k 量级
x_Q = np.linspace(0.5, 2.0, n_samples)
y_Q = np.linspace(1.0, 3.0, n_samples)
a_curve = np.linspace(1, 3, n_samples)
b_curve = np.linspace(-1, 2, n_samples)
xy = x_Q + y_Q

# Hecke
a_p = np.array([1.0, -1.0, 0.0, 2.0, -2.0, 1.0, -1.0, 3.0, -3.0, 2.0, 0.0, -2.0])
P = len(a_p)

# Step 2:  X(r = 1~5)
X_parts = []
for i in range(P):
    for r in range(1, 6):
        X_parts.append(a_p * (xy ** r))
        X_parts.append(a_p * (a_curve ** r))
        X_parts.append(a_p * (b_curve ** r))
X = np.column_stack(X_parts)

# Step 3:
coeffs, _, _, _ = np.linalg.lstsq(X, k_values, rcond=None)
k_pred = X @ coeffs

# Step 4:
mse = np.mean((k_pred - k_values) ** 2)
max_err = np.max(np.abs(k_pred - k_values))
mean_err = np.mean(np.abs(k_pred - k_values))

#
print("\nMultivariable Spectral Regression (n = 1000)")
print("=" * 65)
print(f"MSE:             {mse:.6e}")
print(f"Max Error:       {max_err:.6f}")
print(f"Mean Error:      {mean_err:.6f}")
print(f"First 5 k (true):     {np.round(k_values[:5], 3).tolist()}")
print(f"First 5 k (predicted):{np.round(k_pred[:5], 3).tolist()}")

#
plt.figure(figsize=(8, 5))
plt.plot(k_values[:100], k_values[:100], 'k--', label='Ideal')
plt.plot(k_values[:100], k_pred[:100], 'o-', label='Predicted')
plt.xlabel("True k")
plt.ylabel("Predicted k")
plt.title("Spectral Regression: Hecke a_p → Scalar k (n = 1000)")
plt.grid(True)
plt.legend()
plt.tight_layout()
plt.show()


Multivariable Spectral Regression (n = 1000)
=================================================================
MSE:             3.990343e-16
Max Error:       0.000000
Mean Error:      0.000000
First 5 k (true):     [1000.0, 2000.0, 3000.0, 4000.0, 5000.0]
First 5 k (predicted):[1000.0, 2000.0, 3000.0, 4000.0, 5000.0]
2025-05-10 19:29:44.285 Python[37892:21950858] +[IMKClient subclass]: chose IMKClient_Modern
2025-05-10 19:29:44.285 Python[37892:21950858] +[IMKInputSession subclass]: chose IMKInputSession_Modern