ratPad Encryption Algorithm 0.1

Quite a whopping monster of a hash! by Jacob Muñoz Seeking peer review!

ratPad is an attempt to generate large streams of pseudo-random data for general encryption, hashing, authentication, and other various security purposes. The most notable feature of ratPad is the 'grid' of data and the 'maze' of instructions used to traverse through the grid. As cells are traversed, their values are transmitted and then modified by various flags and instructions. The result is a constantly-changing 3-dimensional array of values and a stream of values that can be reproduced predictably by any party with the proper starting data.

ratPad is purely for experimental use only, it most likely has exploitable weaknesses that have not yet been discovered.


In this example, a 'password' or 'secret' is used with a hashing algorithm (not shown here) to generate unique data values:

  1. Maze dimensions (x,y,z): [6,7,8]
  2. Cursor location (x,y,z): [3,4,5]
  3. Face:1
  4. Orientation:2
  5. Instructions: E0 O0 A1 M3 I127 R128 D124 B125 L134 C127 I047 U123 F126 A2 K2 R124 D135 F136 K3 B127 R129 E2 D38 B45 L46 I03457 I047 D26 B23 A2 O4 K2 R24 U44 F46 K3 B33 E3 O2 D40 R32 L35 U25 R28
  6. Maze cell values can be kept from previous connections or filled with incoming values if the connection is new:
    z 0  x0   x1   x2   x3   x4   x5   
    y0
    130
    120
    1
    76
    177
    40

    y1
    224
    31
    253
    13
    186
    176

    y2
    177
    227
    196
    35
    65
    97

    y3
    198
    221
    59
    165
    70
    131

    y4
    153
    198
    0
    201
    74
    81

    y5
    249
    121
    26
    38
    178
    181

    y6
    114
    115
    92
    87
    153
    26

    z 1  x0   x1   x2   x3   x4   x5   
    y0
    26
    162
    114
    183
    235
    81

    y1
    159
    179
    184
    171
    36
    52

    y2
    221
    230
    121
    40
    124
    6

    y3
    201
    185
    21
    113
    78
    107

    y4
    181
    41
    152
    105
    255
    9

    y5
    244
    211
    226
    2
    50
    207

    y6
    28
    36
    85
    42
    78
    37

    z 2  x0   x1   x2   x3   x4   x5   
    y0
    32
    114
    102
    41
    93
    99

    y1
    55
    219
    20
    146
    67
    218

    y2
    162
    90
    132
    3
    50
    213

    y3
    88
    210
    78
    241
    130
    70

    y4
    102
    117
    238
    77
    162
    70

    y5
    243
    241
    48
    71
    199
    8

    y6
    171
    131
    12
    55
    25
    109

    z 3  x0   x1   x2   x3   x4   x5   
    y0
    129
    210
    125
    26
    118
    52

    y1
    151
    126
    150
    220
    57
    232

    y2
    238
    164
    127
    209
    16
    68

    y3
    190
    149
    87
    193
    161
    211

    y4
    102
    127
    24
    134
    207
    254

    y5
    164
    153
    123
    200
    59
    202

    y6
    138
    193
    79
    163
    22
    88

    z 4  x0   x1   x2   x3   x4   x5   
    y0
    199
    196
    194
    250
    85
    198

    y1
    193
    135
    32
    55
    226
    107

    y2
    116
    34
    196
    244
    137
    228

    y3
    149
    172
    247
    21
    255
    45

    y4
    91
    147
    186
    241
    231
    172

    y5
    76
    184
    231
    203
    180
    152

    y6
    154
    45
    69
    109
    199
    162

    z 5  x0   x1   x2   x3   x4   x5   
    y0
    34
    248
    186
    230
    233
    238

    y1
    222
    204
    239
    32
    124
    233

    y2
    176
    221
    33
    145
    151
    160

    y3
    169
    211
    212
    88
    172
    42

    y4
    214
    75
    220
    22
    130
    100

    y5
    141
    125
    0
    69
    138
    132

    y6
    30
    108
    70
    115
    171
    69

    z 6  x0   x1   x2   x3   x4   x5   
    y0
    228
    15
    121
    19
    230
    213

    y1
    111
    78
    83
    128
    120
    227

    y2
    129
    87
    211
    61
    105
    179

    y3
    61
    224
    146
    154
    243
    209

    y4
    206
    168
    180
    29
    245
    98

    y5
    209
    249
    226
    122
    25
    138

    y6
    218
    147
    254
    182
    36
    157

    z 7  x0   x1   x2   x3   x4   x5   
    y0
    235
    130
    99
    220
    195
    207

    y1
    75
    81
    131
    135
    244
    13

    y2
    183
    231
    93
    43
    187
    159

    y3
    242
    170
    30
    115
    255
    179

    y4
    85
    85
    218
    8
    87
    192

    y5
    157
    224
    16
    94
    133
    64

    y6
    158
    137
    197
    220
    148
    248


