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
    40
    44
    72
    134
    163
    51

    y1
    17
    246
    234
    70
    177
    117

    y2
    172
    250
    34
    8
    139
    130

    y3
    163
    227
    225
    235
    19
    114

    y4
    250
    190
    55
    155
    186
    36

    y5
    52
    179
    67
    113
    77
    217

    y6
    72
    186
    197
    80
    53
    108

    z 1  x0   x1   x2   x3   x4   x5   
    y0
    126
    153
    185
    46
    20
    184

    y1
    14
    86
    105
    239
    188
    172

    y2
    140
    71
    154
    80
    118
    238

    y3
    150
    14
    127
    186
    131
    83

    y4
    24
    102
    38
    206
    71
    2

    y5
    152
    167
    126
    68
    57
    222

    y6
    185
    99
    194
    153
    229
    7

    z 2  x0   x1   x2   x3   x4   x5   
    y0
    136
    251
    148
    229
    193
    183

    y1
    243
    121
    221
    239
    1
    231

    y2
    40
    37
    178
    87
    27
    95

    y3
    39
    249
    252
    240
    157
    59

    y4
    227
    6
    214
    154
    245
    227

    y5
    18
    40
    241
    52
    80
    104

    y6
    82
    166
    70
    121
    112
    229

    z 3  x0   x1   x2   x3   x4   x5   
    y0
    241
    170
    113
    220
    38
    148

    y1
    92
    233
    211
    122
    65
    155

    y2
    252
    224
    19
    111
    112
    193

    y3
    233
    235
    93
    46
    169
    144

    y4
    180
    63
    129
    192
    86
    65

    y5
    229
    30
    37
    103
    105
    107

    y6
    212
    160
    140
    107
    165
    54

    z 4  x0   x1   x2   x3   x4   x5   
    y0
    95
    164
    76
    102
    192
    245

    y1
    104
    254
    237
    168
    152
    48

    y2
    225
    193
    109
    63
    255
    42

    y3
    160
    155
    63
    22
    59
    123

    y4
    15
    80
    137
    143
    181
    13

    y5
    194
    179
    253
    26
    15
    143

    y6
    255
    112
    40
    5
    128
    184

    z 5  x0   x1   x2   x3   x4   x5   
    y0
    185
    60
    183
    11
    253
    197

    y1
    143
    143
    63
    98
    150
    23

    y2
    113
    183
    206
    134
    120
    237

    y3
    247
    237
    93
    76
    31
    58

    y4
    206
    171
    229
    34
    122
    210

    y5
    177
    146
    86
    255
    197
    145

    y6
    12
    231
    23
    222
    144
    191

    z 6  x0   x1   x2   x3   x4   x5   
    y0
    198
    30
    146
    22
    182
    121

    y1
    242
    220
    171
    180
    89
    191

    y2
    2
    137
    22
    102
    186
    203

    y3
    37
    185
    40
    55
    98
    240

    y4
    107
    126
    197
    237
    222
    153

    y5
    86
    192
    195
    248
    92
    187

    y6
    23
    102
    41
    45
    223
    216

    z 7  x0   x1   x2   x3   x4   x5   
    y0
    38
    194
    113
    151
    163
    122

    y1
    253
    41
    49
    177
    164
    12

    y2
    18
    15
    36
    201
    147
    186

    y3
    24
    3
    135
    133
    163
    185

    y4
    10
    199
    149
    132
    246
    41

    y5
    0
    41
    226
    29
    164
    207

    y6
    108
    166
    52
    5
    77
    74


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

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

y1
17
246
234
230
177
117

y2
148
241
70
204
26
202

y3
163
227
225
175
19
114

y4
250
190
55
49
186
36

y5
52
179
67
208
77
217

y6
72
186
197
15
53
108

z 1  x0   x1   x2   x3   x4   x5   
y0
126
107
185
46
20
184

y1
14
86
105
239
188
172

y2
140
71
154
80
118
172

y3
150
14
127
186
131
83

y4
24
102
38
180
71
2

y5
152
167
126
219
57
222

y6
185
99
194
153
229
7

z 2  x0   x1   x2   x3   x4   x5   
y0
136
217
148
254
193
183

y1
243
157
221
252
1
231

y2
40
251
178
160
27
174

y3
39
94
252
254
157
59

y4
227
183
214
235
245
236

y5
18
27
241
55
80
104

y6
82
195
70
12
5
38

z 3  x0   x1   x2   x3   x4   x5   
y0
241
58
113
220
38
148

y1
92
233
211
122
65
155

y2
252
224
19
111
112
179

y3
233
235
93
46
169
144

y4
180
63
129
211
86
65

y5
229
30
37
4
105
107

y6
212
160
140
107
165
54

z 4  x0   x1   x2   x3   x4   x5   
y0
95
220
76
102
192
245

y1
104
254
237
168
152
48

y2
225
193
109
63
255
87

y3
160
155
63
22
59
123

y4
15
80
137
219
181
13

y5
194
179
253
144
15
143

y6
255
112
40
5
128
184

z 5  x0   x1   x2   x3   x4   x5   
y0
185
241
183
11
253
247

y1
143
143
63
98
150
251

y2
113
183
206
134
120
81

y3
247
237
93
76
31
180

y4
196
226
0
132
110
248

y5
177
146
86
3
197
255

y6
12
231
23
222
144
255

z 6  x0   x1   x2   x3   x4   x5   
y0
198
224
146
200
182
121

y1
242
122
171
20
89
191

y2
2
143
22
249
186
49

y3
37
75
40
224
98
240

y4
107
5
197
60
222
153

y5
247
23
195
119
92
187

y6
23
62
41
183
223
26

z 7  x0   x1   x2   x3   x4   x5   
y0
38
158
113
151
163
122

y1
253
41
49
177
164
12

y2
18
15
36
201
147
99

y3
24
3
135
133
163
185

y4
10
199
149
1
246
41

y5
0
41
226
45
164
207

y6
108
166
52
5
77
74

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: P2¶L³J5ke!¯Sµþ0·¬ÖÝ‹RQ.

Reversing the modification turns: P2¶L³J5ke!¯Sµþ0·¬ÖÝ‹RQ 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.