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
    38
    222
    55
    55
    62
    247

    y1
    155
    135
    102
    213
    165
    143

    y2
    44
    232
    111
    20
    239
    0

    y3
    131
    29
    26
    174
    218
    212

    y4
    19
    234
    137
    219
    182
    11

    y5
    85
    100
    124
    163
    201
    135

    y6
    210
    180
    204
    35
    188
    196

    z 1  x0   x1   x2   x3   x4   x5   
    y0
    140
    254
    100
    128
    25
    69

    y1
    49
    103
    122
    40
    193
    48

    y2
    212
    17
    155
    208
    32
    209

    y3
    133
    94
    49
    197
    167
    208

    y4
    55
    173
    113
    147
    219
    85

    y5
    147
    228
    28
    174
    66
    21

    y6
    68
    198
    1
    62
    45
    170

    z 2  x0   x1   x2   x3   x4   x5   
    y0
    187
    171
    35
    100
    153
    14

    y1
    200
    148
    196
    85
    159
    71

    y2
    13
    248
    20
    209
    250
    182

    y3
    138
    32
    208
    88
    163
    235

    y4
    226
    56
    99
    167
    170
    142

    y5
    21
    225
    134
    37
    29
    218

    y6
    196
    219
    56
    225
    226
    189

    z 3  x0   x1   x2   x3   x4   x5   
    y0
    169
    28
    88
    220
    3
    168

    y1
    68
    38
    113
    102
    102
    241

    y2
    146
    81
    35
    67
    89
    154

    y3
    36
    86
    230
    45
    100
    185

    y4
    170
    148
    102
    35
    67
    186

    y5
    98
    195
    38
    188
    5
    232

    y6
    6
    81
    225
    218
    73
    216

    z 4  x0   x1   x2   x3   x4   x5   
    y0
    43
    8
    235
    108
    127
    30

    y1
    180
    66
    199
    82
    67
    207

    y2
    185
    191
    152
    187
    224
    195

    y3
    173
    101
    209
    211
    24
    193

    y4
    193
    174
    91
    227
    48
    68

    y5
    245
    188
    89
    6
    96
    110

    y6
    67
    33
    69
    19
    79
    119

    z 5  x0   x1   x2   x3   x4   x5   
    y0
    21
    244
    40
    51
    216
    220

    y1
    199
    100
    72
    12
    16
    88

    y2
    205
    147
    119
    247
    194
    65

    y3
    215
    246
    37
    113
    222
    51

    y4
    93
    212
    91
    246
    230
    173

    y5
    245
    181
    206
    142
    151
    131

    y6
    52
    60
    183
    210
    238
    235

    z 6  x0   x1   x2   x3   x4   x5   
    y0
    1
    217
    140
    130
    41
    185

    y1
    29
    158
    170
    53
    95
    118

    y2
    154
    217
    177
    196
    206
    113

    y3
    92
    177
    34
    29
    12
    157

    y4
    78
    154
    109
    193
    102
    237

    y5
    220
    208
    248
    136
    45
    30

    y6
    134
    114
    54
    78
    137
    32

    z 7  x0   x1   x2   x3   x4   x5   
    y0
    0
    224
    104
    18
    105
    248

    y1
    84
    226
    47
    243
    189
    199

    y2
    9
    160
    50
    211
    150
    161

    y3
    80
    67
    8
    254
    5
    214

    y4
    116
    173
    253
    200
    81
    186

    y5
    72
    253
    172
    124
    10
    225

    y6
    23
    65
    8
    73
    214
    145


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

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

y1
155
135
102
10
165
143

y2
89
83
47
3
245
107

y3
131
29
26
6
218
212

y4
19
234
137
223
182
11

y5
85
100
124
236
201
135

y6
210
180
204
68
188
196

z 1  x0   x1   x2   x3   x4   x5   
y0
140
175
100
128
25
69

y1
49
103
122
40
193
48

y2
212
17
155
208
32
14

y3
133
94
49
197
167
208

y4
55
173
113
210
219
85

y5
147
228
28
175
66
21

y6
68
198
1
62
45
170

z 2  x0   x1   x2   x3   x4   x5   
y0
187
177
35
122
153
14

y1
200
7
196
21
159
71

y2
13
176
20
255
250
176

y3
138
84
208
41
163
235

y4
226
230
99
9
170
194

y5
21
124
134
20
29
218

y6
196
64
56
194
159
58

z 3  x0   x1   x2   x3   x4   x5   
y0
169
208
88
220
3
168

y1
68
38
113
102
102
241

y2
146
81
35
67
89
96

y3
36
86
230
45
100
185

y4
170
148
102
93
67
186

y5
98
195
38
104
5
232

y6
6
81
225
218
73
216

z 4  x0   x1   x2   x3   x4   x5   
y0
43
65
235
108
127
30

y1
180
66
199
82
67
207

y2
185
191
152
187
224
147

y3
173
101
209
211
24
193

y4
193
174
91
23
48
68

y5
245
188
89
194
96
110

y6
67
33
69
19
79
119

z 5  x0   x1   x2   x3   x4   x5   
y0
21
223
40
51
216
84

y1
199
100
72
12
16
100

y2
205
147
119
247
194
249

y3
215
246
37
113
222
199

y4
17
210
233
184
252
35

y5
245
181
206
137
151
92

y6
52
60
183
210
238
46

z 6  x0   x1   x2   x3   x4   x5   
y0
1
53
140
152
41
185

y1
29
180
170
131
95
118

y2
154
200
177
181
206
74

y3
92
10
34
141
12
157

y4
78
252
109
4
102
237

y5
163
28
248
45
45
30

y6
134
245
54
220
137
97

z 7  x0   x1   x2   x3   x4   x5   
y0
0
254
104
18
105
248

y1
84
226
47
243
189
199

y2
9
160
50
211
150
41

y3
80
67
8
254
5
214

y4
116
173
253
123
81
186

y5
72
253
172
9
10
225

y6
23
65
8
73
214
145

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: ´}ßµ¹üƽÔ[‰jhy™EoÀ1s«æ.

Reversing the modification turns: ´}ßµ¹üƽÔ[‰jhy™EoÀ1s«æ 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.