With those starting values, the instructions are processed accoring to the following rules:
L#, R#, U#, D#, F#, B# = left, right, up, down, front, back #
K# = skip #
A# = accumulate 1=increment 2=decrement 3=clear
I# = invert bit #
C# = reset bit #
O# = change map orientation to #
E# = change map facing direction to #
Q# = quote # bytes from 
N# = insert # bytes of random noise
M# = modify cell function 0=none, 1=accumulate from acc, 2=multiply by acc and reduce by inverted acc, 3=add inverted*3.14159
instruction: E param: 0
instruction: O param: 0
instruction: A param: 1
instruction: M param: 3
instruction: I param: 127
instruction: R param: 128
Generating data: 4,96,58,129,101,127,126,48,68,60,48,194,193,204,1,35,65,4,188,105,225,71,127,147,92,58,210,166,57,47,24,54,221,188,175,207,242,69,108,186,24,210,89,34,196,131,96,144,109,125,62,52,41,30,10,144,158,189,231,15,58,35,10,214,104,226,33,78,115,168,131,38,126,169,76,29,19,20,199,151,127,149,195,252,190,160,155,143,69,206,137,244,88,82,73,0,240,133,79,95,104,128,196,184,186,228,115,104,45,143,239,128,82,95,103,81,235,224,228,14,32,51,79,148,216,83,168,254, instruction: D param: 124
Generating data: 122,199,169,158,62,100,239,170,108,207,55,34,193,91,54,31,201,172,215,143,99,112,155,214,46,208,202,193,82,48,227,186,225,61,146,118,131,175,240,136,92,67,60,50,12,149,130,122,136,173,203,244,216,223,208,193,157,75,220,38,118,197,17,253,235,148,247,166,90,194,254,60,33,179,146,133,56,195,12,42,240,231,219,221,147,12,91,128,204,31,108,82,207,133,122,55,145,76,82,12,0,2,3,235,231,10,39,93,145,23,72,145,12,110,17,249,245,172,148,1,199,202,6,70, instruction: B param: 125
Generating data: 34,110,59,69,162,69,240,179,210,135,138,206,165,150,168,126,37,39,18,205,161,144,97,73,84,134,169,226,56,172,152,172,209,208,160,71,8,229,75,36,204,24,241,229,4,60,14,39,208,49,97,173,46,107,137,235,26,246,146,110,84,251,235,121,228,21,248,245,248,18,83,24,189,33,91,155,24,143,56,85,17,255,163,129,126,104,111,147,173,217,191,183,171,182,190,164,112,16,96,207,54,249,192,47,17,29,201,131,102,129,193,165,200,52,98,88,93,85,13,225,158,118,16,37,53, instruction: L param: 134
Generating data: 114,145,93,56,233,61,231,207,187,201,233,177,223,46,133,53,197,141,55,142,130,132,56,52,42,37,152,29,31,63,89,142,111,95,141,215,114,109,96,119,99,21,236,233,255,1,8,29,87,231,97,217,86,178,96,2,213,117,69,8,245,249,58,20,30,48,104,232,55,84,191,4,160,49,131,180,126,243,200,188,178,135,97,247,48,136,246,232,235,125,194,179,66,141,213,154,81,178,159,139,63,26,11,222,184,55,44,75,120,177,12,236,23,69,218,162,31,85,199,251,166,125,110,29,223,93,60,47,45,48,110,61,75,105, instruction: C param: 127
instruction: I param: 047
instruction: U param: 123
Generating data: 109,217,14,84,31,162,93,197,154,250,52,83,31,229,142,130,54,144,175,205,5,229,117,75,73,8,173,54,77,48,63,81,66,7,230,178,165,20,85,97,151,171,135,112,202,137,36,63,226,205,193,101,74,95,98,138,240,35,24,31,49,169,141,43,24,62,177,238,215,56,11,45,157,122,250,58,22,35,100,121,112,228,88,98,209,119,122,103,148,91,244,181,146,134,48,10,9,35,28,24,224,244,5,87,130,168,227,60,101,206,9,21,219,70,184,67,227,72,157,216,178,104,117, instruction: F param: 126
Generating data: 119,188,100,81,148,238,76,113,104,90,37,40,34,162,98,131,48,53,47,149,182,98,72,87,45,134,201,194,186,134,140,161,221,165,74,191,21,127,65,14,195,58,1,240,77,8,48,41,121,47,121,142,127,110,204,53,214,195,99,67,83,219,125,214,110,61,19,25,15,194,188,116,80,80,123,240,83,99,217,160,175,237,138,40,25,183,76,169,104,237,241,195,228,223,171,144,117,246,57,102,16,87,143,141,138,34,155,36,40,233,200,88,171,189,176,138,240,21,86,11,206,80,187,8,166,35, instruction: A param: 2
instruction: K param: 2
instruction: R param: 124
Generating data: 18,84,101,104,157,24,139,140,143,75,250,123,199,115,82,159,42,105,37,60,243,9,52,91,225,72,117,151,146,30,129,142,135,64,200,76,166,49,248,45,40,193,30,21,41,77,198,95,41,106,37,33,244,48,62,68,20,152,162,77,26,103,19,167,174,160,106,188,47,255,68,213,54,19,91,220,53,28,93,203,42,62,120,8,18,61,114,95,99,80,37,231,80,76,117,101,72,95,57,230,33,69,91,116,33,7,122,171,40,238,70,198,86,34,98,54,10,116,172,36,17,69,196,46, instruction: D param: 135
Generating data: 134,165,156,16,146,69,83,75,10,0,130,47,212,36,167,198,78,53,144,134,188,148,138,13,110,144,42,204,98,47,92,188,67,217,55,210,33,239,247,84,79,116,95,79,154,227,169,10,128,33,178,81,80,11,11,245,132,43,232,45,102,223,34,196,23,51,114,237,193,205,119,252,129,22,79,75,112,231,25,164,20,110,53,180,189,104,254,66,134,45,115,158,3,23,179,195,158,226,131,143,254,182,193,120,71,66,49,16,158,131,9,96,200,91,221,135,36,141,227,93,171,208,99,140,121,202,32,23,186,57,233,108,129,197,74, instruction: F param: 136
Generating data: 239,12,82,145,167,61,151,117,127,221,245,244,222,7,204,83,168,231,246,36,148,185,171,222,36,101,49,63,210,120,30,12,103,52,176,145,233,243,30,98,238,106,140,48,8,81,37,166,8,140,44,65,136,156,112,214,39,187,2,159,60,32,25,119,12,25,13,169,207,125,228,205,24,85,13,142,163,225,229,30,251,4,163,135,80,155,94,206,91,101,110,41,167,66,140,135,166,43,209,36,8,130,87,223,107,240,51,113,251,140,55,232,253,2,23,34,99,249,118,28,211,71,204,128,22,231,215,56,211,44,66,224,225,50,167,113, instruction: K param: 3
instruction: B param: 127
Generating data: 117,88,211,3,224,37,40,217,18,225,57,55,135,106,131,4,186,166,162,176,120,0,254,19,56,43,245,62,39,115,8,237,48,67,36,79,5,226,29,39,86,239,120,179,3,208,211,217,192,159,129,230,137,201,112,171,59,228,89,175,26,244,58,11,130,97,23,255,110,255,180,183,99,22,151,196,95,39,240,53,58,71,19,151,190,64,239,123,248,111,133,12,163,215,172,215,145,122,217,125,164,34,226,94,210,12,232,46,71,205,92,47,109,42,41,229,85,77,118,101,77,64,63,17,86,97,105, instruction: R param: 129
Generating data: 16,76,84,90,12,157,228,164,114,67,223,43,28,77,173,17,96,46,51,125,61,222,173,30,2,4,10,47,155,74,93,110,74,0,46,10,188,124,134,184,13,172,74,114,114,46,164,54,146,44,204,118,178,179,49,215,244,73,234,247,164,229,143,83,166,199,13,226,190,255,233,237,40,7,14,208,33,21,111,62,108,251,42,230,40,86,67,193,213,48,25,180,254,5,19,87,34,90,192,162,21,93,14,119,169,227,155,192,85,199,178,81,210,143,224,36,244,214,84,194,243,21,149,142,165,98,14,69,198, instruction: E param: 2
instruction: D param: 38
Generating data: 103,4,123,238,216,170,67,38,142,247,119,124,62,159,63,222,37,218,72,252,37,170,74,138,157,225,79,2,203,177,81,84,167,38,77,28,211,226, instruction: B param: 45
Generating data: 137,187,27,190,6,156,233,113,200,70,80,148,58,120,4,238,49,68,39,113,6,233,9,87,51,94,227,114,126,140,5,171,209,208,210,146,122,220,124,170,47,18,77,241,77, instruction: L param: 46
Generating data: 254,119,94,174,90,192,199,19,145,155,182,74,17,254,44,87,100,109,117,109,104,66,119,113,37,10,237,160,226,53,4,26,83,148,86,85,103,47,18,235,168,205,8,30,229,6, instruction: I param: 03457
instruction: I param: 047
instruction: D param: 26
Generating data: 77,134,34,30,223,145,46,75,108,107,149,42,217,9,249,101,252,177,161,181,46,97,128,206,171,31, instruction: B param: 23
Generating data: 29,52,114,190,170,16,128,224,254,203,161,232,103,137,46,225,9,55,171,112,161,106,179, instruction: A param: 2
instruction: O param: 4
instruction: K param: 2
instruction: R param: 24
Generating data: 243,179,157,92,20,56,48,105,162,112,208,116,194,59,114,179,110,134,215,11,72,15,75,13, instruction: U param: 44
Generating data: 3,32,84,147,154,167,3,30,117,29,213,67,49,10,199,193,254,249,154,202,32,161,40,48,158,104,252,222,138,134,112,72,244,147,133,155,113,71,202,241,224,47,130,185, instruction: F param: 46
Generating data: 154,208,181,213,143,144,169,38,159,16,179,55,92,205,190,155,6,230,104,136,60,247,130,233,235,174,166,55,149,32,179,207,100,237,114,11,79,16,25,86,255,104,24,76,46,52, instruction: K param: 3
instruction: B param: 33
Generating data: 255,231,195,180,155,136,69,28,110,209,54,172,171,195,150,14,17,153,14,61,88,32,167,185,145,146,3,218,66,215,227,255,204, instruction: E param: 3
instruction: O param: 2
instruction: D param: 40
Generating data: 161,118,252,231,0,33,237,33,136,160,53,211,85,64,221,99,231,254,19,176,101,200,178,221,222,88,255,23,150,188,163,243,90,194,129,21,145,84,59,242, instruction: R param: 32
Generating data: 140,176,130,81,38,191,192,99,237,126,23,75,24,45,104,137,58,245,142,247,240,171,179,192,173,236,101,139,46,226,8,45, instruction: L param: 35
Generating data: 161,84,48,210,184,157,201,156,216,72,234,81,122,171,120,71,121,6,57,89,152,58,140,144,142,171,12,151,93,36,215,43,10,115,199, instruction: U param: 25
Generating data: 183,134,99,203,146,73,90,111,139,157,197,20,220,233,121,235,213,61,188,148,133,185,11,86,50, instruction: R param: 28
Generating data: 147,189,126,143,115,59,136,81,163,60,146,157,151,68,32,172,62,84,204,172,158,101,192,73,211,176,161,10,

