1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
from noiseprotocol.constants import TOKEN_S, TOKEN_E, TOKEN_ES, TOKEN_SS, TOKEN_EE, TOKEN_SE
from noiseprotocol.functions.patterns import OneWayPattern, Pattern
# One-way patterns
class PatternN(OneWayPattern):
def __init__(self):
super(PatternN, self).__init__()
self.name = 'N'
self.pre_messages = [
[],
[TOKEN_S]
]
self.tokens = [
[TOKEN_E, TOKEN_ES]
]
class PatternK(OneWayPattern):
def __init__(self):
super(PatternK, self).__init__()
self.name = 'K'
self.pre_messages = [
[TOKEN_S],
[TOKEN_S]
]
self.tokens = [
[TOKEN_E, TOKEN_ES, TOKEN_SS]
]
class PatternX(OneWayPattern):
def __init__(self):
super(PatternX, self).__init__()
self.name = 'X'
self.pre_messages = [
[],
[TOKEN_S]
]
self.tokens = [
[TOKEN_E, TOKEN_ES, TOKEN_S, TOKEN_SS]
]
# Interactive patterns
class PatternNN(Pattern):
def __init__(self):
super(PatternNN, self).__init__()
self.name = 'NN'
self.tokens = [
[TOKEN_E],
[TOKEN_E, TOKEN_EE]
]
class PatternKN(Pattern):
def __init__(self):
super(PatternKN, self).__init__()
self.name = 'KN'
self.pre_messages = [
[TOKEN_S],
[]
]
self.tokens = [
[TOKEN_E],
[TOKEN_E, TOKEN_EE, TOKEN_SE]
]
class PatternNK(Pattern):
def __init__(self):
super(PatternNK, self).__init__()
self.name = 'NK'
self.pre_messages = [
[],
[TOKEN_S]
]
self.tokens = [
[TOKEN_E, TOKEN_ES],
[TOKEN_E, TOKEN_EE]
]
class PatternKK(Pattern):
def __init__(self):
super(PatternKK, self).__init__()
self.name = 'KK'
self.pre_messages = [
[TOKEN_S],
[TOKEN_S]
]
self.tokens = [
[TOKEN_E, TOKEN_ES, TOKEN_SS],
[TOKEN_E, TOKEN_EE, TOKEN_SE]
]
class PatternNX(Pattern):
def __init__(self):
super(PatternNX, self).__init__()
self.name = 'NX'
self.tokens = [
[TOKEN_E],
[TOKEN_E, TOKEN_EE, TOKEN_S, TOKEN_ES]
]
class PatternKX(Pattern):
def __init__(self):
super(PatternKX, self).__init__()
self.name = 'KX'
self.pre_messages = [
[TOKEN_S],
[]
]
self.tokens = [
[TOKEN_E],
[TOKEN_E, TOKEN_EE, TOKEN_SE, TOKEN_S, TOKEN_ES]
]
class PatternXN(Pattern):
def __init__(self):
super(PatternXN, self).__init__()
self.name = 'XN'
self.tokens = [
[TOKEN_E],
[TOKEN_E, TOKEN_EE],
[TOKEN_S, TOKEN_SE]
]
class PatternIN(Pattern):
def __init__(self):
super(PatternIN, self).__init__()
self.name = 'IN'
self.tokens = [
[TOKEN_E, TOKEN_S],
[TOKEN_E, TOKEN_EE, TOKEN_SE]
]
class PatternXK(Pattern):
def __init__(self):
super(PatternXK, self).__init__()
self.name = 'XK'
self.pre_messages = [
[],
[TOKEN_S]
]
self.tokens = [
[TOKEN_E, TOKEN_ES],
[TOKEN_E, TOKEN_EE],
[TOKEN_S, TOKEN_SE]
]
class PatternIK(Pattern):
def __init__(self):
super(PatternIK, self).__init__()
self.name = 'IK'
self.pre_messages = [
[],
[TOKEN_S]
]
self.tokens = [
[TOKEN_E, TOKEN_ES, TOKEN_S, TOKEN_SS],
[TOKEN_E, TOKEN_EE, TOKEN_SE]
]
class PatternXX(Pattern):
def __init__(self):
super(PatternXX, self).__init__()
self.name = 'XX'
self.tokens = [
[TOKEN_E],
[TOKEN_E, TOKEN_EE, TOKEN_S, TOKEN_ES],
[TOKEN_S, TOKEN_SE]
]
class PatternIX(Pattern):
def __init__(self):
super(PatternIX, self).__init__()
self.name = 'IX'
self.tokens = [
[TOKEN_E, TOKEN_S],
[TOKEN_E, TOKEN_EE, TOKEN_SE, TOKEN_S, TOKEN_ES]
]
|