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
    108
    55
    60
    152
    26
    131

    y1
    102
    46
    47
    43
    110
    9

    y2
    104
    188
    245
    230
    96
    237

    y3
    63
    191
    2
    123
    28
    217

    y4
    240
    101
    29
    153
    93
    196

    y5
    134
    111
    80
    13
    116
    92

    y6
    253
    82
    190
    194
    134
    235

    z 1  x0   x1   x2   x3   x4   x5   
    y0
    32
    100
    214
    231
    47
    102

    y1
    175
    153
    164
    124
    30
    12

    y2
    212
    248
    81
    174
    16
    246

    y3
    181
    240
    130
    61
    190
    22

    y4
    144
    87
    209
    219
    203
    240

    y5
    139
    62
    61
    140
    161
    156

    y6
    143
    171
    205
    36
    89
    145

    z 2  x0   x1   x2   x3   x4   x5   
    y0
    45
    11
    142
    18
    54
    70

    y1
    99
    7
    158
    98
    171
    42

    y2
    126
    131
    63
    122
    16
    209

    y3
    80
    249
    66
    23
    236
    45

    y4
    183
    250
    126
    76
    41
    107

    y5
    125
    31
    19
    72
    152
    161

    y6
    110
    136
    101
    208
    39
    166

    z 3  x0   x1   x2   x3   x4   x5   
    y0
    210
    122
    102
    194
    229
    221

    y1
    231
    255
    85
    2
    2
    85

    y2
    168
    251
    84
    140
    156
    111

    y3
    117
    246
    11
    58
    220
    108

    y4
    146
    246
    252
    98
    198
    212

    y5
    173
    78
    90
    79
    178
    7

    y6
    193
    53
    79
    123
    86
    248

    z 4  x0   x1   x2   x3   x4   x5   
    y0
    175
    228
    236
    186
    19
    19

    y1
    41
    32
    247
    102
    105
    165

    y2
    6
    111
    27
    252
    185
    84

    y3
    62
    146
    152
    0
    158
    26

    y4
    65
    157
    183
    89
    228
    255

    y5
    146
    79
    188
    58
    42
    161

    y6
    70
    163
    75
    54
    55
    122

    z 5  x0   x1   x2   x3   x4   x5   
    y0
    81
    224
    216
    212
    98
    104

    y1
    251
    196
    237
    110
    165
    210

    y2
    55
    52
    228
    31
    41
    94

    y3
    109
    34
    157
    166
    177
    237

    y4
    117
    234
    10
    155
    29
    194

    y5
    95
    20
    100
    227
    193
    4

    y6
    202
    155
    82
    83
    135
    66

    z 6  x0   x1   x2   x3   x4   x5   
    y0
    83
    17
    123
    106
    72
    87

    y1
    11
    224
    154
    193
    85
    107

    y2
    132
    44
    132
    110
    69
    186

    y3
    42
    90
    71
    239
    175
    74

    y4
    4
    35
    9
    143
    0
    29

    y5
    47
    59
    221
    169
    71
    187

    y6
    88
    38
    224
    131
    29
    82

    z 7  x0   x1   x2   x3   x4   x5   
    y0
    24
    164
    88
    156
    17
    156

    y1
    20
    63
    196
    112
    20
    70

    y2
    1
    210
    189
    4
    29
    246

    y3
    197
    7
    215
    188
    42
    57

    y4
    255
    25
    203
    53
    132
    4

    y5
    0
    187
    15
    249
    38
    79

    y6
    91
    237
    29
    203
    146
    69


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

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

y1
102
46
47
130
110
9

y2
246
236
175
242
166
2

y3
63
191
2
229
28
217

y4
240
101
29
233
93
196

y5
134
111
80
35
116
92

y6
253
82
190
37
134
235

z 1  x0   x1   x2   x3   x4   x5   
y0
32
74
214
231
47
102

y1
175
153
164
124
30
12

y2
212
248
81
174
16
100

y3
181
240
130
61
190
22

y4
144
87
209
254
203
240

y5
139
62
61
39
161
156

y6
143
171
205
36
89
145

z 2  x0   x1   x2   x3   x4   x5   
y0
45
254
142
170
54
70

y1
99
207
158
235
171
42

y2
126
163
63
97
16
200

y3
80
204
66
219
236
45

y4
183
226
126
250
41
125

y5
125
245
19
215
152
161

y6
110
230
101
236
246
58

z 3  x0   x1   x2   x3   x4   x5   
y0
210
168
102
194
229
221

y1
231
255
85
2
2
85

y2
168
251
84
140
156
103

y3
117
246
11
58
220
108

y4
146
246
252
103
198
212

y5
173
78
90
55
178
7

y6
193
53
79
123
86
248

z 4  x0   x1   x2   x3   x4   x5   
y0
175
214
236
186
19
19

y1
41
32
247
102
105
165

y2
6
111
27
252
185
182

y3
62
146
152
0
158
26

y4
65
157
183
220
228
255

y5
146
79
188
27
42
161

y6
70
163
75
54
55
122

z 5  x0   x1   x2   x3   x4   x5   
y0
81
119
216
212
98
57

y1
251
196
237
110
165
58

y2
55
52
228
31
41
253

y3
109
34
157
166
177
192

y4
38
217
147
158
216
97

y5
95
20
100
31
193
48

y6
202
155
82
83
135
115

z 6  x0   x1   x2   x3   x4   x5   
y0
83
23
123
61
72
87

y1
11
214
154
83
85
107

y2
132
144
132
222
69
51

y3
42
162
71
125
175
74

y4
4
178
9
13
0
29

y5
21
46
221
199
71
187

y6
88
232
224
222
29
250

z 7  x0   x1   x2   x3   x4   x5   
y0
24
3
88
156
17
156

y1
20
63
196
112
20
70

y2
1
210
189
4
29
102

y3
197
7
215
188
42
57

y4
255
25
203
95
132
4

y5
0
187
15
29
38
79

y6
91
237
29
203
146
69

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: ïÁ;+îζPT© A5XƒE€ugói•�¼Ô.

Reversing the modification turns: ïÁ;+îζPT© A5XƒE€ugói•�¼Ô 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.