Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/quiet/qn2bind.om # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / quiet / qn2bind.om` 393 lines ยท 5814 bytes Raw Blame History 1 note quiet/qn2bind.om: FORGE-EVIDENCE v1 bind. The six field lines are hashed; the bind line is not. 2 note Both forge-contribute and the patch page call qncanon, so a stale bind cannot pass. 3 text tqev1 "FORGE-EVIDENCE v1" 4 text tqcmt "commit=" 5 text tqtre "tree=" 6 text tqcmdk "cmd=" 7 text tqrck "rc=" 8 text tqoutk "out=" 9 text tqagk2 "agent=" 10 text tqbnd "bind=" 11 global qnrc uchar 1024 12 global qnrcl ulong 1 13 global qncm uchar 40 14 global qntr uchar 40 15 global qncmd uchar 200 16 global qncmdl ulong 1 17 global qnrcn ulong 1 18 global qnout64 uchar 64 19 global qnag uchar 40 20 global qnagl ulong 1 21 global qnbd uchar 64 22 global qncan uchar 512 23 global qncanl ulong 1 24 global qnst ulong 1 25 fn qnhexd c uchar to bool 26 if and ge c 48 le c 57 27 ret true 28 end 29 ret and ge c 97 le c 102 30 end 31 fn qnhxb v uchar to uchar 32 if lt v 10 33 ret add v 48 34 end 35 ret add v 87 36 end 37 fn qncanb c uchar to void 38 n = get qncanl 0 39 if lt n 511 40 put qncan n c 41 put qncanl 0 add n 1 42 end 43 end 44 fn qncant t view uchar * to void 45 for i ulong len t bound 16 46 qncanb get t i 47 end 48 end 49 note qncanh: n is 40 (commit, tree), 64 (out), at most 39 (agent) or at most 200 (cmd: qncopy and 50 note qncanon refuse more), so the bound is 200, the largest. It was 64: a cmd of 65 bytes was trap 4. 51 fn qncanh a ulong n ulong src ulong to void 52 for i ulong n bound 200 53 if eq src 0 54 qncanb get qncm i 55 end 56 if eq src 1 57 qncanb get qntr i 58 end 59 if eq src 2 60 qncanb get qnout64 i 61 end 62 if eq src 3 63 qncanb get qnag i 64 end 65 if eq src 4 66 qncanb get qncmd i 67 end 68 end 69 end 70 fn qncand v ulong to void 71 if ge v 10 72 qncand div v 10 73 end 74 qncanb add 48 uchar rem v 10 75 end 76 fn qncanon to bool 77 put qncanl 0 0 78 if ne get qncmdl 0 0 79 if gt get qncmdl 0 200 80 ret false 81 end 82 end 83 if or eq get qnagl 0 0 gt get qnagl 0 39 84 ret false 85 end 86 if gt get qnrcn 0 255 87 ret false 88 end 89 qncant tqcmt 90 qncanh 0 40 0 91 qncanb 10 92 qncant tqtre 93 qncanh 0 40 1 94 qncanb 10 95 qncant tqcmdk 96 qncanh 0 get qncmdl 0 4 97 qncanb 10 98 qncant tqrck 99 qncand get qnrcn 0 100 qncanb 10 101 qncant tqoutk 102 qncanh 0 64 2 103 qncanb 10 104 qncant tqagk2 105 qncanh 0 get qnagl 0 3 106 qncanb 10 107 if gt get qncanl 0 511 108 ret false 109 end 110 ret true 111 end 112 fn qnsha hh edit uchar * to void 113 b = new uchar 512 0 114 n = get qncanl 0 115 for i ulong n bound 512 116 put b i get qncan i 117 end 118 k = sha2_digest 256 view part b 0 n hh 119 end 120 fn qnseal to bool 121 if not qncanon 122 ret false 123 end 124 h = new uchar 32 0 125 qnsha h 126 put qnrcl 0 0 127 for i ulong len tqev1 128 put qnrc i get tqev1 i 129 end 130 put qnrcl 0 len tqev1 131 put qnrc get qnrcl 0 10 132 put qnrcl 0 add get qnrcl 0 1 133 for i ulong get qncanl 0 bound 512 134 put qnrc add get qnrcl 0 i get qncan i 135 end 136 put qnrcl 0 add get qnrcl 0 get qncanl 0 137 for i ulong len tqbnd 138 put qnrc add get qnrcl 0 i get tqbnd i 139 end 140 put qnrcl 0 add get qnrcl 0 len tqbnd 141 for i ulong 32 142 v = get h i 143 put qnrc add get qnrcl 0 mul i 2 qnhxb shr v 4 144 put qnrc add add get qnrcl 0 mul i 2 1 qnhxb and v 15 145 end 146 put qnrcl 0 add get qnrcl 0 64 147 put qnrc get qnrcl 0 10 148 put qnrcl 0 add get qnrcl 0 1 149 ret true 150 end 151 fn qnlnat p ulong to ulong 152 q = p 153 while lt q get qnrcl 0 bound 1024 154 if eq get qnrc q 10 155 ret q 156 end 157 q = add q 1 158 end 159 ret get qnrcl 0 160 end 161 fn qnpre p ulong t view uchar * to bool 162 if gt add p len t get qnrcl 0 163 ret false 164 end 165 for i ulong len t bound 16 166 if ne get qnrc add p i get t i 167 ret false 168 end 169 end 170 ret true 171 end 172 fn qncopy p ulong n ulong dst ulong to bool 173 if eq dst 0 174 if ne n 40 175 ret false 176 end 177 for i ulong 40 178 c = get qnrc add p i 179 if not qnhexd c 180 ret false 181 end 182 put qncm i c 183 end 184 ret true 185 end 186 if eq dst 1 187 if ne n 40 188 ret false 189 end 190 for i ulong 40 191 c = get qnrc add p i 192 if not qnhexd c 193 ret false 194 end 195 put qntr i c 196 end 197 ret true 198 end 199 if eq dst 2 200 if or eq n 0 gt n 200 201 ret false 202 end 203 for i ulong n bound 200 204 c = get qnrc add p i 205 if or lt c 32 eq c 127 206 ret false 207 end 208 put qncmd i c 209 end 210 put qncmdl 0 n 211 ret true 212 end 213 if eq dst 3 214 if or eq n 0 gt n 3 215 ret false 216 end 217 v = ulong 0 218 for i ulong n bound 3 219 c = get qnrc add p i 220 if not and ge c 48 le c 57 221 ret false 222 end 223 v = add mul v 10 sub ulong c 48 224 end 225 if gt v 255 226 ret false 227 end 228 if and gt n 1 eq get qnrc p 48 229 ret false 230 end 231 put qnrcn 0 v 232 ret true 233 end 234 if eq dst 4 235 if ne n 64 236 ret false 237 end 238 for i ulong 64 239 c = get qnrc add p i 240 if not qnhexd c 241 ret false 242 end 243 put qnout64 i c 244 end 245 ret true 246 end 247 if eq dst 5 248 if or eq n 0 gt n 39 249 ret false 250 end 251 for i ulong n bound 39 252 c = get qnrc add p i 253 ok = false 254 if and ge c 48 le c 57 255 ok = true 256 end 257 if and ge c 97 le c 122 258 ok = true 259 end 260 if eq c 45 261 ok = true 262 end 263 if not ok 264 ret false 265 end 266 put qnag i c 267 end 268 put qnagl 0 n 269 ret true 270 end 271 if eq dst 6 272 if ne n 64 273 ret false 274 end 275 for i ulong 64 276 c = get qnrc add p i 277 if not qnhexd c 278 ret false 279 end 280 put qnbd i c 281 end 282 ret true 283 end 284 ret false 285 end 286 fn qnmark to ulong 287 n = get qnrcl 0 288 m = len tqev1 289 p = ulong 0 290 while lt p n bound 1024 291 e = qnlnat p 292 if eq sub e p m 293 hit = true 294 for i ulong m bound 20 295 if ne get qnrc add p i get tqev1 i 296 hit = false 297 end 298 end 299 if hit 300 if eq e n 301 ret 9999 302 end 303 ret add e 1 304 end 305 end 306 p = add e 1 307 if eq e n 308 p = n 309 end 310 end 311 ret 9999 312 end 313 fn qnfield p ulong t view uchar * dst ulong to ulong 314 e = qnlnat p 315 if not qnpre p t 316 ret 9999 317 end 318 a = add p len t 319 if gt a e 320 ret 9999 321 end 322 if not qncopy a sub e a dst 323 ret 9999 324 end 325 if eq e get qnrcl 0 326 ret e 327 end 328 ret add e 1 329 end 330 fn qnparse to bool 331 p = qnmark 332 if eq p 9999 333 put qnst 0 0 334 ret false 335 end 336 p = qnfield p tqcmt 0 337 if eq p 9999 338 put qnst 0 2 339 ret false 340 end 341 p = qnfield p tqtre 1 342 if eq p 9999 343 put qnst 0 2 344 ret false 345 end 346 p = qnfield p tqcmdk 2 347 if eq p 9999 348 put qnst 0 2 349 ret false 350 end 351 p = qnfield p tqrck 3 352 if eq p 9999 353 put qnst 0 2 354 ret false 355 end 356 p = qnfield p tqoutk 4 357 if eq p 9999 358 put qnst 0 2 359 ret false 360 end 361 p = qnfield p tqagk2 5 362 if eq p 9999 363 put qnst 0 2 364 ret false 365 end 366 p = qnfield p tqbnd 6 367 if eq p 9999 368 put qnst 0 2 369 ret false 370 end 371 ret true 372 end 373 fn qnbindok to bool 374 if not qncanon 375 put qnst 0 2 376 ret false 377 end 378 h = new uchar 32 0 379 qnsha h 380 hex = new uchar 64 0 381 for i ulong 32 382 v = get h i 383 put hex mul i 2 qnhxb shr v 4 384 put hex add mul i 2 1 qnhxb and v 15 385 end 386 for i ulong 64 387 if ne get hex i get qnbd i 388 put qnst 0 3 389 ret false 390 end 391 end 392 ret true 393 end