The resulting data is produced...
0 (6)
1 (4)
2 (6)
3 (7)
4 (10)
5 (5)
6 (6)
7 (4)
8 (13)
9 (7)
10 (13)
11 (9)
12 (13)
13 (7)
14 (9)
15 (3)
16 (9)
17 (9)
18 (7)
19 (9)
20 (7)
21 (10)
22 (4)
23 (9)
24 (12)
25 (7)
26 (5)
27 (1)
28 (6)
29 (8)
30 (11)
31 (8)
32 (8)
33 (11)
34 (11)
35 (6)
36 (12)
37 (12)
38 (6)
39 (8)
40 (9)
41 (6)
42 (8)
43 (6)
44 (5)
45 (9)
46 (13)
47 (13)
48 (17)
49 (9)
50 (3)
51 (5)
52 (8)
53 (10)
54 (9)
55 (11)
56 (9)
57 (6)
58 (11)
59 (5)
60 (10)
61 (9)
62 (9)
63 (7)
64 (4)
65 (3)
66 (8)
67 (9)
68 (5)
69 (11)
70 (4)
71 (8)
72 (9)
73 (6)
74 (8)
75 (11)
76 (8)
77 (11)
78 (2)
79 (8)
80 (8)
81 (11)
82 (7)
83 (9)
84 (13)
85 (9)
86 (9)
87 (8)
88 (7)
89 (4)
90 (7)
91 (9)
92 (6)
93 (10)
94 (4)
95 (9)
96 (7)
97 (8)
98 (9)
99 (11)
100 (5)
101 (12)
102 (3)
103 (7)
104 (15)
105 (5)
106 (5)
107 (3)
108 (6)
109 (6)
110 (14)
111 (5)
112 (10)
113 (7)
114 (11)
115 (7)
116 (5)
117 (10)
118 (7)
119 (9)
120 (8)
121 (7)
122 (9)
123 (4)
124 (3)
125 (7)
126 (8)
127 (6)
128 (7)
129 (8)
130 (10)
131 (9)
132 (2)
133 (7)
134 (12)
135 (8)
136 (8)
137 (7)
138 (8)
139 (4)
140 (10)
141 (6)
142 (10)
143 (11)
144 (9)
145 (11)
146 (11)
147 (6)
148 (10)
149 (6)
150 (3)
151 (8)
152 (4)
153 (1)
154 (6)
155 (11)
156 (4)
157 (10)
158 (8)
159 (6)
160 (7)
161 (9)
162 (8)
163 (6)
164 (6)
165 (6)
166 (10)
167 (8)
168 (6)
169 (9)
170 (5)
171 (15)
172 (10)
173 (7)
174 (3)
175 (5)
176 (6)
177 (5)
178 (9)
179 (12)
180 (5)
181 (3)
182 (4)
183 (4)
184 (5)
185 (4)
186 (6)
187 (4)
188 (11)
189 (5)
190 (7)
191 (4)
192 (8)
193 (11)
194 (8)
195 (8)
196 (5)
197 (5)
198 (4)
199 (10)
200 (7)
201 (6)
202 (6)
203 (5)
204 (10)
205 (8)
206 (6)
207 (7)
208 (10)
209 (5)
210 (9)
211 (7)
212 (1)
213 (7)
214 (6)
215 (10)
216 (5)
217 (9)
218 (3)
219 (3)
220 (4)
221 (7)
222 (7)
223 (8)
224 (7)
225 (9)
226 (10)
227 (8)
228 (8)
229 (8)
230 (5)
231 (12)
232 (6)
233 (11)
234 (2)
235 (9)
236 (3)
237 (9)
238 (6)
239 (6)
240 (11)
241 (4)
242 (2)
243 (6)
244 (10)
245 (7)
246 (4)
247 (7)
248 (4)
249 (6)
250 (3)
251 (5)
252 (6)
253 (2)
254 (11)
255 (10)
After processing these instructions, the current state of the map is:
z 0  x0   x1   x2   x3   x4   x5   
y0
130
159
1
220
177
40

