Files
pydarc/test/mimick_excel.py

1031 lines
66 KiB
Python

from src.models import DarcKey, DarcKeyTypes
if __name__ == "__main__":
height = 10
width = 7
"""
Alphabet Values 10 28 38 41 51 64 70 15 25 33 48 56 69 71 13 22 36 47 54 60 72 12 24 31 43 58 63 73 11 21 39 49 53 65 74 18 20 32 45 52 61 75 14 29 37 44 57 68 76 19 23 34 40 59 62 77 17 27 35 42 55 67 78 16 26 30 46 50 66 79
"""
# Alphabet Values
alphabet_values = DarcKey(matrix=[
['10', '28', '38', '41', '51', '64', '70'],
['15', '25', '33', '48', '56', '69', '71'],
['13', '22', '36', '47', '54', '60', '72'],
['12', '24', '31', '43', '58', '63', '73'],
['11', '21', '39', '49', '53', '65', '74'],
['18', '20', '32', '45', '52', '61', '75'],
['14', '29', '37', '44', '57', '68', '76'],
['19', '23', '34', '40', '59', '62', '77'],
['17', '27', '35', '42', '55', '67', '78'],
['16', '26', '30', '46', '50', '66', '79']
], key_type=DarcKeyTypes.alphabet)
""" persistent Keys Generation """
"""
Outer (Mutual) (Substitution) Function Key 9 7 4 2 5 3 0 6 1 8
Outer (Mutual) (Substitution) Function Function Key 8 1 4 5 2 3 7 6 0 9
Outer Server (Mutual) Shuffle (Permutation) Function Key 3 9 2 5 0 7 6 8 1 4
Outer Client Shuffle (Permutation) Key 6 4 7 8 0 2 1 9 5 3
Outer Client Shuffle (Permutation) Function Key 4 2 1 0 5 7 8 9 3 6
Outer Server Shuffle (Permutation) Key 4 9 6 0 7 5 3 1 2 8
"""
# Outer (Mutual) (Substitution) Function Key
outer_mutual_substitution_function_key = DarcKey(matrix=[['9', '7', '4', '2', '5', '3', '0', '6', '1', '8']], key_type=DarcKeyTypes.outer_shuffle)
# Outer (Mutual) (Substitution) Function Function Key
outer_mutual_substitution_function_function_key = DarcKey(matrix=[['8', '1', '4', '5', '2', '3', '7', '6', '0', '9']], key_type=DarcKeyTypes.outer_shuffle)
# Outer Server (Mutual) Shuffle (Permutation) Function Key
outer_mutual_shuffle_permutation_function_key = DarcKey(matrix=[['3', '9', '2', '5', '0', '7', '6', '8', '1', '4']], key_type=DarcKeyTypes.outer_shuffle)
# Outer Client Shuffle (Permutation) Key
outer_client_shuffle_permutation_key = DarcKey(matrix=[['6', '4', '7', '8', '0', '2', '1', '9', '5', '3']], key_type=DarcKeyTypes.outer_shuffle)
# Outer Client Shuffle (Permutation) Function Key
outer_client_shuffle_permutation_function_key = DarcKey(matrix=[['4', '2', '1', '0', '5', '7', '8', '9', '3', '6']], key_type=DarcKeyTypes.outer_shuffle)
# Outer Server Shuffle (Permutation) Key
outer_server_shuffle_permutation_key = DarcKey(matrix=[['4', '9', '6', '0', '7', '5', '3', '1', '2', '8']], key_type=DarcKeyTypes.outer_shuffle)
"""
(Mutual) (Substitution) Function Key 1 5 0 2 3 6 4 5 2 6 4 1 3 0 4 2 3 5 6 1 0 0 3 1 6 5 2 4 4 1 3 0 6 5 2 6 3 4 2 5 1 0 2 3 0 4 1 6 5 4 0 6 5 2 3 1 3 2 4 1 0 5 6 2 3 4 1 5 0 6
Client Shuffle (Permutation) Key X 6 3 1 4 5 0 2 6 5 0 2 3 4 1 1 4 0 6 3 2 5 6 1 4 5 3 2 0 2 0 1 4 3 5 6 3 0 6 2 1 4 5 3 2 0 1 6 4 5 6 2 3 0 1 5 4 3 0 6 5 4 1 2 3 2 5 0 4 1 6
Client Shuffle (Permutation) Key A (remove A) 6 0 3 5 2 1 4 4 3 2 5 0 1 6 5 4 1 0 2 3 6 3 6 1 4 5 2 0 3 5 4 2 0 1 6 6 1 5 4 2 3 0 0 4 6 3 5 1 2 0 6 4 3 1 2 5 5 0 6 3 4 1 2 3 2 0 4 1 6 5
Server Shuffle (Permutation) Key 5 2 3 0 6 4 1 5 2 6 3 0 1 4 1 3 5 0 2 6 4 6 2 1 4 5 0 3 2 3 4 1 5 6 0 3 2 0 1 5 4 6 2 6 0 3 4 1 5 3 0 4 6 2 5 1 5 3 2 0 6 4 1 1 4 5 3 2 6 0
"""
# (Mutual) (Substitution) Function Key
mutual_substitution_function_key = DarcKey(matrix=[
['1', '5', '0', '2', '3', '6', '4'],
['5', '2', '6', '4', '1', '3', '0'],
['4', '2', '3', '5', '6', '1', '0'],
['0', '3', '1', '6', '5', '2', '4'],
['4', '1', '3', '0', '6', '5', '2'],
['6', '3', '4', '2', '5', '1', '0'],
['2', '3', '0', '4', '1', '6', '5'],
['4', '0', '6', '5', '2', '3', '1'],
['3', '2', '4', '1', '0', '5', '6'],
['2', '3', '4', '1', '5', '0', '6']
], key_type=DarcKeyTypes.inner_shuffle)
# Client Shuffle (Permutation) Key X
client_shuffle_permutation_key_x = DarcKey(matrix=[
['6', '3', '1', '4', '5', '0', '2'],
['6', '5', '0', '2', '3', '4', '1'],
['1', '4', '0', '6', '3', '2', '5'],
['6', '1', '4', '5', '3', '2', '0'],
['2', '0', '1', '4', '3', '5', '6'],
['3', '0', '6', '2', '1', '4', '5'],
['3', '2', '0', '1', '6', '4', '5'],
['6', '2', '3', '0', '1', '5', '4'],
['3', '0', '6', '5', '4', '1', '2'],
['3', '2', '5', '0', '4', '1', '6']
], key_type=DarcKeyTypes.inner_shuffle)
# Client Shuffle (Permutation) Key A (remove A)
client_shuffle_permutation_key_a = DarcKey(matrix=[
['6', '0', '3', '5', '2', '1', '4'],
['4', '3', '2', '5', '0', '1', '6'],
['5', '4', '1', '0', '2', '3', '6'],
['3', '6', '1', '4', '5', '2', '0'],
['3', '5', '4', '2', '0', '1', '6'],
['6', '1', '5', '4', '2', '3', '0'],
['0', '4', '6', '3', '5', '1', '2'],
['0', '6', '4', '3', '1', '2', '5'],
['5', '0', '6', '3', '4', '1', '2'],
['3', '2', '0', '4', '1', '6', '5']
], key_type=DarcKeyTypes.inner_shuffle)
# Server Shuffle (Permutation) Key
server_shuffle_permutation_key = DarcKey(matrix=[
['5', '2', '3', '0', '6', '4', '1'],
['5', '2', '6', '3', '0', '1', '4'],
['1', '3', '5', '0', '2', '6', '4'],
['6', '2', '1', '4', '5', '0', '3'],
['2', '3', '4', '1', '5', '6', '0'],
['3', '2', '0', '1', '5', '4', '6'],
['2', '6', '0', '3', '4', '1', '5'],
['3', '0', '4', '6', '2', '5', '1'],
['5', '3', '2', '0', '6', '4', '1'],
['1', '4', '5', '3', '2', '6', '0']
], key_type=DarcKeyTypes.inner_shuffle)
"""
Shared (Mutual) (Substitution) Component 1 81 150 209 32 246 219 15 100 15 50 179 52 1 142 98 34 170 6 195 115 117 205 169 12 151 139 91 114 192 153 175 62 249 230 103 56 54 44 107 125 122 219 28 16 32 27 95 248 200 152 121 40 198 19 55 59 189 227 175 102 171 135 170 182 144 202 64 253 89 196
Shared (Mutual) (Substitution) Component 2 48 87 34 220 7 126 227 92 232 22 55 20 202 27 53 121 169 82 73 194 136 66 190 253 113 231 210 137 189 76 54 114 39 144 74 71 47 179 12 209 213 187 110 46 81 150 252 48 79 50 166 60 45 116 88 123 167 175 228 65 204 171 186 56 140 58 124 85 95 199
Shared (Mutual) (Substitution) Component 3 102 134 242 33 236 198 117 64 217 214 101 254 216 28 63 6 193 57 57 149 219 46 206 213 239 207 23 188 146 185 119 73 126 123 248 96 61 106 92 239 209 167 150 168 220 110 162 117 247 175 141 235 39 117 140 186 225 198 28 249 80 106 206 204 81 141 187 235 53 173
Shared (Mutual) (Substitution) Component 4 236 98 244 78 32 92 199 122 89 139 227 31 100 136 111 144 78 34 20 19 16 245 75 82 73 80 188 45 165 117 28 215 119 104 22 119 11 96 75 126 196 57 197 92 232 211 74 106 131 93 109 141 51 16 54 248 101 199 185 6 95 129 246 198 27 60 7 17 167 12
Shared (Mutual) (Substitution) Component 5 253 68 183 115 57 179 113 85 25 128 100 215 10 142 26 25 247 144 3 30 241 91 221 157 30 233 114 176 201 223 59 64 175 161 148 230 185 178 69 191 169 220 239 77 2 106 58 12 174 244 18 203 208 85 137 129 178 105 242 166 162 137 94 226 186 254 165 198 1 68
"""
# Shared (Mutual) (Substitution) Component 1
shared_mutual_substitution_component_1 = DarcKey(matrix=[
['81', '150', '209', '32', '246', '219', '15'],
['100', '15', '50', '179', '52', '1', '142'],
['98', '34', '170', '6', '195', '115', '117'],
['205', '169', '12', '151', '139', '91', '114'],
['192', '153', '175', '62', '249', '230', '103'],
['56', '54', '44', '107', '125', '122', '219'],
['28', '16', '32', '27', '95', '248', '200'],
['152', '121', '40', '198', '19', '55', '59'],
['189', '227', '175', '102', '171', '135', '170'],
['182', '144', '202', '64', '253', '89', '196']
], key_type=DarcKeyTypes.alphabet)
# Shared (Mutual) (Substitution) Component 2
shared_mutual_substitution_component_2 = DarcKey(matrix=[
['48', '87', '34', '220', '7', '126', '227'],
['92', '232', '22', '55', '20', '202', '27'],
['53', '121', '169', '82', '73', '194', '136'],
['66', '190', '253', '113', '231', '210', '137'],
['189', '76', '54', '114', '39', '144', '74'],
['71', '47', '179', '12', '209', '213', '187'],
['110', '46', '81', '150', '252', '48', '79'],
['50', '166', '60', '45', '116', '88', '123'],
['167', '175', '228', '65', '204', '171', '186'],
['56', '140', '58', '124', '85', '95', '199']
], key_type=DarcKeyTypes.alphabet)
# Shared (Mutual) (Substitution) Component 3
shared_mutual_substitution_component_3 = DarcKey(matrix=[
['102', '134', '242', '33', '236', '198', '117'],
['64', '217', '214', '101', '254', '216', '28'],
['63', '6', '193', '57', '57', '149', '219'],
['46', '206', '213', '239', '207', '23', '188'],
['146', '185', '119', '73', '126', '123', '248'],
['96', '61', '106', '92', '239', '209', '167'],
['150', '168', '220', '110', '162', '117', '247'],
['175', '141', '235', '39', '117', '140', '186'],
['225', '198', '28', '249', '80', '106', '206'],
['204', '81', '141', '187', '235', '53', '173']
], key_type=DarcKeyTypes.alphabet)
# Shared (Mutual) (Substitution) Component 4
shared_mutual_substitution_component_4 = DarcKey(matrix=[
['236', '98', '244', '78', '32', '92', '199'],
['122', '89', '139', '227', '31', '100', '136'],
['111', '144', '78', '34', '20', '19', '16'],
['245', '75', '82', '73', '80', '188', '45'],
['165', '117', '28', '215', '119', '104', '22'],
['119', '11', '96', '75', '126', '196', '57'],
['197', '92', '232', '211', '74', '106', '131'],
['93', '109', '141', '51', '16', '54', '248'],
['101', '199', '185', '6', '95', '129', '246'],
['198', '27', '60', '7', '17', '167', '12']
], key_type=DarcKeyTypes.alphabet)
# Shared (Mutual) (Substitution) Component 5
shared_mutual_substitution_component_5 = DarcKey(matrix=[
['253', '68', '183', '115', '57', '179', '113'],
['85', '25', '128', '100', '215', '10', '142'],
['26', '25', '247', '144', '3', '30', '241'],
['91', '221', '157', '30', '233', '114', '176'],
['201', '223', '59', '64', '175', '161', '148'],
['230', '185', '178', '69', '191', '169', '220'],
['239', '77', '2', '106', '58', '12', '174'],
['244', '18', '203', '208', '85', '137', '129'],
['178', '105', '242', '166', '162', '137', '94'],
['226', '186', '254', '165', '198', '1', '68']
], key_type=DarcKeyTypes.alphabet)
"""
Shared (Mutual) Client (Substitution) Component 240 15 88 14 250 164 163 163 56 44 73 159 63 176 73 243 215 9 10 177 36 120 89 247 92 152 209 95 130 128 3 126 120 77 105 232 156 52 52 145 3 116 17 124 135 199 154 130 221 101 78 248 180 114 83 72 58 66 170 59 212 240 221 67 53 80 35 124 28 197
Shared (Mutual) Server (Substitution) Component 115 96 164 85 150 162 142 252 185 145 200 150 27 195 186 199 82 103 152 178 130 139 104 18 104 198 177 181 118 143 110 202 118 85 83 104 216 226 79 228 177 42 59 114 204 213 229 98 164 54 240 249 203 153 181 84 29 23 83 59 148 165 19 238 22 232 255 41 234 113
Client (Substitution) Component 1 151 187 247 139 183 232 14 230 143 212 92 0 130 233 129 77 103 15 159 192 98 97 208 37 14 53 62 138 38 141 174 232 134 14 171 87 79 75 191 122 214 18 9 204 152 159 21 178 171 30 130 4 1 166 248 96 87 179 192 93 61 129 106 43 41 3 232 20 10 163
Client (Substitution) Component 2 39 161 162 158 47 242 245 115 157 174 130 210 253 157 95 103 134 162 131 19 170 53 217 182 156 83 184 228 97 49 114 75 158 248 138 204 22 121 176 205 115 146 117 154 87 237 2 56 114 24 241 213 73 236 37 12 156 230 70 205 108 187 32 194 40 99 190 143 24 119
"""
# Shared (Mutual) Client (Substitution) Component
shared_mutual_client_substitution_component = DarcKey(matrix=[
['240', '15', '88', '14', '250', '164', '163'],
['163', '56', '44', '73', '159', '63', '176'],
['73', '243', '215', '9', '10', '177', '36'],
['120', '89', '247', '92', '152', '209', '95'],
['130', '128', '3', '126', '120', '77', '105'],
['232', '156', '52', '52', '145', '3', '116'],
['17', '124', '135', '199', '154', '130', '221'],
['101', '78', '248', '180', '114', '83', '72'],
['58', '66', '170', '59', '212', '240', '221'],
['67', '53', '80', '35', '124', '28', '197']
], key_type=DarcKeyTypes.alphabet)
# Shared (Mutual) Server (Substitution) Component
shared_mutual_server_substitution_component = DarcKey(matrix=[
['115', '96', '164', '85', '150', '162', '142'],
['252', '185', '145', '200', '150', '27', '195'],
['186', '199', '82', '103', '152', '178', '130'],
['139', '104', '18', '104', '198', '177', '181'],
['118', '143', '110', '202', '118', '85', '83'],
['104', '216', '226', '79', '228', '177', '42'],
['59', '114', '204', '213', '229', '98', '164'],
['54', '240', '249', '203', '153', '181', '84'],
['29', '23', '83', '59', '148', '165', '19'],
['238', '22', '232', '255', '41', '234', '113']
], key_type=DarcKeyTypes.alphabet)
# Client (Substitution) Component 1
client_substitution_component_1 = DarcKey(matrix=[
['151', '187', '247', '139', '183', '232', '14'],
['230', '143', '212', '92', '0', '130', '233'],
['129', '77', '103', '15', '159', '192', '98'],
['97', '208', '37', '14', '53', '62', '138'],
['38', '141', '174', '232', '134', '14', '171'],
['87', '79', '75', '191', '122', '214', '18'],
['9', '204', '152', '159', '21', '178', '171'],
['30', '130', '4', '1', '166', '248', '96'],
['87', '179', '192', '93', '61', '129', '106'],
['43', '41', '3', '232', '20', '10', '163']
], key_type=DarcKeyTypes.alphabet)
# Client (Substitution) Component 2
client_substitution_component_2 = DarcKey(matrix=[
['39', '161', '162', '158', '47', '242', '245'],
['115', '157', '174', '130', '210', '253', '157'],
['95', '103', '134', '162', '131', '19', '170'],
['53', '217', '182', '156', '83', '184', '228'],
['97', '49', '114', '75', '158', '248', '138'],
['204', '22', '121', '176', '205', '115', '146'],
['117', '154', '87', '237', '2', '56', '114'],
['24', '241', '213', '73', '236', '37', '12'],
['156', '230', '70', '205', '108', '187', '32'],
['194', '40', '99', '190', '143', '24', '119']
], key_type=DarcKeyTypes.alphabet)
"""
Server (Substitution) Component 1 202 199 197 48 92 205 182 45 16 19 85 99 114 163 154 232 143 138 159 248 190 87 79 134 207 88 120 175 17 133 198 222 231 227 231 171 170 43 215 22 83 139 154 228 211 44 35 228 82 49 175 11 224 248 215 206 109 101 208 62 247 59 175 86 26 53 57 171 135 80
Server (Substitution) Component 2 141 198 40 43 65 91 15 41 26 29 55 179 239 92 165 193 247 134 24 232 157 170 132 223 231 45 92 130 209 198 33 38 130 183 83 103 183 30 163 134 8 123 62 192 47 67 198 127 155 210 95 229 182 67 248 60 242 146 72 38 147 46 235 136 129 85 244 243 183 172
Client (Substitution) Key 148 232 147 96 20 201 150 120 0 158 250 176 223 82 12 81 193 212 247 100 1 127 211 164 202 25 149 34 214 38 10 197 195 97 193 177 120 199 180 206 184 155 154 146 186 205 190 47 169 164 80 233 207 214 91 108 123 101 231 244 92 88 12 222 193 85 98 224 145 0
Server (Substitution) Key 163 247 59 226 186 179 35 140 180 54 88 40 252 97 229 247 16 206 186 125 81 221 222 54 22 190 18 122 126 130 83 142 152 238 237 76 168 77 176 198 119 104 121 96 80 75 138 219 122 92 210 20 56 232 219 245 111 1 155 236 15 184 0 36 31 143 5 112 206 106
"""
# Server (Substitution) Component 1
server_substitution_component_1 = DarcKey(matrix=[
['202', '199', '197', '48', '92', '205', '182'],
['45', '16', '19', '85', '99', '114', '163'],
['154', '232', '143', '138', '159', '248', '190'],
['87', '79', '134', '207', '88', '120', '175'],
['17', '133', '198', '222', '231', '227', '231'],
['171', '170', '43', '215', '22', '83', '139'],
['154', '228', '211', '44', '35', '228', '82'],
['49', '175', '11', '224', '248', '215', '206'],
['109', '101', '208', '62', '247', '59', '175'],
['86', '26', '53', '57', '171', '135', '80']
], key_type=DarcKeyTypes.alphabet)
# Server (Substitution) Component 2
server_substitution_component_2 = DarcKey(matrix=[
['141', '198', '40', '43', '65', '91', '15'],
['41', '26', '29', '55', '179', '239', '92'],
['165', '193', '247', '134', '24', '232', '157'],
['170', '132', '223', '231', '45', '92', '130'],
['209', '198', '33', '38', '130', '183', '83'],
['103', '183', '30', '163', '134', '8', '123'],
['62', '192', '47', '67', '198', '127', '155'],
['210', '95', '229', '182', '67', '248', '60'],
['242', '146', '72', '38', '147', '46', '235'],
['136', '129', '85', '244', '243', '183', '172']
], key_type=DarcKeyTypes.alphabet)
# Client (Substitution) Key
client_substitution_key = DarcKey(matrix=[
['148', '232', '147', '96', '20', '201', '150'],
['120', '0', '158', '250', '176', '223', '82'],
['12', '81', '193', '212', '247', '100', '1'],
['127', '211', '164', '202', '25', '149', '34'],
['214', '38', '10', '197', '195', '97', '193'],
['177', '120', '199', '180', '206', '184', '155'],
['154', '146', '186', '205', '190', '47', '169'],
['164', '80', '233', '207', '214', '91', '108'],
['123', '101', '231', '244', '92', '88', '12'],
['222', '193', '85', '98', '224', '145', '0']
], key_type=DarcKeyTypes.alphabet)
# Server (Substitution) Key
server_substitution_key = DarcKey(matrix=[
['163', '247', '59', '226', '186', '179', '35'],
['140', '180', '54', '88', '40', '252', '97'],
['229', '247', '16', '206', '186', '125', '81'],
['221', '222', '54', '22', '190', '18', '122'],
['126', '130', '83', '142', '152', '238', '237'],
['76', '168', '77', '176', '198', '119', '104'],
['121', '96', '80', '75', '138', '219', '122'],
['92', '210', '20', '56', '232', '219', '245'],
['111', '1', '155', '236', '15', '184', '0'],
['36', '31', '143', '5', '112', '206', '106']
],
key_type=DarcKeyTypes.alphabet
)
# Shared (Mutual) (Substitution) Key
shared_mutual_substitution_key = shared_mutual_substitution_component_1 ^ client_substitution_key
# Shared (Mutual) Client (Substitution) Key Scratch
shared_mutual_client_substitution_key_scratch = shared_mutual_substitution_component_1 ^ shared_mutual_server_substitution_component
# Shared (Mutual) Server (Substitution) Key Scratch
shared_mutual_server_substitution_key_scratch = shared_mutual_substitution_component_1 ^ shared_mutual_client_substitution_component
# Client Mutual (Substitution) Key 1 = Client (Substitution) Component 1 ^ Shared (Mutual) (Substitution) Component 4
client_mutual_substitution_key_1 = client_substitution_component_1 ^ shared_mutual_substitution_component_4
# Client Mutual (Substitution) Key 2 = Client (Substitution) Component 2 ^ Shared (Mutual) (Substitution) Component 2 ^ Shared (Mutual) Client (Substitution) Key Scratch
client_mutual_substitution_key_2 = client_substitution_component_2 ^ shared_mutual_substitution_component_2 ^ shared_mutual_client_substitution_key_scratch
# Client Mutual (Substitution) Key 3 = Client (Substitution) Component 2 ^ Shared (Mutual) Client (Substitution) Component ^ Shared (Mutual) (Substitution) Component 1 ^ Shared (Mutual) (Substitution) Component 3
client_mutual_substitution_key_3 = client_substitution_component_2 ^ shared_mutual_client_substitution_component ^ shared_mutual_substitution_component_1 ^ shared_mutual_substitution_component_3
# Client Mutual (Substitution) Key 4 = Client (Substitution) Component 1 ^ Shared (Mutual) (Substitution) Component 5
client_mutual_substitution_key_4 = client_substitution_component_1 ^ shared_mutual_substitution_component_5
# Server Mutual (Substitution) Key 1 = Server (Substitution) Component 1 ^ Shared (Mutual) (Substitution) Component 4
server_mutual_substitution_key_1 = server_substitution_component_1 ^ shared_mutual_substitution_component_4
# Server Mutual (Substitution) Key 2 = Server (Substitution) Component 2 ^ Shared (Mutual) (Substitution) Component 1 ^ Shared (Mutual) (Substitution) Component 2 ^ Shared (Mutual) Server (Substitution) Component
server_mutual_substitution_key_2 = server_substitution_component_2 ^ shared_mutual_substitution_component_1 ^ shared_mutual_substitution_component_2 ^ shared_mutual_server_substitution_component
# Server Mutual (Substitution) Key 3 = Server (Substitution) Component 2 ^ Shared (Mutual) (Substitution) Component 3 ^ Shared (Mutual) Server (Substitution) Key Scratch
server_mutual_substitution_key_3 = server_substitution_component_2 ^ shared_mutual_substitution_component_3 ^ shared_mutual_server_substitution_key_scratch
# Server Mutual (Substitution) Key 4 = Server (Substitution) Component 1 ^ Shared (Mutual) (Substitution) Component 5
server_mutual_substitution_key_4 = server_substitution_component_1 ^ shared_mutual_substitution_component_5
""" ephemeral Key Generation """
"""
Outer (Mutual) (Substitution) Function ephemeral Key 0 9 6 2 1 5 3 8 7 4
Outer (Mutual) (Substitution) Function Function ephemeral Key 2 3 9 7 6 0 1 4 8 5
Outer Server (Mutual) Shuffle (Permutation) Function ephemeral Key 0 8 5 9 7 3 1 4 6 2
Outer Client Shuffle (Permutation) ephemeral Key 1 4 2 9 5 7 8 3 0 6
Outer Client Shuffle (Permutation) Function ephemeral Key 4 3 2 5 1 6 7 8 0 9
Outer Server Shuffle (Permutation) ephemeral Key 7 5 2 1 8 4 3 6 9 0
"""
# Outer (Mutual) (Substitution) Function ephemeral Key
outer_mutual_substitution_function_ephemeral_key = DarcKey(matrix=[
['0', '9', '6', '2', '1', '5', '3', '8', '7', '4']
], key_type=DarcKeyTypes.outer_shuffle)
# Outer (Mutual) (Substitution) Function Function ephemeral Key
outer_mutual_substitution_function_function_ephemeral_key = DarcKey(matrix=[
['2', '3', '9', '7', '6', '0', '1', '4', '8', '5']
], key_type=DarcKeyTypes.outer_shuffle)
# Outer Server (Mutual) Shuffle (Permutation) Function ephemeral Key
outer_server_mutual_shuffle_permutation_function_ephemeral_key = DarcKey(matrix=[
['0', '8', '5', '9', '7', '3', '1', '4', '6', '2']
], key_type=DarcKeyTypes.outer_shuffle)
# Outer Client Shuffle (Permutation) ephemeral Key
outer_client_shuffle_permutation_ephemeral_key = DarcKey(matrix=[
['1', '4', '2', '9', '5', '7', '8', '3', '0', '6']
], key_type=DarcKeyTypes.outer_shuffle)
# Outer Client Shuffle (Permutation) Function ephemeral Key
outer_client_shuffle_permutation_function_ephemeral_key = DarcKey(matrix=[
['4', '3', '2', '5', '1', '6', '7', '8', '0', '9']
], key_type=DarcKeyTypes.outer_shuffle)
# Outer Server Shuffle (Permutation) ephemeral Key
outer_server_shuffle_permutation_ephemeral_key = DarcKey(matrix=[
['7', '5', '2', '1', '8', '4', '3', '6', '9', '0']
], key_type=DarcKeyTypes.outer_shuffle)
"""
(Mutual) (Substitution) Function ephemeral Key 6 0 1 4 2 3 5 2 3 6 4 0 1 5 2 4 0 3 6 1 5 0 4 2 3 1 5 6 6 4 2 5 1 0 3 5 1 0 6 4 2 3 1 2 4 3 6 0 5 6 1 4 0 5 3 2 2 3 5 4 6 0 1 1 6 4 3 5 2 0
Client Shuffle (Permutation) ephemeral Key A (remove A) 5 0 4 3 2 6 1 0 6 2 1 5 3 4 1 2 0 3 5 4 6 0 2 6 3 4 5 1 5 1 2 0 3 4 6 1 0 3 4 5 6 2 3 0 5 2 6 4 1 6 4 5 3 0 2 1 2 4 6 0 3 5 1 4 6 2 3 5 1 0
Server Shuffle (Permutation) ephemeral Key 1 (remove 1) 6 1 3 0 4 2 5 3 2 1 0 4 5 6 2 4 3 5 0 6 1 4 1 3 6 0 2 5 1 4 2 3 0 5 6 6 4 5 0 2 3 1 0 4 2 3 1 5 6 0 6 3 5 1 2 4 2 6 3 1 4 5 0 5 0 4 1 6 3 2
"""
# (Mutual) (Substitution) Function ephemeral Key
mutual_substitution_function_ephemeral_key = DarcKey(matrix=[
['6', '0', '1', '4', '2', '3', '5'],
['2', '3', '6', '4', '0', '1', '5'],
['2', '4', '0', '3', '6', '1', '5'],
['0', '4', '2', '3', '1', '5', '6'],
['6', '4', '2', '5', '1', '0', '3'],
['5', '1', '0', '6', '4', '2', '3'],
['1', '2', '4', '3', '6', '0', '5'],
['6', '1', '4', '0', '5', '3', '2'],
['2', '3', '5', '4', '6', '0', '1'],
['1', '6', '4', '3', '5', '2', '0']
], key_type=DarcKeyTypes.inner_shuffle)
# Client Shuffle (Permutation) ephemeral Key A (remove A)
client_shuffle_permutation_ephemeral_key_a = DarcKey(matrix=[
['5', '0', '4', '3', '2', '6', '1'],
['0', '6', '2', '1', '5', '3', '4'],
['1', '2', '0', '3', '5', '4', '6'],
['0', '2', '6', '3', '4', '5', '1'],
['5', '1', '2', '0', '3', '4', '6'],
['1', '0', '3', '4', '5', '6', '2'],
['3', '0', '5', '2', '6', '4', '1'],
['6', '4', '5', '3', '0', '2', '1'],
['2', '4', '6', '0', '3', '5', '1'],
['4', '6', '2', '3', '5', '1', '0']
], key_type=DarcKeyTypes.inner_shuffle)
# Server Shuffle (Permutation) ephemeral Key 1 (remove 1)
server_shuffle_permutation_ephemeral_key_1 = DarcKey(matrix=[
['6', '1', '3', '0', '4', '2', '5'],
['3', '2', '1', '0', '4', '5', '6'],
['2', '4', '3', '5', '0', '6', '1'],
['4', '1', '3', '6', '0', '2', '5'],
['1', '4', '2', '3', '0', '5', '6'],
['6', '4', '5', '0', '2', '3', '1'],
['0', '4', '2', '3', '1', '5', '6'],
['0', '6', '3', '5', '1', '2', '4'],
['2', '6', '3', '1', '4', '5', '0'],
['5', '0', '4', '1', '6', '3', '2']
], key_type=DarcKeyTypes.inner_shuffle)
# Server (Substitution) ephemeral Unique Component Function
server_substitution_ephemeral_unique_component_function = 5
"""
Shared (Mutual) (Substitution) ephemeral Key 106 113 9 54 49 4 207 184 3 232 179 15 113 142 129 44 164 54 1 32 201 106 50 246 140 149 179 109 210 11 69 193 77 245 62 37 76 137 24 220 30 165 40 57 147 225 24 176 103 37 212 189 203 218 138 168 73 227 38 164 20 239 24 7 194 254 76 0 244 215
Client (Substitution) ephemeral Key 21 149 75 73 228 81 79 41 189 80 209 45 101 53 139 238 141 159 30 79 214 239 234 72 75 80 190 124 203 225 246 200 205 195 92 201 185 113 101 176 216 106 14 210 125 70 53 128 57 115 27 97 39 199 26 104 29 4 55 5 13 57 19 158 184 137 0 221 12 217
Server (Substitution) ephemeral Random Component 191 50 229 60 201 64 45 31 88 90 8 153 6 228 117 63 38 90 236 207 254 64 219 36 3 119 205 171 172 138 153 52 161 137 216 49 150 210 129 174 190 54 81 230 135 200 218 31 52 128 253 177 220 1 83 3 204 199 43 50 148 215 6 79 124 128 30 74 242 85
"""
# Shared (Mutual) (Substitution) ephemeral Key
shared_mutual_substitution_ephemeral_key = DarcKey(matrix=[
['106', '113', '9', '54', '49', '4', '207'],
['184', '3', '232', '179', '15', '113', '142'],
['129', '44', '164', '54', '1', '32', '201'],
['106', '50', '246', '140', '149', '179', '109'],
['210', '11', '69', '193', '77', '245', '62'],
['37', '76', '137', '24', '220', '30', '165'],
['40', '57', '147', '225', '24', '176', '103'],
['37', '212', '189', '203', '218', '138', '168'],
['73', '227', '38', '164', '20', '239', '24'],
['7', '194', '254', '76', '0', '244', '215']
], key_type=DarcKeyTypes.alphabet)
# Client (Substitution) ephemeral Key
client_substitution_ephemeral_key = DarcKey(matrix=[
['21', '149', '75', '73', '228', '81', '79'],
['41', '189', '80', '209', '45', '101', '53'],
['139', '238', '141', '159', '30', '79', '214'],
['239', '234', '72', '75', '80', '190', '124'],
['203', '225', '246', '200', '205', '195', '92'],
['201', '185', '113', '101', '176', '216', '106'],
['14', '210', '125', '70', '53', '128', '57'],
['115', '27', '97', '39', '199', '26', '104'],
['29', '4', '55', '5', '13', '57', '19'],
['158', '184', '137', '0', '221', '12', '217']
], key_type=DarcKeyTypes.alphabet)
# Server (Substitution) ephemeral Random Component
server_substitution_ephemeral_random_component = DarcKey(matrix=[
['191', '50', '229', '60', '201', '64', '45'],
['31', '88', '90', '8', '153', '6', '228'],
['117', '63', '38', '90', '236', '207', '254'],
['64', '219', '36', '3', '119', '205', '171'],
['172', '138', '153', '52', '161', '137', '216'],
['49', '150', '210', '129', '174', '190', '54'],
['81', '230', '135', '200', '218', '31', '52'],
['128', '253', '177', '220', '1', '83', '3'],
['204', '199', '43', '50', '148', '215', '6'],
['79', '124', '128', '30', '74', '242', '85']
], key_type=DarcKeyTypes.alphabet)
"""
Server (Substitution) ephemeral Unique Component 7 190 58 75 135 15 214 149 244 224
"""
# Server (Substitution) ephemeral Unique Component
server_substitution_ephemeral_unique_component = DarcKey(matrix=[
['7', '190', '58', '75', '135', '15', '214', '149', '244', '224']
], key_type=DarcKeyTypes.alphabet)
# Outer (Mutual) Function Function ephemeral Key Applied = Outer (Mutual) (Substitution) Function Function Key << Outer (Mutual) (Substitution) Function Function ephemeral Key
outer_mutual_function_function_ephemeral_key_applied = outer_mutual_substitution_function_function_key << outer_mutual_substitution_function_function_ephemeral_key
# Inner (Mutual) Function Applied Key = (Mutual) (Substitution) Function Key << (Mutual) (Substitution) Function ephemeral Key
inner_mutual_function_applied_key = mutual_substitution_function_key << mutual_substitution_function_ephemeral_key
# Inner (Mutual) Function Key Scratch = Inner (Mutual) Function Applied Key << Outer (Mutual) Function Function ephemeral Key Applied
inner_mutual_function_key_scratch = inner_mutual_function_applied_key < outer_mutual_function_function_ephemeral_key_applied
# Outer Server (Mutual) Shuffle (Permutation) Function ephemeral Key Applied = Outer Server (Mutual) Shuffle (Permutation) Function Key << Outer Server (Mutual) Shuffle (Permutation) Function ephemeral Key
outer_server_mutual_shuffle_permutation_function_ephemeral_key_applied = outer_mutual_shuffle_permutation_function_key << outer_server_mutual_shuffle_permutation_function_ephemeral_key
# Client Shuffle (Permutation) Key X Scratch = Client Shuffle (Permutation) Key X < Outer Server (Mutual) Shuffle (Permutation) Function ephemeral Key Applied
client_shuffle_permutation_key_x_scratch = client_shuffle_permutation_key_x < outer_server_mutual_shuffle_permutation_function_ephemeral_key_applied
# Inner Function Key Scratch 2 = Inner (Mutual) Function Key Scratch << Client Shuffle (Permutation) Key X Scratch
inner_function_key_scratch_2 = inner_mutual_function_key_scratch << client_shuffle_permutation_key_x_scratch
# Outer (Mutual) Function ephemeral Key Applied = Outer (Mutual) (Substitution) Function Key < Outer (Mutual) (Substitution) Function ephemeral Key
outer_mutual_function_ephemeral_key_applied = outer_mutual_substitution_function_key << outer_mutual_substitution_function_ephemeral_key
# Server (Substitution) Key Scratch = Server (Substitution) Key < Outer (Mutual) Function ephemeral Key Applied
server_substitution_key_scratch = server_substitution_key < outer_mutual_function_ephemeral_key_applied
# Shared (Mutual) (Substitution) Key Scratch = Shared (Mutual) (Substitution) Key < Outer (Mutual) Function ephemeral Key Applied
shared_mutual_substitution_key_scratch = shared_mutual_substitution_key < outer_mutual_function_ephemeral_key_applied
# Shared (Mutual) (Substitution) ephemeral Key Server Scratch = Shared (Mutual) (Substitution) ephemeral Key < Outer (Mutual) Function ephemeral Key Applied
shared_mutual_substitution_ephemeral_key_server_scratch = shared_mutual_substitution_ephemeral_key < outer_mutual_function_ephemeral_key_applied
# line 78
# Server Client Shuffle (Permutation) = Server Shuffle (Permutation) Key << Client Shuffle (Permutation) Key X
server_client_shuffle_permutation = server_shuffle_permutation_key << client_shuffle_permutation_key_x
# Server Client Shuffle (Permutation) Inverse
server_client_shuffle_permutation_inverse = ~server_client_shuffle_permutation
# Server Shuffle (Permutation) ephemeral Key 1 Inverse (remove 1) = ~(Server Shuffle (Permutation) ephemeral Key 1 (remove 1))
server_shuffle_permutation_ephemeral_key_1_inverse = ~server_shuffle_permutation_ephemeral_key_1
# Server Shuffle (Permutation) ephemeral Key Applied = Server Client Shuffle (Permutation) Inverse < Server Shuffle (Permutation) ephemeral Key 1 Inverse (remove 1)
server_shuffle_permutation_ephemeral_key_applied = server_client_shuffle_permutation_inverse << server_shuffle_permutation_ephemeral_key_1_inverse
# line 82
# Server Shuffle (Permutation) ephemeral Key Applied Scratch = Server Shuffle (Permutation) ephemeral Key Applied < Outer Server (Mutual) Shuffle (Permutation) Function ephemeral Key Applied
server_shuffle_permutation_ephemeral_key_applied_scratch = server_shuffle_permutation_ephemeral_key_applied < outer_server_mutual_shuffle_permutation_function_ephemeral_key_applied
# Server Shuffle (Permutation) ephemeral Key Applied Scratch Inverse = ~Server Shuffle (Permutation) ephemeral Key Applied Scratch
server_shuffle_permutation_ephemeral_key_applied_scratch_inverse = ~server_shuffle_permutation_ephemeral_key_applied_scratch
# Outer Server Shuffle (Permutation) ephemeral Key Applied = Outer Server Shuffle (Permutation) Key < Outer Server Shuffle (Permutation) ephemeral Key
outer_server_shuffle_permutation_ephemeral_key_applied = outer_server_shuffle_permutation_key << outer_server_shuffle_permutation_ephemeral_key
# Alphabet Scratch 1 = Alphabet Values < Outer Server Shuffle (Permutation) ephemeral Key Applied
alphabet_scratch_1 = alphabet_values < outer_server_shuffle_permutation_ephemeral_key_applied
# Alphabet Scratch 2 = Alphabet Scratch 1 << Server Shuffle (Permutation) ephemeral Key Applied Scratch Inverse
alphabet_scratch_2 = alphabet_scratch_1 << server_shuffle_permutation_ephemeral_key_applied_scratch_inverse
# Server (Substitution) ephemeral Component Scratch 1 = Server (Substitution) ephemeral Random Component.column_substitution( Server (Substitution) ephemeral Unique Component Function ,Server (Substitution) ephemeral Unique Component)
server_substitution_ephemeral_component_scratch_1 = server_substitution_ephemeral_random_component.column_substitution(
server_substitution_ephemeral_unique_component_function,
server_substitution_ephemeral_unique_component.matrix[0]
)
# Server (Substitution) ephemeral Component Scratch 2 = Server (Substitution) ephemeral Component Scratch 1 < Outer (Mutual) Function ephemeral Key Applied
server_substitution_ephemeral_component_scratch_2 = server_substitution_ephemeral_component_scratch_1 < outer_mutual_function_ephemeral_key_applied
"""
# Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Server (Substitution) ephemeral Component Scratch 2 << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) ephemeral Key Server Scratch << Inner Function Key Scratch 2)
=BITXOR(
# Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Server (Substitution) ephemeral Component Scratch 2 << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner Function Key Scratch 2)
BITXOR(
# Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Server (Substitution) ephemeral Component Scratch 2 << Inner Function Key Scratch 2)
BITXOR(
# Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2)
BITXOR(
BN86, # Alphabet Scratch 2
# Server (Substitution) Key Scratch << Inner Function Key Scratch 2
HLOOKUP(
BN73, # Inner Function Key Scratch 2
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB75) - ROW($BD$5) + 1, # Server (Substitution) Key Scratch
FALSE
)
),
# Server (Substitution) ephemeral Component Scratch 2 << Inner Function Key Scratch 2
HLOOKUP(
BN73, # Inner Function Key Scratch 2
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB88) - ROW($BD$5) + 1, # Server (Substitution) ephemeral Component Scratch 2
FALSE
)
),
# Shared (Mutual) (Substitution) Key Scratch << Inner Function Key Scratch 2
HLOOKUP(
BN73, # Inner Function Key Scratch 2
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB76) - ROW($BD$5) + 1, # Shared (Mutual) (Substitution) Key Scratch
FALSE
)
),
# Shared (Mutual) (Substitution) ephemeral Key Server Scratch << Inner Function Key Scratch 2
HLOOKUP(
BN73, # Inner Function Key Scratch 2
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB77) - ROW($BD$5) + 1, # Shared (Mutual) (Substitution) ephemeral Key Server Scratch
FALSE
)
)
"""
# Server (Substitution) ephemeral Component Scratch 3 = Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Server (Substitution) ephemeral Component Scratch 2 << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) ephemeral Key Server Scratch << Inner Function Key Scratch 2)
server_substitution_ephemeral_component_scratch_3 = alphabet_scratch_2 ^ (server_substitution_key_scratch << inner_function_key_scratch_2) ^ (server_substitution_ephemeral_component_scratch_2 << inner_function_key_scratch_2) ^ (shared_mutual_substitution_key_scratch << inner_function_key_scratch_2) ^ (shared_mutual_substitution_ephemeral_key_server_scratch << inner_function_key_scratch_2)
# Inner Function Key Scratch 2 Inverse = ~Inner Function Key Scratch 2
inner_function_key_scratch_2_inverse = ~inner_function_key_scratch_2
# Server (Substitution) ephemeral Key Scratch = Server (Substitution) ephemeral Component Scratch 3 << Inner Function Key Scratch 2 Inverse
server_substitution_ephemeral_key_scratch = server_substitution_ephemeral_component_scratch_3 << inner_function_key_scratch_2_inverse
# Outer (Mutual) Function ephemeral Key Applied Inverse = ~Outer (Mutual) Function ephemeral Key Applied
outer_mutual_function_ephemeral_key_applied_inverse = ~outer_mutual_function_ephemeral_key_applied
# Server (Substitution) ephemeral Key = Server (Substitution) ephemeral Key Scratch < Outer (Mutual) Function ephemeral Key Applied Inverse
server_substitution_ephemeral_key = server_substitution_ephemeral_key_scratch < outer_mutual_function_ephemeral_key_applied_inverse
"""
server_substitution_ephemeral_key_expected = 159 243 217 236 133 191 86 8 248 18 181 54 164 252 86 139 223 48 37 67 24 126 115 91 230 221 105 196 56 172 101 158 124 89 183 228 118 232 199 12 229 156 157 115 233 158 138 123 11 211 238 246 43 210 158 65 62 158 234 252 88 81 243 67 209 43 108 31 29 28
"""
server_substitution_ephemeral_key_expected = DarcKey(matrix=[
['159', '243', '217', '236', '133', '191', '86'],
['8', '248', '18', '181', '54', '164', '252'],
['86', '139', '223', '48', '37', '67', '24'],
['126', '115', '91', '230', '221', '105', '196'],
['56', '172', '101', '158', '124', '89', '183'],
['228', '118', '232', '199', '12', '229', '156'],
['157', '115', '233', '158', '138', '123', '11'],
['211', '238', '246', '43', '210', '158', '65'],
['62', '158', '234', '252', '88', '81', '243'],
['67', '209', '43', '108', '31', '29', '28']
], key_type=DarcKeyTypes.alphabet)
# compare server_substitution_ephemeral_key_expected to server_substitution_ephemeral_key
assert server_substitution_ephemeral_key_expected == server_substitution_ephemeral_key
# line 94
""" Server Tx (Phase 1) """
# Inner Server Shuffle (Permutation) Key Applied = Server Shuffle (Permutation) ephemeral Key 1 (remove 1) << Server Shuffle (Permutation) Key
inner_server_shuffle_permutation_key_applied = server_shuffle_permutation_ephemeral_key_1 << server_shuffle_permutation_key
# Outer Server Shuffle (Permutation) Key Applied = Inner Server Shuffle (Permutation) Key Applied < Outer Server (Mutual) Shuffle (Permutation) Function ephemeral Key Applied
outer_server_shuffle_permutation_key_applied = inner_server_shuffle_permutation_key_applied < outer_server_mutual_shuffle_permutation_function_ephemeral_key_applied
# Server (Substitution) ephemeral Key Scratch = Server (Substitution) ephemeral Key < Outer (Mutual) Function ephemeral Key Applied
server_substitution_ephemeral_key_scratch = server_substitution_ephemeral_key < outer_mutual_function_ephemeral_key_applied
# Server (Substitution) Key Scratch 2 = Server (Substitution) Key Scratch
server_substitution_key_scratch_2 = server_substitution_key_scratch
# line 105
# Outer (Mutual) Function Function ephemeral Key Applied = Outer (Mutual) (Substitution) Function Function Key << Outer (Mutual) (Substitution) Function Function ephemeral Key
outer_mutual_function_function_ephemeral_key_applied = outer_mutual_substitution_function_function_key << outer_mutual_substitution_function_function_ephemeral_key
# line 108
""" Server Tx (Phase 1) """
# Client (Substitution) Key A Scratch = Client (Substitution) Key < Outer (Mutual) Function ephemeral Key Applied
client_substitution_key_a_scratch = client_substitution_key < outer_mutual_function_ephemeral_key_applied
# Client (Substitution) ephemeral Key A Scratch = Client (Substitution) ephemeral Key < Outer (Mutual) Function ephemeral Key Applied
client_substitution_ephemeral_key_a_scratch = client_substitution_ephemeral_key < outer_mutual_function_ephemeral_key_applied
# Client Shuffle (Permutation) Key A Applied (remove A) = Client Shuffle (Permutation) Key A Applied (remove A) << Client Shuffle (Permutation) ephemeral Key A (remove A)
client_shuffle_permutation_key_a_applied = client_shuffle_permutation_key_a << client_shuffle_permutation_ephemeral_key_a
# Client Shuffle (Permutation) Key A Scratch (remove A) = Client Shuffle (Permutation) Key A Applied (remove A) < Outer Server (Mutual) Shuffle (Permutation) Function ephemeral Key Applied
client_shuffle_permutation_key_a_scratch = client_shuffle_permutation_key_a_applied < outer_server_mutual_shuffle_permutation_function_ephemeral_key_applied
# Outer Client Shuffle (Permutation) ephemeral Key Applied = Outer Client Shuffle (Permutation) Key << Outer Client Shuffle (Permutation) ephemeral Key
outer_client_shuffle_permutation_ephemeral_key_applied = outer_client_shuffle_permutation_key << outer_client_shuffle_permutation_ephemeral_key
# Outer Client Shuffle (Permutation) Function ephemeral Key Applied = Outer Client Shuffle (Permutation) Function Key << Outer Client Shuffle (Permutation) Function ephemeral Key
outer_client_shuffle_permutation_function_ephemeral_key_applied = outer_client_shuffle_permutation_function_key << outer_client_shuffle_permutation_function_ephemeral_key
# Outer Client Shuffle (Permutation) Function Key Applied = Outer Client Shuffle (Permutation) ephemeral Key Applied << Outer Client Shuffle (Permutation) Function ephemeral Key Applied
outer_client_shuffle_permutation_function_key_applied = outer_client_shuffle_permutation_ephemeral_key_applied << outer_client_shuffle_permutation_function_ephemeral_key_applied
# Outer Client Shuffle (Permutation) Function Key Applied Inverse = ~Outer Client Shuffle (Permutation) Function Key Applied
outer_client_shuffle_permutation_function_key_applied_inverse = ~outer_client_shuffle_permutation_function_key_applied
"""
Alphabet Input Sequence 0 2 4 6 8 1 3 5 7 9
"""
alphabet_input_sequence = DarcKey(matrix=[
['0', '2', '4', '6', '8', '1', '3', '5', '7', '9']
], key_type=DarcKeyTypes.outer_shuffle)
# Alphabet Input Sequence Scratch = Outer Client Shuffle (Permutation) Function Key Applied Inverse << Alphabet Input Sequence
alphabet_input_sequence_scratch = outer_client_shuffle_permutation_function_key_applied_inverse << alphabet_input_sequence
# line 130
""" Client Tx (Phase 3) """
# Client Shuffle (Permutation) Key A Inverse (remove A) = ~Client Shuffle (Permutation) Key A (remove A)
client_shuffle_permutation_key_a_inverse = ~client_shuffle_permutation_key_a
# Client Shuffle (Permutation) Key B (remove B) = Client Shuffle (Permutation) Key A Inverse (remove A) << Client Shuffle (Permutation) Key X
client_shuffle_permutation_key_b = client_shuffle_permutation_key_a_inverse << client_shuffle_permutation_key_x
# Client Shuffle (Permutation) ephemeral Key A (remove A) Inverse = ~Client Shuffle (Permutation) ephemeral Key A (remove A)
client_shuffle_permutation_ephemeral_key_a_inverse = ~client_shuffle_permutation_ephemeral_key_a
# Client Shuffle (Permutation) Key B Applied = Client Shuffle (Permutation) ephemeral Key B << Client Shuffle (Permutation) Key B (remove B)
client_shuffle_permutation_key_b_applied = client_shuffle_permutation_ephemeral_key_a_inverse << client_shuffle_permutation_key_b
# Outer Server (Mutual) Shuffle (Permutation) Function Key Scratch = Outer Server (Mutual) Shuffle (Permutation) Function ephemeral Key Applied << Outer Client Shuffle (Permutation) Function Key Applied
outer_server_mutual_shuffle_permutation_function_key_scratch = outer_server_mutual_shuffle_permutation_function_ephemeral_key_applied << outer_client_shuffle_permutation_function_key_applied
# Client Shuffle (Permutation) Key B Scratch = Client Shuffle (Permutation) Key B Applied < Outer Server (Mutual) Shuffle (Permutation) Function Key Scratch
client_shuffle_permutation_key_b_scratch = client_shuffle_permutation_key_b_applied < outer_server_mutual_shuffle_permutation_function_key_scratch
# Client Shuffle (Permutation) Key X Scratch 2 = Client Shuffle (Permutation) Key X < Outer Server (Mutual) Shuffle (Permutation) Function Key Scratch
client_shuffle_permutation_key_x_scratch_2 = client_shuffle_permutation_key_x < outer_server_mutual_shuffle_permutation_function_key_scratch
# line 144
# Outer Function Function Key Scratch = Outer (Mutual) Function Function ephemeral Key Applied << Outer Client Shuffle (Permutation) Function Key Applied
outer_function_function_key_scratch = outer_mutual_function_function_ephemeral_key_applied << outer_client_shuffle_permutation_function_key_applied
# Inner (Mutual) Function Key Client Scratch = Inner (Mutual) Function Applied Key < Outer Function Function Key Scratch
inner_mutual_function_key_client_scratch = inner_mutual_function_applied_key < outer_function_function_key_scratch
# line 147
# (Mutual) Function Key Scratch 2 = Inner (Mutual) Function Key Client Scratch << client_shuffle_permutation_key_x_scratch_2
mutual_function_key_scratch_2 = inner_mutual_function_key_client_scratch << client_shuffle_permutation_key_x_scratch_2
# Outer (Mutual) Function Key Scratch = Outer (Mutual) Function ephemeral Key Applied << Outer Client Shuffle (Permutation) Function Key Applied
outer_mutual_function_key_scratch = outer_mutual_function_ephemeral_key_applied << outer_client_shuffle_permutation_function_key_applied
# Client (Substitution) Key B Scratch = Client (Substitution) Key < Outer (Mutual) Function Key Scratch
client_substitution_key_b_scratch = client_substitution_key < outer_mutual_function_key_scratch
# Client (Substitution) ephemeral Key B Scratch = Client (Substitution) ephemeral Key < Outer (Mutual) Function Key Scratch
client_substitution_ephemeral_key_b_scratch = client_substitution_ephemeral_key < outer_mutual_function_key_scratch
# Shared (Mutual) (Substitution) ephemeral Key Client Scratch = Shared (Mutual) (Substitution) ephemeral Key < Outer (Mutual) Function Key Scratch
shared_mutual_substitution_ephemeral_key_client_scratch = shared_mutual_substitution_ephemeral_key < outer_mutual_function_key_scratch
# Shared (Mutual) (Substitution) ephemeral Key Client Scratch
# DARC Message Data TODO: unsure how to compute this
# DARC Message Data Check = DARC Message Data < Alphabet Input Sequence Scratch
# line 175
""" Server Rx (Phase 4) """
"""
Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Server (Substitution) ephemeral Key Scratch << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) ephemeral Key Server Scratch << Inner Function Key Scratch 2)
=BITXOR(
Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Server (Substitution) ephemeral Key Scratch << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner Function Key Scratch 2)
BITXOR(
Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Server (Substitution) ephemeral Key Scratch << Inner Function Key Scratch 2)
BITXOR(
Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2)
BITXOR(
BN216, # Alphabet Scratch 2
Server (Substitution) Key Scratch << Inner Function Key Scratch 2
HLOOKUP(
BN184, # Inner Function Key Scratch 2
INDIRECT(ADDRESS(@CELL("row", $BD$5), @CELL("col", BN$5) - BN$5) & ":" & ADDRESS(@CELL("row", $BB$242), @CELL("col", BN$5) - BN$5 + $E$2 - 1)),
ROW($BB197) - ROW($BD$5) + 1, # Server (Substitution) Key Scratch
FALSE
)
),
Server (Substitution) ephemeral Key Scratch << Inner Function Key Scratch 2
HLOOKUP(
BN184, # Inner Function Key Scratch 2
INDIRECT(ADDRESS(@CELL("row", $BD$5), @CELL("col", BN$5) - BN$5) & ":" & ADDRESS(@CELL("row", $BB$242), @CELL("col", BN$5) - BN$5 + $E$2 - 1)),
ROW($BB201) - ROW($BD$5) + 1, # Server (Substitution) ephemeral Key Scratch
FALSE
)
),
(Shared (Mutual) (Substitution) Key Scratch << Inner Function Key Scratch 2)
HLOOKUP(
BN184, # Inner Function Key Scratch 2
INDIRECT(ADDRESS(@CELL("row", $BD$5), @CELL("col", BN$5) - BN$5) & ":" & ADDRESS(@CELL("row", $BB$242), @CELL("col", BN$5) - BN$5 + $E$2 - 1)),
ROW($BB202) - ROW($BD$5) + 1, # Shared (Mutual) (Substitution) Key Scratch
FALSE
)
),
(Shared (Mutual) (Substitution) ephemeral Key Server Scratch << Inner Function Key Scratch 2)
HLOOKUP(
BN184, # Inner Function Key Scratch 2
INDIRECT(ADDRESS(@CELL("row", $BD$5), @CELL("col", BN$5) - BN$5) & ":" & ADDRESS(@CELL("row", $BB$242), @CELL("col", BN$5) - BN$5 + $E$2 - 1)),
ROW($BB203) - ROW($BD$5) + 1, # Shared (Mutual) (Substitution) ephemeral Key Server Scratch
FALSE
)
)
"""
# Translation (Substitution) = Alphabet Scratch 2 ^ (Server (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Server (Substitution) ephemeral Key Scratch << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) ephemeral Key Server Scratch << Inner Function Key Scratch 2)
translation_substitution = alphabet_scratch_2 ^ (server_substitution_key_scratch << inner_function_key_scratch_2) ^ (server_substitution_ephemeral_key_scratch << inner_function_key_scratch_2) ^ (shared_mutual_substitution_key_scratch << inner_function_key_scratch_2) ^ (shared_mutual_substitution_ephemeral_key_server_scratch << inner_function_key_scratch_2)
""" Final """
""" Server Tx (Phase 1) """
# Outer Shuffle (Permutation) = Alphabet Values << Outer Server Shuffle (Permutation) ephemeral Key Applied
outer_shuffle_permutation = alphabet_values < outer_server_shuffle_permutation_ephemeral_key_applied
# Inner Shuffle (Permutation) = Outer Shuffle (Permutation) << Outer Server Shuffle (Permutation) Key Applied
inner_shuffle_permutation = outer_shuffle_permutation << outer_server_shuffle_permutation_key_applied
"""
# Inner Shuffle (Permutation) ^ (Server (Substitution) ephemeral Key Scratch << Inner (Mutual) Function Key Scratch) ^ (Server (Substitution) Key Scratch 2 << Inner (Mutual) Function Key Scratch)
=BITXOR(
# Inner Shuffle (Permutation) ^ (Server (Substitution) ephemeral Key Scratch << Inner (Mutual) Function Key Scratch)
BITXOR(
# Inner Shuffle (Permutation)
@INDIRECT(
ADDRESS(
ROW(BN225),
COLUMN(BN225),
4,
1
)
),
# Server (Substitution) ephemeral Key Scratch << Inner (Mutual) Function Key Scratch
HLOOKUP(
BN107, # Inner (Mutual) Function Key Scratch
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
@ROW($BB103) - ROW($BD$5) + 1, # Server (Substitution) ephemeral Key Scratch
FALSE
)
),
# Server (Substitution) Key Scratch 2 << Inner (Mutual) Function Key Scratch
HLOOKUP(
BN107, # Inner (Mutual) Function Key Scratch
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
@ROW($BB104) - ROW($BD$5) + 1, # Server (Substitution) Key Scratch 2
FALSE
)
)
"""
# Translation (Substitution) = Inner Shuffle (Permutation) ^ (Server (Substitution) ephemeral Key Scratch << Inner (Mutual) Function Key Scratch) ^ (Server (Substitution) Key Scratch 2 << Inner (Mutual) Function Key Scratch)
translation_substitution = inner_shuffle_permutation ^ (server_substitution_ephemeral_key_scratch << inner_mutual_function_key_scratch) ^ (server_substitution_key_scratch_2 << inner_mutual_function_key_scratch)
""" Client Rx (Phase 2) """
"""
# Translation (Substitution) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner (Mutual) Function Key Scratch) ^ (Client (Substitution) Key A Scratch << Inner (Mutual) Function Key Scratch) ^ (Client (Substitution) ephemeral Key A Scratch << Inner (Mutual) Function Key Scratch)
=BITXOR(
# Translation (Substitution) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner (Mutual) Function Key Scratch) ^ (Client (Substitution) Key A Scratch << Inner (Mutual) Function Key Scratch)
BITXOR(
# Translation (Substitution) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner (Mutual) Function Key Scratch)
BITXOR(
BN226, # Translation (Substitution)
# Shared (Mutual) (Substitution) Key Scratch << Inner (Mutual) Function Key Scratch
HLOOKUP(
BN111, # Inner (Mutual) Function Key Scratch
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB115) - ROW($BD$5) + 1, # Shared (Mutual) (Substitution) Key Scratch
FALSE
)
),
# Client (Substitution) Key A Scratch << Inner (Mutual) Function Key Scratch
HLOOKUP(
BN111, # Inner (Mutual) Function Key Scratch
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB113) - ROW($BD$5) + 1, # Client (Substitution) Key A Scratch
FALSE
)
),
Client (Substitution) ephemeral Key A Scratch << Inner (Mutual) Function Key Scratch
HLOOKUP(
BN111, # Inner (Mutual) Function Key Scratch
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB114) - ROW($BD$5) + 1, # Client (Substitution) ephemeral Key A Scratch
FALSE
)
)
"""
# Translation (Substitution) - Client Data = Translation (Substitution) ^ (Shared (Mutual) (Substitution) Key Scratch << Inner (Mutual) Function Key Scratch) ^ (Client (Substitution) Key A Scratch << Inner (Mutual) Function Key Scratch) ^ (Client (Substitution) ephemeral Key A Scratch << Inner (Mutual) Function Key Scratch)
translation_substitution_client_data = translation_substitution ^ (shared_mutual_substitution_key_scratch << inner_mutual_function_key_scratch) ^ (client_substitution_key_a_scratch << inner_mutual_function_key_scratch) ^ (client_substitution_ephemeral_key_a_scratch << inner_mutual_function_key_scratch)
# Inner Shuffle (Permutation) - CSKA+CSEKA = Translation (Substitution) - Client Data << Client Shuffle (Permutation) Key A Scratch (remove A)
inner_shuffle_permutation_cska_cseka = translation_substitution_client_data << client_shuffle_permutation_key_a_scratch
# Outer Shuffle (Permutation) - Client Rest = Inner Shuffle (Permutation) - CSKA+CSEKA << Outer Client Shuffle (Permutation) Function Key Applied
outer_shuffle_permutation_client_rest = inner_shuffle_permutation_cska_cseka < outer_client_shuffle_permutation_function_key_applied
""" Client Tx (Phase 3) """
# Inner Shuffle (Permutation) - CSEKB +CSKB = Outer Shuffle (Permutation) - Client Rest << Client Shuffle (Permutation) Key B Scratch
inner_shuffle_permutation_csekb_cskb = outer_shuffle_permutation_client_rest << client_shuffle_permutation_key_b_scratch
"""
# Inner Shuffle (Permutation) - CSEKB +CSKB ^ (Client (Substitution) Key B Scratch << (Mutual) Function Key Scratch 2) ^ (Client (Substitution) ephemeral Key B Scratch << (Mutual) Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) ephemeral Key Client Scratch << (Mutual) Function Key Scratch 2)
=BITXOR(
# Inner Shuffle (Permutation) - CSEKB +CSKB ^ (Client (Substitution) Key B Scratch << (Mutual) Function Key Scratch 2) ^ (Client (Substitution) ephemeral Key B Scratch << (Mutual) Function Key Scratch 2)
BITXOR(
# Inner Shuffle (Permutation) - CSEKB +CSKB ^ (Client (Substitution) Key B Scratch << (Mutual) Function Key Scratch 2)
BITXOR(
BN230, # Inner Shuffle (Permutation) - CSEKB +CSKB
# Client (Substitution) Key B Scratch << (Mutual) Function Key Scratch 2
HLOOKUP(
BN147, # (Mutual) Function Key Scratch 2
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB150) - ROW($BD$5) + 1, # Client (Substitution) Key B Scratch
FALSE
)
),
# Client (Substitution) ephemeral Key B Scratch << (Mutual) Function Key Scratch 2
HLOOKUP(
BN147, # (Mutual) Function Key Scratch 2
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB151) - ROW($BD$5) + 1, # Client (Substitution) ephemeral Key B Scratch
FALSE
)
),
# Shared (Mutual) (Substitution) ephemeral Key Client Scratch << (Mutual) Function Key Scratch 2
HLOOKUP(
BN147, # (Mutual) Function Key Scratch 2
INDIRECT(
ADDRESS(
@CELL("row", $BD$5),
@CELL("col", BN$5) - BN$5
) & ":" & ADDRESS(
@CELL("row", $BB$242),
@CELL("col", BN$5) - BN$5 + $E$2 - 1
)
),
ROW($BB152) - ROW($BD$5) + 1, # Shared (Mutual) (Substitution) ephemeral Key Client Scratch
FALSE
)
)
"""
# Translation (Substitution) DARC Data = Inner Shuffle (Permutation) - CSEKB +CSKB ^ (Client (Substitution) Key B Scratch << (Mutual) Function Key Scratch 2) ^ (Client (Substitution) ephemeral Key B Scratch << (Mutual) Function Key Scratch 2) ^ (Shared (Mutual) (Substitution) ephemeral Key Client Scratch << (Mutual) Function Key Scratch 2)
translation_substitution_darc_data = inner_shuffle_permutation_csekb_cskb ^ (client_substitution_key_b_scratch << mutual_function_key_scratch_2) ^ (client_substitution_ephemeral_key_b_scratch << mutual_function_key_scratch_2) ^ (shared_mutual_substitution_ephemeral_key_client_scratch << mutual_function_key_scratch_2)
a = 1
""" Server Rx (Phase 4) """
""" Server Rx (Phase 4) """
a = 1