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
    37
    57
    181
    26
    16
    98

    y1
    149
    151
    87
    12
    120
    186

    y2
    192
    188
    87
    223
    182
    138

    y3
    169
    178
    179
    239
    81
    131

    y4
    165
    231
    159
    206
    171
    137

    y5
    94
    10
    213
    169
    19
    6

    y6
    116
    20
    209
    58
    164
    155

    z 1  x0   x1   x2   x3   x4   x5   
    y0
    81
    233
    251
    34
    87
    27

    y1
    44
    9
    68
    231
    181
    60

    y2
    23
    212
    181
    167
    27
    36

    y3
    66
    67
    244
    248
    90
    236

    y4
    51
    109
    21
    75
    8
    58

    y5
    241
    176
    115
    246
    254
    205

    y6
    223
    142
    32
    54
    30
    148

    z 2  x0   x1   x2   x3   x4   x5   
    y0
    155
    17
    132
    21
    166
    228

    y1
    164
    142
    113
    178
    163
    205

    y2
    227
    12
    144
    21
    52
    68

    y3
    244
    71
    167
    211
    196
    180

    y4
    219
    50
    68
    22
    239
    35

    y5
    239
    105
    207
    204
    124
    67

    y6
    44
    140
    24
    227
    29
    28

    z 3  x0   x1   x2   x3   x4   x5   
    y0
    193
    155
    245
    171
    250
    95

    y1
    203
    25
    189
    177
    122
    122

    y2
    34
    87
    247
    55
    29
    90

    y3
    231
    3
    159
    216
    144
    203

    y4
    190
    130
    157
    133
    174
    32

    y5
    39
    209
    48
    213
    70
    86

    y6
    249
    13
    84
    112
    15
    142

    z 4  x0   x1   x2   x3   x4   x5   
    y0
    119
    253
    101
    150
    210
    100

    y1
    67
    181
    216
    202
    83
    117

    y2
    3
    32
    113
    97
    81
    46

    y3
    230
    127
    35
    232
    10
    231

    y4
    93
    67
    39
    203
    10
    163

    y5
    239
    219
    120
    226
    103
    240

    y6
    244
    97
    102
    156
    77
    75

    z 5  x0   x1   x2   x3   x4   x5   
    y0
    135
    13
    138
    113
    119
    134

    y1
    6
    79
    182
    180
    171
    0

    y2
    4
    69
    108
    253
    187
    146

    y3
    62
    180
    115
    107
    72
    66

    y4
    47
    227
    131
    117
    252
    230

    y5
    0
    32
    117
    172
    65
    253

    y6
    80
    130
    76
    179
    167
    166

    z 6  x0   x1   x2   x3   x4   x5   
    y0
    87
    89
    49
    4
    58
    115

    y1
    81
    74
    128
    196
    70
    202

    y2
    171
    253
    179
    202
    245
    56

    y3
    185
    148
    71
    139
    216
    234

    y4
    119
    12
    123
    21
    130
    175

    y5
    20
    12
    31
    75
    195
    218

    y6
    233
    3
    70
    98
    159
    183

    z 7  x0   x1   x2   x3   x4   x5   
    y0
    78
    197
    148
    187
    144
    144

    y1
    169
    43
    86
    46
    175
    29

    y2
    142
    73
    122
    211
    130
    144

    y3
    135
    168
    80
    48
    50
    104

    y4
    235
    3
    29
    139
    31
    212

    y5
    4
    52
    69
    176
    6
    67

    y6
    233
    142
    140
    80
    44
    158


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

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

y1
149
151
87
176
120
186

y2
9
4
240
234
2
139

y3
169
178
179
213
81
131

y4
165
231
159
72
171
137

y5
94
10
213
44
19
6

y6
116
20
209
29
164
155

z 1  x0   x1   x2   x3   x4   x5   
y0
81
227
251
34
87
27

y1
44
9
68
231
181
60

y2
23
212
181
167
27
92

y3
66
67
244
248
90
236

y4
51
109
21
197
8
58

y5
241
176
115
139
254
205

y6
223
142
32
54
30
148

z 2  x0   x1   x2   x3   x4   x5   
y0
155
254
132
166
166
228

y1
164
248
113
87
163
205

y2
227
24
144
144
52
137

y3
244
234
167
181
196
180

y4
219
26
68
6
239
2

y5
239
93
207
205
124
67

y6
44
43
24
72
209
102

z 3  x0   x1   x2   x3   x4   x5   
y0
193
188
245
171
250
95

y1
203
25
189
177
122
122

y2
34
87
247
55
29
179

y3
231
3
159
216
144
203

y4
190
130
157
185
174
32

y5
39
209
48
46
70
86

y6
249
13
84
112
15
142

z 4  x0   x1   x2   x3   x4   x5   
y0
119
205
101
150
210
100

y1
67
181
216
202
83
117

y2
3
32
113
97
81
65

y3
230
127
35
232
10
231

y4
93
67
39
206
10
163

y5
239
219
120
147
103
240

y6
244
97
102
156
77
75

z 5  x0   x1   x2   x3   x4   x5   
y0
135
56
138
113
119
115

y1
6
79
182
180
171
74

y2
4
69
108
253
187
16

y3
62
180
115
107
72
236

y4
212
106
238
188
45
246

y5
0
32
117
73
65
28

y6
80
130
76
179
167
198

z 6  x0   x1   x2   x3   x4   x5   
y0
87
22
49
196
58
115

y1
81
250
128
222
70
202

y2
171
60
179
211
245
255

y3
185
186
71
43
216
234

y4
119
17
123
10
130
175

y5
30
26
31
56
195
218

y6
233
33
70
49
159
53

z 7  x0   x1   x2   x3   x4   x5   
y0
78
19
148
187
144
144

y1
169
43
86
46
175
29

y2
142
73
122
211
130
255

y3
135
168
80
48
50
104

y4
235
3
29
253
31
212

y5
4
52
69
225
6
67

y6
233
142
140
80
44
158

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: ÎÌ�åÓàŠÉÐÿ"67ðz b1ØŸ£².

Reversing the modification turns: ÎÌ�åÓàŠÉÐÿ"67ðz b1ØŸ£² 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.