y1
224
31
253
182
186
176

y2
164
73
84
243
50
11

y3
198
221
59
198
70
131

y4
153
198
0
11
74
81

y5
249
121
26
28
178
181

y6
114
115
92
238
153
26

z 1  x0   x1   x2   x3   x4   x5   
y0
26
199
114
183
235
81

y1
159
179
184
171
36
52

y2
221
230
121
40
124
92

y3
201
185
21
113
78
107

y4
181
41
152
241
255
9

y5
244
211
226
50
50
207

y6
28
36
85
42
78
37

z 2  x0   x1   x2   x3   x4   x5   
y0
32
45
102
251
93
99

y1
55
214
20
22
67
218

y2
162
119
132
132
50
7

y3
88
250
78
131
130
70

y4
102
100
238
73
162
237

y5
243
227
48
253
199
8

y6
171
63
12
232
223
220

z 3  x0   x1   x2   x3   x4   x5   
y0
129
116
125
26
118
52

y1
151
126
150
220
57
232

y2
238
164
127
209
16
243

y3
190
149
87
193
161
211

y4
102
127
24
147
207
254

y5
164
153
123
213
59
202

y6
138
193
79
163
22
88

z 4  x0   x1   x2   x3   x4   x5   
y0
199
172
194
250
85
198

