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
    76
    120
    250
    79
    237
    174

    y1
    51
    7
    150
    110
    116
    234

    y2
    87
    25
    124
    249
    217
    124

    y3
    15
    27
    51
    255
    100
    9

    y4
    87
    15
    103
    12
    20
    163

    y5
    191
    222
    131
    72
    166
    194

    y6
    241
    193
    177
    240
    219
    19

    z 1  x0   x1   x2   x3   x4   x5   
    y0
    175
    228
    168
    38
    88
    96

    y1
    7
    37
    50
    144
    186
    56

    y2
    89
    43
    231
    193
    109
    10

    y3
    44
    229
    46
    29
    243
    144

    y4
    203
    152
    13
    141
    155
    147

    y5
    126
    101
    186
    229
    193
    169

    y6
    50
    192
    29
    170
    105
    8

    z 2  x0   x1   x2   x3   x4   x5   
    y0
    255
    224
    142
    129
    161
    30

    y1
    0
    86
    203
    57
    181
    163

    y2
    3
    102
    105
    113
    34
    238

    y3
    243
    203
    111
    84
    109
    173

    y4
    58
    174
    132
    156
    27
    3

    y5
    145
    195
    165
    167
    107
    202

    y6
    28
    48
    99
    224
    188
    159

    z 3  x0   x1   x2   x3   x4   x5   
    y0
    174
    112
    134
    28
    50
    225

    y1
    49
    159
    4
    76
    3
    227

    y2
    238
    81
    82
    192
    73
    192

    y3
    51
    106
    200
    27
    195
    125

    y4
    40
    91
    18
    125
    57
    251

    y5
    159
    103
    150
    195
    252
    63

    y6
    89
    190
    35
    206
    176
    96

    z 4  x0   x1   x2   x3   x4   x5   
    y0
    117
    86
    117
    222
    118
    78

    y1
    95
    88
    154
    187
    74
    91

    y2
    234
    196
    29
    106
    184
    1

    y3
    181
    71
    143
    35
    12
    53

    y4
    56
    81
    68
    17
    41
    66

    y5
    89
    173
    13
    239
    89
    36

    y6
    248
    214
    32
    111
    9
    202

    z 5  x0   x1   x2   x3   x4   x5   
    y0
    109
    46
    117
    54
    237
    119

    y1
    105
    9
    192
    194
    74
    150

    y2
    195
    168
    65
    159
    153
    77

    y3
    0
    131
    35
    161
    183
    77

    y4
    126
    119
    237
    10
    184
    244

    y5
    130
    212
    15
    17
    132
    207

    y6
    211
    131
    107
    117
    26
    8

    z 6  x0   x1   x2   x3   x4   x5   
    y0
    197
    19
    216
    233
    171
    208

    y1
    87
    200
    240
    10
    172
    74

    y2
    31
    77
    147
    215
    200
    228

    y3
    72
    42
    47
    186
    215
    30

    y4
    255
    204
    4
    152
    6
    75

    y5
    29
    189
    169
    178
    182
    181

    y6
    140
    64
    120
    160
    93
    139

    z 7  x0   x1   x2   x3   x4   x5   
    y0
    108
    130
    198
    115
    17
    209

    y1
    46
    119
    217
    168
    19
    163

    y2
    187
    184
    168
    195
    69
    4

    y3
    20
    146
    232
    182
    232
    193

    y4
    98
    147
    28
    186
    215
    19

    y5
    76
    206
    182
    251
    76
    184

    y6
    218
    162
    123
    138
    184
    73


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

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

y1
51
7
150
110
116
234

y2
180
201
58
177
78
136

y3
15
27
51
8
100
9

y4
87
15
103
190
20
163

y5
191
222
131
5
166
194

y6
241
193
177
198
219
19

z 1  x0   x1   x2   x3   x4   x5   
y0
175
156
168
38
88
96

y1
7
37
50
144
186
56

y2
89
43
231
193
109
238

y3
44
229
46
29
243
144

y4
203
152
13
122
155
147

y5
126
101
186
146
193
169

y6
50
192
29
170
105
8

z 2  x0   x1   x2   x3   x4   x5   
y0
255
57
142
120
161
30

y1
0
59
203
140
181
163

y2
3
61
105
231
34
156

y3
243
233
111
239
109
173

y4
58
219
132
234
27
159

y5
145
242
165
29
107
202

y6
28
232
99
211
240
132

z 3  x0   x1   x2   x3   x4   x5   
y0
174
92
134
28
50
225

y1
49
159
4
76
3
227

y2
238
81
82
192
73
57

y3
51
106
200
27
195
125

y4
40
91
18
63
57
251

y5
159
103
150
37
252
63

y6
89
190
35
206
176
96

z 4  x0   x1   x2   x3   x4   x5   
y0
117
66
117
222
118
78

y1
95
88
154
187
74
91

y2
234
196
29
106
184
87

y3
181
71
143
35
12
53

y4
56
81
68
155
41
66

y5
89
173
13
206
89
36

y6
248
214
32
111
9
202

z 5  x0   x1   x2   x3   x4   x5   
y0
109
5
117
54
237
222

y1
105
9
192
194
74
172

y2
195
168
65
159
153
148

y3
0
131
35
161
183
201

y4
170
120
60
172
217
101

y5
130
212
15
0
132
183

y6
211
131
107
117
26
91

z 6  x0   x1   x2   x3   x4   x5   
y0
197
227
216
4
171
208

y1
87
8
240
238
172
74

y2
31
240
147
212
200
208

y3
72
208
47
6
215
30

y4
255
212
4
140
6
75

y5
231
137
169
160
182
181

y6
140
156
120
239
93
109

z 7  x0   x1   x2   x3   x4   x5   
y0
108
171
198
115
17
209

y1
46
119
217
168
19
163

y2
187
184
168
195
69
49

y3
20
146
232
182
232
193

y4
98
147
28
57
215
19

y5
76
206
182
211
76
184

y6
218
162
123
138
184
73

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: ’’š(‡„\vxNü)d¡Ì2ÎÐ@¨KuZ.

Reversing the modification turns: ’’š(‡„\vxNü)d¡Ì2ÎÐ@¨KuZ 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.