Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
HomelessPhD authored Mar 14, 2021
1 parent 3c078ff commit 5bd14c3
Show file tree
Hide file tree
Showing 25 changed files with 2,648 additions and 0 deletions.
117 changes: 117 additions & 0 deletions BTC32_Analysis/BTC32_dummy_analysis.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
% Dummy MATLAB script - analysis of 32BTC Puzzle private keys
%
% Donations could be sent here: 1QKjnfVsTT1KXzHgAFUbTy3QbJ2Hgy96WU
% ( i am poor Ukrainian student that will really appreciate your
% donates - have no home, living in the dorm and trying to cope
% for the smallest flat in the city - with no success at the moment,
% nearly 10% of desired amount)

%% Clear all: command window, workspace, figures
clc;
clear all;
close all;

%% Load and prepare the data
% Read the private keys from the file - stored as decimal prefix
% (there are two columns: 1) is the wallet index (unknown bits amount),
% 2) priv key non-zero part in decimal.
data = dlmread('btc32_keys_dec.csv');
% Evaluate the "reminder" of the non-zero priv key part - each priv key
% has a form of 2^(n-1) + <reminder> where n is an amount of unknown bits
% and <reminder> is actually unknown its part that lies in interval
% 2^(n-1) -- 2^n
rem_2 = vpa( data(:,2) - 2.^(data(:,1)-1) );
% Compute the relative position of the priv key inside the
% 2^n -- 2^(n+1) interval - "describe the Private Keys in
% dimensionless form"
alpha = rem_2 ./ vpa( 2.^(data(:,1)) - 2.^(data(:,1)-1));

%% Plot raw numbers/ histograms / autocorrelation function

% raw numbers
fig = figure();
plot(data(:,1), double(alpha), 'o');
hold on;
xlabel('index');
ylabel('Place within interval');
plot([63.5 63.5],[0 1],'--r', 'LineWidth',2);
ylim([0 1]);
saveas(fig, 'raw_alpha.png');
close(fig);

% histograms
% All known priv keys
fig = figure();
subplot(2,1,1);
hist(double(alpha),10);
title('Histogram for all keys');
xlim([0 1]);
subplot(2,1,2);
hist(double(alpha),40);
title('(smaller bars)');
xlim([0 1]);
saveas(fig, 'hist_all.png');
close(fig);

% 1-63 keys
fig = figure();
subplot(2,1,1);
hist(double(alpha(1:(end-11))),10);
title('Histogram for 1-63 keys');
xlim([0 1]);
subplot(2,1,2);
hist(double(alpha(1:(end-11))),40);
title('(smaller bars)');
xlim([0 1]);
saveas(fig, 'hist_1_63.png');
close(fig);

% all upper 5th keys
fig = figure();
subplot(2,1,1);
hist(double(alpha((end-10):end)),10);
title('Histogram for 5th keys');
xlim([0 1]);
subplot(2,1,2);
hist(double(alpha((end-10):end)),40);
title('(smaller bars)');
xlim([0 1]);
saveas(fig, 'hist_upper_5th.png');
close(fig);

% look more closely
fig = figure();
hist(double(alpha),100);
title('Histogram all keys: tiny bins');
xlim([0 1]);
saveas(fig, 'hist_all_tiny_bins.png');
close(fig);

% even more closely
fig = figure();
hist(double(alpha),2000)
title('Histogram all keys: very tiny bins');
xlim([0 1]);
saveas(fig, 'hist_all_very_tiny_bins.png');
close(fig);

% Autocorrelation
% 1-63 keys
fig = figure();
plot(xcorr(double(alpha(1:(end-11))) - mean(double(alpha(1:(end-11))))), '--o');
title('Autocorrelation for 1-63 keys');
xlim([0 length(double(alpha(1:(end-11))))*2])
saveas(fig, 'autocorr_1_63.png');
close(fig);

% all upper 5th keys
fig = figure();
plot(xcorr(double(alpha((end-10):end)) - mean(double(alpha((end-10):end)))), '--o');
title('Autocorrelation for 5th keys');
xlim([0 length(double(alpha((end-10):end)))*2])
saveas(fig, 'autocorr_upper_5th.png');
close(fig);

% Inspect those with alpha ~ 0.82
% Get indecies of ~0.82 withing its alpha value
[data((double(alpha)<0.84) .* (double(alpha)>0.8)==1,1),alpha((double(alpha)<0.84) .* (double(alpha)>0.8)==1)]
51 changes: 51 additions & 0 deletions BTC32_Analysis/BTC32_dummy_simulation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
% Dummy MATLAB script - analysis of 32BTC Puzzle private keys - simulation
% of the key randomization - inspecting histograms
%
% Donations could be sent here: 1QKjnfVsTT1KXzHgAFUbTy3QbJ2Hgy96WU
% ( i am poor Ukrainian student that will really appreciate your
% donates - have no home, living in the dorm and trying to cope
% for the smallest flat in the city - with no success at the moment,
% nearly 10% of desired amount)

%% Clear all
close all;
clear all;
clc;