y1
193
135
32
55
226
107

y2
116
34
196
244
137
231

y3
149
172
247
21
255
45

y4
91
147
186
254
231
172

y5
76
184
231
234
180
152

y6
154
45
69
109
199
162

z 5  x0   x1   x2   x3   x4   x5   
y0
34
225
186
230
233
179

y1
222
204
239
32
124
127

y2
176
221
33
145
151
58

y3
169
211
212
88
172
213

y4
54
237
161
16
209
237

y5
141
125
0
200
138
120

y6
30
108
70
115
171
190

z 6  x0   x1   x2   x3   x4   x5   
y0
228
221
121
242
230
213

y1
111
14
83
218
120
227

y2
129
6
211
218
105
22

y3
61
245
146
20
243
209

y4
206
147
180
253
245
98

y5
20
100
226
89
25
138

y6
218
246
254
217
36
53

z 7  x0   x1   x2   x3   x4   x5   
y0
235
54
99
220
195
207

y1
75
81
131
135
244
13

y2
183
231
93
43
187
18

y3
242
170
30
115
255
179

y4
85
85
218
252
87
192

y5
157
224
16
189
133
64

y6
158
137
197
220
148
248

Continuous production of the instruction stream is not described in this document, but the high 'running instruction ratio' means there is a reasonable positive entropy gradient. Considering 1896 values have been generated by 44 instructions, it should be reasonably easy to produce a reliable number of new instructions in a manner only predictable to those that have the initial 'secret' or maze state.

