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
    179
    122
    193
    25
    13
    17

    y1
    198
    40
    83
    54
    197
    130

    y2
    136
    251
    103
    96
    69
    51

    y3
    39
    152
    224
    57
    183
    110

    y4
    34
    177
    177
    254
    59
    195

    y5
    153
    248
    94
    64
    44
    4

    y6
    77
    237
    34
    53
    132
    98

    z 1  x0   x1   x2   x3   x4   x5   
    y0
    23
    146
    191
    231
    233
    67

    y1
    237
    26
    108
    235
    10
    89

    y2
    244
    1
    95
    173
    136
    82

    y3
    113
    175
    240
    195
    155
    162

    y4
    69
    244
    47
    11
    161
    3

    y5
    51
    231
    85
    96
    205
    17

    y6
    210
    23
    21
    103
    249
    121

    z 2  x0   x1   x2   x3   x4   x5   
    y0
    12
    182
    56
    237
    151
    68

    y1
    60
    46
    132
    228
    72
    249

    y2
    31
    39
    112
    234
    39
    246

    y3
    147
    16
    182
    119
    23
    186

    y4
    27
    190
    38
    198
    184
    67

    y5
    229
    223
    138
    176
    172
    65

    y6
    45
    99
    56
    85
    13
    193

    z 3  x0   x1   x2   x3   x4   x5   
    y0
    10
    146
    220
    213
    148
    211

    y1
    248
    174
    8
    74
    246
    42

    y2
    8
    9
    97
    162
    44
    252

    y3
    16
    215
    6
    201
    38
    114

    y4
    105
    113
    156
    239
    170
    92

    y5
    182
    151
    161
    105
    208
    124

    y6
    54
    136
    93
    133
    224
    106

    z 4  x0   x1   x2   x3   x4   x5   
    y0
    241
    39
    99
    6
    242
    2

    y1
    104
    53
    64
    101
    156
    15

    y2
    154
    27
    218
    47
    38
    94

    y3
    35
    204
    50
    228
    109
    207

    y4
    171
    1
    28
    128
    57
    206

    y5
    228
    135
    53
    79
    11
    191

    y6
    227
    8
    78
    38
    147
    104

    z 5  x0   x1   x2   x3   x4   x5   
    y0
    179
    82
    240
    55
    64
    85

    y1
    2
    30
    112
    80
    165
    67

    y2
    241
    72
    150
    115
    74
    174

    y3
    182
    58
    183
    203
    29
    212

    y4
    86
    48
    79
    122
    237
    21

    y5
    201
    244
    247
    253
    244
    128

    y6
    135
    75
    18
    13
    90
    251

    z 6  x0   x1   x2   x3   x4   x5   
    y0
    130
    207
    185
    79
    209
    49

    y1
    29
    17
    121
    204
    75
    239

    y2
    126
    14
    165
    133
    17
    103

    y3
    245
    72
    74
    247
    7
    219

    y4
    177
    64
    85
    10
    130
    13

    y5
    233
    237
    127
    51
    233
    36

    y6
    54
    146
    124
    166
    217
    47

    z 7  x0   x1   x2   x3   x4   x5   
    y0
    99
    191
    34
    176
    108
    120

    y1
    14
    230
    106
    71
    129
    249

    y2
    149
    75
    84
    63
    165
    164

    y3
    29
    92
    79
    81
    149
    149

    y4
    56
    178
    223
    105
    144
    192

    y5
    237
    215
    117
    5
    7
    7

    y6
    206
    178
    18
    201
    169
    241


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

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

y1
198
40
83
227
197
130

y2
60
27
0
248
67
117

y3
39
152
224
240
183
110

y4
34
177
177
153
59
195

y5
153
248
94
193
44
4

y6
77
237
34
245
132
98

z 1  x0   x1   x2   x3   x4   x5   
y0
23
170
191
231
233
67

y1
237
26
108
235
10
89

y2
244
1
95
173
136
0

y3
113
175
240
195
155
162

y4
69
244
47
151
161
3

y5
51
231
85
235
205
17

y6
210
23
21
103
249
121

z 2  x0   x1   x2   x3   x4   x5   
y0
12
69
56
224
151
68

y1
60
219
132
180
72
249

y2
31
251
112
80
39
159

y3
147
244
182
71
23
186

y4
27
84
38
235
184
249

y5
229
162
138
167
172
65

y6
45
81
56
244
91
3

z 3  x0   x1   x2   x3   x4   x5   
y0
10
255
220
213
148
211

y1
248
174
8
74
246
42

y2
8
9
97
162
44
209

y3
16
215
6
201
38
114

y4
105
113
156
186
170
92

y5
182
151
161
0
208
124

y6
54
136
93
133
224
106

z 4  x0   x1   x2   x3   x4   x5   
y0
241
182
99
6
242
2

y1
104
53
64
101
156
15

y2
154
27
218
47
38
163

y3
35
204
50
228
109
207

y4
171
1
28
215
57
206

y5
228
135
53
22
11
191

y6
227
8
78
38
147
104

z 5  x0   x1   x2   x3   x4   x5   
y0
179
14
240
55
64
45

y1
2
30
112
80
165
53

y2
241
72
150
115
74
217

y3
182
58
183
203
29
57

y4
0
95
59
198
84
59

y5
201
244
247
58
244
110

y6
135
75
18
13
90
91

z 6  x0   x1   x2   x3   x4   x5   
y0
130
17
185
224
209
49

y1
29
162
121
18
75
239

y2
126
230
165
214
17
178

y3
245
27
74
215
7
219

y4
177
250
85
255
130
13

y5
173
210
127
44
233
36

y6
54
227
124
7
217
95

z 7  x0   x1   x2   x3   x4   x5   
y0
99
155
34
176
108
120

y1
14
230
106
71
129
249

y2
149
75
84
63
165
235

y3
29
92
79
81
149
149

y4
56
178
223
242
144
192

y5
237
215
117
223
7
7

y6
206
178
18
201
169
241

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: ¿ìGq@IëßfÀÅgOÎÂR{è8ü%@.

Reversing the modification turns: ¿ìGq@IëßfÀÅgOÎÂR{è8ü%@ 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.