%% Compose alphas array in a "similar" to BTC32 way
% Define the maximum integer generated by random generator
% (BTC 32 have 2^255-2^256 i assume)
MAX_RANDOM_NUMBER = 10^14;
% Define the maximum used/interesting integer - BTC 32 only the first
% 160 numbers are interesting now - they are generated by projection
% of the 2^255 random onto 2^{bits} space by taking the reminder i
% assume
MAX_INTERESTING_NUMBER = 10^11;
% Intervals are also growing logarithmic integers like in the BTC32
% but with a smaller "logarithmic" step - MATLAB random integers are
% limited to 52 bit
intervals = unique(ceil(logspace(0,log10(MAX_INTERESTING_NUMBER),160)'));
num_raw = randi(MAX_RANDOM_NUMBER,length(intervals),1);

for i=1:length(num_raw)
num(i) = rem(num_raw(i), intervals(i));
alpha(i) = num(i) / intervals(i);
end

%% Plot histograms for the first 60 alphas and the last alphas

fig = figure('Position',[10 10 1000 600]);

subplot(2,1,1);

hist(alpha(1:60),100);
title('first 60 alphas');
grid on;

subplot(2,1,2);
hist(alpha(61:end),100);
title('...all remind alphas');
grid on;

saveas(fig, 'alpha_simulation_hist.png');
close(fig)
74 changes: 74 additions & 0 deletions BTC32_Analysis/alpha.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
1,0
2,0.5
3,0.75
4,0
5,0.3125
6,0.53125
7,0.1875
8,0.75
9,0.82421875
10,0.00390625
11,0.1279296875
12,0.31005859375
13,0.2734375
14,0.287109375
15,0.63983154296875
16,0.57196044921875
17,0.4621429443359375
18,0.5157241821289062
19,0.3638877868652344
20,0.6466464996337891
21,0.7278327941894531
22,0.434089183807373
23,0.3348584175109863
24,0.7200322151184082
25,0.9780104756355286
26,0.6253847479820251
27,0.6681841164827347
28,0.6960085034370422
29,0.4927569553256035
30,0.9244143441319466
31,0.9580019181594253
32,0.4405105328187346
33,0.6618142630904913
34,0.6453061435604468
35,0.1707232212647796
36,0.2336464709369466
37,0.4588522112899227
38,0.0693586707348004
39,0.1777045763192291
40,0.8256312850098766
41,0.3262726544298857
42,0.3166639075566309
43,0.6847959722838368
44,0.7513186500162874
45,0.1366673269661192
46,0.4611222908516766
47,0.7005655069250736
48,0.3586072690006503
49,0.4534823301649347
50,0.08560360020207014
51,0.8285546544961626
52,0.8725002169265093
53,0.5018395352846268
54,0.107386987053339
55,0.6678542153963616
56,0.2273166453323929
57,0.9185453074950023
58,0.3876168823447197
59,0.8217038442259545
60,0.9689828764301731
61,0.2366735609679316
62,0.6949864005878701
63,0.9500958897872267
65,0.6571150545548308
70,0.6439841804320401
75,0.1931688975616066
80,0.8289294721848897
85,0.0903437696623155
90,0.4023493269008402
95,0.2887251778456132
100,0.3698115766805314
105,0.4339139536794416
110,0.6797900857488874
115,0.5149424275913059
Binary file added BTC32_Analysis/alpha_simulation_hist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BTC32_Analysis/autocorr_1_63.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BTC32_Analysis/autocorr_upper_5th.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions BTC32_Analysis/btc32_keys_dec.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
1,1
2,3
3,7
4,8
5,21
6,49
7,76
8,224
9,467
10,514
11,1155
12,2683
13,5216
14,10544
15,26867
16,51510
17,95823
18,198669
19,357535
20,863317
21,1811764
22,3007503
23,5598802
24,14428676
25,33185509
26,54538862
27,111949941
28,227634408
29,400708894
30,1033162084
31,2102388551
32,3093472814
33,7137437912
34,14133072157
35,20112871792
36,42387769980
37,100251560595
38,146971536592
39,323724968937
40,1003651412950
41,1458252205147
42,2895374552463
43,7409811047825
44,15404761757071
45,19996463086597
46,51408670348612
47,119666659114170
48,191206974700443
49,409118905032525
50,611140496167764
51,2058769515153876
52,4216495639600700
53,6763683971478124
54,9974455244496707
55,30045390491869460
56,44218742292676575
57,138245758910846492
58,199976667976342049
59,525070384258266191
60,1135041350219496382
61,1425787542618654982
62,3908372542507822062
63,8993229949524469768
65,30568377312064202855
70,970436974005023690481
75,22538323240989823823367
80,1105520030589234487939456
85,21090315766411506144426920
90,868012190417726402719548863
95,25525831956644113617013748212
100,868221233689326498340379183142
105,29083230144918045706788529192435
110,1090246098153987172547740458951748
115,31464123230573852164273674364426950
Binary file added BTC32_Analysis/hist_1_63.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BTC32_Analysis/hist_all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BTC32_Analysis/hist_all_tiny_bins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BTC32_Analysis/hist_all_very_tiny_bins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BTC32_Analysis/hist_upper_5th.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BTC32_Analysis/raw_alpha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5bd14c3

Please sign in to comment.