The initial instruction string contains several three-digit traversal instructions, and instructions like 'I03457' (invert output bits 0,3,4,5,7) could be easily generated from one or two bytes of newly-generated noise.


Now, the encrypting..

We can now encrypt the text: This is my secret message into an unrecognizable stream: XÈ£ô…èñP±µP5&/sˆµ$)ÎTºàúÁ.

Reversing the modification turns: XÈ£ô…èñP±µP5&/sˆµ$)ÎTºàúÁ back into: This is my secret message. Both parties must know the 'state' and 'grid values' to communicate to the other party.

It is critical that both parties are communicating using synchronized transactions in order for the generated stream to remain identical on both sides. Current plans are to add 'calculated checkpoints' so that if synchronization is lost - both parties can attempt to resynchronize where the next scheduled 'checkpoint' is calculated to be.

It is planned for ratPad to provide a shared-secret key-exchange algorithm that allows two parties to establish fully-populated 'grids' without disclosing critical metadata.

  1. both parties generate parameters from 'secret'
  2. both parties populate grid with random data
  3. both parties begin traversing instruction path and transmitting their grid data to the other
  4. both parties record incoming grid data and store in local copy of 'remote' grid
  5. after a pre-determined checkpoint, both parties evaluate whether grids are fully populated
  6. if both parties are not fully-populated with grid data, they continue processing until the next scheduled checkpoint
  7. obscurity can be enhanced by discarding some scheduled data to generate entropy and transmitting nonsense until the agreed checkpoint.
  8. once both parties have filled in grid data, encrypted bi-directional communication can begin

While this method surely isn't full-proof, the burden of calculating on an unknown quantity of potentially meaningless data makes prediction difficult.