omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tests / path / test_path_identity.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | note |
| 4 | note tests/path/test_path_identity.om -- pure seeded OM-2 PATH-1 test harness. |
| 5 | note Replaces tests/path/test_path_identity.c. Composed after src/path/rx_path.om. |
| 6 | |
| 7 | text t_hex "0123456789abcdef" |
| 8 | text t_kat_sem "90b28b4367cc0f6cc7bd5ec45930629a25d0303a64da13a57e9dfc4a728b7938" |
| 9 | text t_kat_real "32dfd9644010a192e879186c3c0b7824fdc59f7061368dac2c9b15a22b13e6ce" |
| 10 | text t_rnd_fold "30fa471ba8284437c2a38fbb12c021fff3d0418db2a616ebc7c390c18193134c" |
| 11 | |
| 12 | text t_fail_pfx "FAIL check " |
| 13 | text t_nl "\n" |
| 14 | text t_m_ksem "KAT semantic " |
| 15 | text t_m_kreal "KAT realization " |
| 16 | text t_m_r1 "random fold " |
| 17 | text t_m_r2 " (1000 paths, " |
| 18 | text t_m_r3 " round trips, " |
| 19 | text t_m_r4 " swaps)\n" |
| 20 | text t_m_bf1 "bit flips " |
| 21 | text t_m_bf2 " of " |
| 22 | text t_m_bf3 " refused\n" |
| 23 | text t_m_pass1 "PATH-1: PASS, " |
| 24 | text t_m_pass2 " checks\n" |
| 25 | text t_m_fail1 "PATH-1: " |
| 26 | text t_m_fail2 " of " |
| 27 | text t_m_fail3 " checks FAILED\n" |
| 28 | text t_zeta "zeta" |
| 29 | text t_alpha "alpha" |
| 30 | |
| 31 | note Test harness state |
| 32 | note g_tc: [0]=checks [1]=failures [2]=rng |
| 33 | global g_tc ulong 4 |
| 34 | global g_out uchar 4096 |
| 35 | global g_outlen ulong 1 |
| 36 | |
| 37 | note Independent SHA-256 context for fold & tagged_sha |
| 38 | global g_fsh uint 8 |
| 39 | global g_fsbuf uchar 64 |
| 40 | global g_fsmeta ulong 2 |
| 41 | global g_fdig uchar 32 |
| 42 | |
| 43 | note KAT buffer & offsets: [0]=katn [1]=off_ac [2]=off_a0 [3]=off_a1 [4]=off_cc [5]=off_sl [6]=off_s0 [7]=off_s1 |
| 44 | global g_kat uchar 512 |
| 45 | global g_koff ulong 8 |
| 46 | global g_buf2 uchar 65600 |
| 47 | global g_id_a uchar 32 |
| 48 | global g_id_b uchar 32 |
| 49 | global g_id_c uchar 32 |
| 50 | global g_id_d uchar 32 |
| 51 | global g_id_e uchar 32 |
| 52 | |
| 53 | note Random spec storage (24 steps, 6 attrs, 4 cons) |
| 54 | global g_sp_n ulong 3 |
| 55 | global g_sp_ids uchar 96 |
| 56 | global g_sp_fam ulong 24 |
| 57 | global g_sp_role ulong 24 |
| 58 | global g_sp_nin ulong 24 |
| 59 | global g_sp_nout ulong 24 |
| 60 | global g_sp_plen ulong 24 |
| 61 | global g_sp_in uchar 6144 |
| 62 | global g_sp_op uchar 768 |
| 63 | global g_sp_out uchar 6144 |
| 64 | global g_sp_par uchar 1536 |
| 65 | global g_sp_ak uchar 48 |
| 66 | global g_sp_av uchar 24 |
| 67 | global g_sp_avl ulong 6 |
| 68 | global g_sp_ck ulong 4 |
| 69 | global g_sp_cp uchar 12 |
| 70 | global g_sp_cpl ulong 4 |
| 71 | |
| 72 | fn t_out_c c uchar to void |
| 73 | n = get g_outlen 0 |
| 74 | if lt n 4095 |
| 75 | put g_out n c |
| 76 | put g_outlen 0 add n 1 |
| 77 | end |
| 78 | end |
| 79 | |
| 80 | fn t_out_s s view uchar * to void |
| 81 | i = ulong 0 |
| 82 | n = len s |
| 83 | while lt i n |
| 84 | t_out_c get s i |
| 85 | i = add i 1 |
| 86 | end |
| 87 | end |
| 88 | |
| 89 | fn t_out_u64 v ulong to void |
| 90 | tmp = new uchar 24 0 |
| 91 | if eq v 0 |
| 92 | t_out_c 48 |
| 93 | ret |
| 94 | end |
| 95 | k = ulong 0 |
| 96 | while gt v 0 |
| 97 | put tmp k uchar add 48 rem v 10 |
| 98 | v = div v 10 |
| 99 | k = add k 1 |
| 100 | end |
| 101 | while gt k 0 |
| 102 | k = sub k 1 |
| 103 | t_out_c get tmp k |
| 104 | end |
| 105 | end |
| 106 | |
| 107 | fn t_out_flush fd int to void |
| 108 | n = get g_outlen 0 |
| 109 | off = ulong 0 |
| 110 | while lt off n |
| 111 | w = write fd g_out off sub n off |
| 112 | if le w 0 |
| 113 | break |
| 114 | end |
| 115 | off = add off ulong w |
| 116 | end |
| 117 | put g_outlen 0 0 |
| 118 | end |
| 119 | |
| 120 | fn t_chk cond bool tag ulong to void |
| 121 | put g_tc 0 add get g_tc 0 1 |
| 122 | if not cond |
| 123 | put g_tc 1 add get g_tc 1 1 |
| 124 | t_out_flush 1 |
| 125 | t_out_s t_fail_pfx |
| 126 | t_out_u64 tag |
| 127 | t_out_c 10 |
| 128 | t_out_flush 2 |
| 129 | end |
| 130 | end |
| 131 | |
| 132 | note ---- Independent SHA-256 (for fold & independent tagged_sha) ---- |
| 133 | fn f_sha_compress to void |
| 134 | i = ulong 0 |
| 135 | while lt i 16 |
| 136 | o = mul i 4 |
| 137 | b0 = uint get g_fsbuf o |
| 138 | b1 = uint get g_fsbuf add o 1 |
| 139 | b2 = uint get g_fsbuf add o 2 |
| 140 | b3 = uint get g_fsbuf add o 3 |
| 141 | put g_rsw i or or shl b0 24 shl b1 16 or shl b2 8 b3 |
| 142 | i = add i 1 |
| 143 | end |
| 144 | i = ulong 16 |
| 145 | while lt i 64 |
| 146 | w15 = get g_rsw sub i 15 |
| 147 | s0 = xor xor rxp_rotr32 w15 7 rxp_rotr32 w15 18 shr w15 3 |
| 148 | w2 = get g_rsw sub i 2 |
| 149 | s1 = xor xor rxp_rotr32 w2 17 rxp_rotr32 w2 19 shr w2 10 |
| 150 | v = add get g_rsw sub i 16 s0 |
| 151 | v = add v get g_rsw sub i 7 |
| 152 | put g_rsw i add v s1 |
| 153 | i = add i 1 |
| 154 | end |
| 155 | i = ulong 0 |
| 156 | while lt i 8 |
| 157 | put g_rsv i get g_fsh i |
| 158 | i = add i 1 |
| 159 | end |
| 160 | i = ulong 0 |
| 161 | while lt i 64 |
| 162 | rxp_sha_round i |
| 163 | i = add i 1 |
| 164 | end |
| 165 | i = ulong 0 |
| 166 | while lt i 8 |
| 167 | put g_fsh i add get g_fsh i get g_rsv i |
| 168 | i = add i 1 |
| 169 | end |
| 170 | end |
| 171 | |
| 172 | fn f_sha_init to void |
| 173 | rxp_sha_init_tbl |
| 174 | i = ulong 0 |
| 175 | while lt i 8 |
| 176 | put g_fsh i get g_rsk add 64 i |
| 177 | i = add i 1 |
| 178 | end |
| 179 | put g_fsmeta 0 0 |
| 180 | put g_fsmeta 1 0 |
| 181 | end |
| 182 | |
| 183 | fn f_sha_byte b uchar to void |
| 184 | bl = get g_fsmeta 0 |
| 185 | put g_fsbuf bl b |
| 186 | bl = add bl 1 |
| 187 | put g_fsmeta 1 add get g_fsmeta 1 1 |
| 188 | if eq bl 64 |
| 189 | f_sha_compress |
| 190 | bl = 0 |
| 191 | end |
| 192 | put g_fsmeta 0 bl |
| 193 | end |
| 194 | |
| 195 | fn f_sha_final to void |
| 196 | bl = get g_fsmeta 0 |
| 197 | bits = mul get g_fsmeta 1 8 |
| 198 | put g_fsbuf bl 128 |
| 199 | bl = add bl 1 |
| 200 | if gt bl 56 |
| 201 | while lt bl 64 |
| 202 | put g_fsbuf bl 0 |
| 203 | bl = add bl 1 |
| 204 | end |
| 205 | f_sha_compress |
| 206 | bl = 0 |
| 207 | end |
| 208 | while lt bl 56 |
| 209 | put g_fsbuf bl 0 |
| 210 | bl = add bl 1 |
| 211 | end |
| 212 | i = ulong 0 |
| 213 | while lt i 8 |
| 214 | put g_fsbuf add 56 i uchar and shr bits mul sub 7 i 8 255 |
| 215 | i = add i 1 |
| 216 | end |
| 217 | f_sha_compress |
| 218 | i = ulong 0 |
| 219 | while lt i 8 |
| 220 | v = get g_fsh i |
| 221 | o = mul i 4 |
| 222 | put g_fdig o uchar and shr v 24 255 |
| 223 | put g_fdig add o 1 uchar and shr v 16 255 |
| 224 | put g_fdig add o 2 uchar and shr v 8 255 |
| 225 | put g_fdig add o 3 uchar and v 255 |
| 226 | i = add i 1 |
| 227 | end |
| 228 | end |
| 229 | |
| 230 | fn f_tagged_sha_kat tag view uchar * use_buf2 bool n ulong to void |
| 231 | f_sha_init |
| 232 | i = ulong 0 |
| 233 | tl = len tag |
| 234 | while lt i tl |
| 235 | f_sha_byte get tag i |
| 236 | i = add i 1 |
| 237 | end |
| 238 | f_sha_byte 0 |
| 239 | i = ulong 0 |
| 240 | while lt i n |
| 241 | if use_buf2 |
| 242 | f_sha_byte get g_buf2 i |
| 243 | else |
| 244 | f_sha_byte get g_kat i |
| 245 | end |
| 246 | i = add i 1 |
| 247 | end |
| 248 | f_sha_final |
| 249 | end |
| 250 | |
| 251 | fn t_hex_eq_id use_fdig bool lit view uchar * to bool |
| 252 | i = ulong 0 |
| 253 | while lt i 32 |
| 254 | b = uchar 0 |
| 255 | if use_fdig |
| 256 | b = get g_fdig i |
| 257 | else |
| 258 | b = get g_id_out i |
| 259 | end |
| 260 | h0 = get t_hex shr ulong b 4 |
| 261 | h1 = get t_hex and ulong b 15 |
| 262 | if ne h0 get lit mul i 2 |
| 263 | ret false |
| 264 | end |
| 265 | if ne h1 get lit add mul i 2 1 |
| 266 | ret false |
| 267 | end |
| 268 | i = add i 1 |
| 269 | end |
| 270 | ret true |
| 271 | end |
| 272 | |
| 273 | fn t_out_hex use_fdig bool to void |
| 274 | i = ulong 0 |
| 275 | while lt i 32 |
| 276 | b = uchar 0 |
| 277 | if use_fdig |
| 278 | b = get g_fdig i |
| 279 | else |
| 280 | b = get g_id_out i |
| 281 | end |
| 282 | t_out_c get t_hex shr ulong b 4 |
| 283 | t_out_c get t_hex and ulong b 15 |
| 284 | i = add i 1 |
| 285 | end |
| 286 | end |
| 287 | |
| 288 | fn t_same_id_ab to bool |
| 289 | i = ulong 0 |
| 290 | while lt i 32 |
| 291 | if ne get g_id_a i get g_id_b i |
| 292 | ret false |
| 293 | end |
| 294 | i = add i 1 |
| 295 | end |
| 296 | ret true |
| 297 | end |
| 298 | |
| 299 | fn t_same_out_fdig to bool |
| 300 | i = ulong 0 |
| 301 | while lt i 32 |
| 302 | if ne get g_id_out i get g_fdig i |
| 303 | ret false |
| 304 | end |
| 305 | i = add i 1 |
| 306 | end |
| 307 | ret true |
| 308 | end |
| 309 | |
| 310 | fn t_copy_out_to which ulong to void |
| 311 | i = ulong 0 |
| 312 | while lt i 32 |
| 313 | b = get g_id_out i |
| 314 | if eq which 0 |
| 315 | put g_id_a i b |
| 316 | end |
| 317 | if eq which 1 |
| 318 | put g_id_b i b |
| 319 | end |
| 320 | if eq which 2 |
| 321 | put g_id_c i b |
| 322 | end |
| 323 | if eq which 3 |
| 324 | put g_id_d i b |
| 325 | end |
| 326 | if eq which 4 |
| 327 | put g_id_e i b |
| 328 | end |
| 329 | if eq which 5 |
| 330 | put g_id_chk i b |
| 331 | end |
| 332 | i = add i 1 |
| 333 | end |
| 334 | end |
| 335 | |
| 336 | fn t_same_out_with which ulong to bool |
| 337 | i = ulong 0 |
| 338 | while lt i 32 |
| 339 | b = uchar 0 |
| 340 | if eq which 0 |
| 341 | b = get g_id_a i |
| 342 | end |
| 343 | if eq which 1 |
| 344 | b = get g_id_b i |
| 345 | end |
| 346 | if eq which 2 |
| 347 | b = get g_id_c i |
| 348 | end |
| 349 | if eq which 3 |
| 350 | b = get g_id_d i |
| 351 | end |
| 352 | if eq which 4 |
| 353 | b = get g_id_e i |
| 354 | end |
| 355 | if ne get g_id_out i b |
| 356 | ret false |
| 357 | end |
| 358 | i = add i 1 |
| 359 | end |
| 360 | ret true |
| 361 | end |
| 362 | |
| 363 | fn t_mkid_tmp off ulong v ulong to void |
| 364 | i = ulong 0 |
| 365 | while lt i 32 |
| 366 | put g_tmp_ids add off i uchar and add mul v 7 i 255 |
| 367 | i = add i 1 |
| 368 | end |
| 369 | end |
| 370 | |
| 371 | fn t_mkid_in off ulong v ulong to void |
| 372 | i = ulong 0 |
| 373 | while lt i 32 |
| 374 | put g_ts_in add off i uchar and add mul v 7 i 255 |
| 375 | i = add i 1 |
| 376 | end |
| 377 | end |
| 378 | |
| 379 | fn t_mkid_op v ulong to void |
| 380 | i = ulong 0 |
| 381 | while lt i 32 |
| 382 | put g_ts_op i uchar and add mul v 7 i 255 |
| 383 | i = add i 1 |
| 384 | end |
| 385 | end |
| 386 | |
| 387 | fn t_mkid_out off ulong v ulong to void |
| 388 | i = ulong 0 |
| 389 | while lt i 32 |
| 390 | put g_ts_out add off i uchar and add mul v 7 i 255 |
| 391 | i = add i 1 |
| 392 | end |
| 393 | end |
| 394 | |
| 395 | fn t_mkid_real off ulong v ulong to void |
| 396 | i = ulong 0 |
| 397 | while lt i 32 |
| 398 | put g_real_ids add off i uchar and add mul v 7 i 255 |
| 399 | i = add i 1 |
| 400 | end |
| 401 | end |
| 402 | |
| 403 | fn t_simple_step role ulong seed ulong to void |
| 404 | put g_ts_meta 0 shr role 8 |
| 405 | put g_ts_meta 1 role |
| 406 | put g_ts_meta 2 0 |
| 407 | put g_ts_meta 3 0 |
| 408 | put g_ts_meta 4 0 |
| 409 | t_mkid_op seed |
| 410 | end |
| 411 | |
| 412 | fn t_init_mk pid ulong v0 ulong v1 ulong v2 ulong to long |
| 413 | t_mkid_tmp 0 v0 |
| 414 | t_mkid_tmp 32 v1 |
| 415 | t_mkid_tmp 64 v2 |
| 416 | ret rx_path_init pid |
| 417 | end |
| 418 | |
| 419 | fn t_add_attr_lit pid ulong k view uchar * v0 uchar v1 uchar vl ulong to long |
| 420 | kl = len k |
| 421 | i = ulong 0 |
| 422 | while lt i kl |
| 423 | put g_tmp_key i get k i |
| 424 | i = add i 1 |
| 425 | end |
| 426 | if ge vl 1 |
| 427 | put g_tmp_val 0 v0 |
| 428 | end |
| 429 | if ge vl 2 |
| 430 | put g_tmp_val 1 v1 |
| 431 | end |
| 432 | ret rx_path_add_attribute pid kl vl |
| 433 | end |
| 434 | |
| 435 | note ---- KAT bytes & path ---- |
| 436 | fn kat_push b uchar to void |
| 437 | n = get g_koff 0 |
| 438 | put g_kat n b |
| 439 | put g_koff 0 add n 1 |
| 440 | end |
| 441 | |
| 442 | fn kat_push_id v ulong to void |
| 443 | i = ulong 0 |
| 444 | while lt i 32 |
| 445 | kat_push uchar and add mul v 7 i 255 |
| 446 | i = add i 1 |
| 447 | end |
| 448 | end |
| 449 | |
| 450 | fn build_kat_bytes to void |
| 451 | put g_koff 0 0 |
| 452 | kat_push 79 |
| 453 | kat_push 77 |
| 454 | kat_push 71 |
| 455 | kat_push 48 |
| 456 | kat_push 1 |
| 457 | kat_push 12 |
| 458 | kat_push 0 |
| 459 | kat_push 2 |
| 460 | kat_push_id 17 |
| 461 | kat_push_id 34 |
| 462 | kat_push_id 51 |
| 463 | put g_koff 1 get g_koff 0 |
| 464 | kat_push 0 |
| 465 | kat_push 2 |
| 466 | put g_koff 2 get g_koff 0 |
| 467 | kat_push 5 |
| 468 | kat_push 97 |
| 469 | kat_push 108 |
| 470 | kat_push 112 |
| 471 | kat_push 104 |
| 472 | kat_push 97 |
| 473 | kat_push 0 |
| 474 | kat_push 2 |
| 475 | kat_push 2 |
| 476 | kat_push 3 |
| 477 | put g_koff 3 get g_koff 0 |
| 478 | kat_push 4 |
| 479 | kat_push 122 |
| 480 | kat_push 101 |
| 481 | kat_push 116 |
| 482 | kat_push 97 |
| 483 | kat_push 0 |
| 484 | kat_push 1 |
| 485 | kat_push 1 |
| 486 | put g_koff 4 get g_koff 0 |
| 487 | kat_push 0 |
| 488 | kat_push 2 |
| 489 | kat_push 0 |
| 490 | kat_push 1 |
| 491 | kat_push 0 |
| 492 | kat_push 0 |
| 493 | kat_push 0 |
| 494 | kat_push 3 |
| 495 | kat_push 0 |
| 496 | kat_push 1 |
| 497 | kat_push 170 |
| 498 | put g_koff 5 get g_koff 0 |
| 499 | kat_push 0 |
| 500 | kat_push 0 |
| 501 | kat_push 0 |
| 502 | kat_push 158 |
| 503 | put g_koff 6 get g_koff 0 |
| 504 | kat_push 0 |
| 505 | kat_push 0 |
| 506 | kat_push 0 |
| 507 | kat_push 1 |
| 508 | kat_push 1 |
| 509 | kat_push 1 |
| 510 | kat_push 0 |
| 511 | kat_push 1 |
| 512 | kat_push_id 64 |
| 513 | kat_push_id 80 |
| 514 | kat_push 0 |
| 515 | kat_push 1 |
| 516 | kat_push_id 96 |
| 517 | kat_push 0 |
| 518 | kat_push 0 |
| 519 | kat_push 0 |
| 520 | kat_push 2 |
| 521 | kat_push 1 |
| 522 | kat_push 2 |
| 523 | put g_koff 7 get g_koff 0 |
| 524 | kat_push 0 |
| 525 | kat_push 1 |
| 526 | kat_push 0 |
| 527 | kat_push 2 |
| 528 | kat_push 2 |
| 529 | kat_push 4 |
| 530 | kat_push 0 |
| 531 | kat_push 0 |
| 532 | kat_push_id 81 |
| 533 | kat_push 0 |
| 534 | kat_push 0 |
| 535 | kat_push 0 |
| 536 | kat_push 0 |
| 537 | kat_push 0 |
| 538 | kat_push 0 |
| 539 | end |
| 540 | |
| 541 | fn build_kat_path pid ulong to void |
| 542 | t_chk eq t_init_mk pid 17 34 51 0 100 |
| 543 | t_chk eq t_add_attr_lit pid t_zeta 1 0 1 0 101 |
| 544 | t_chk eq t_add_attr_lit pid t_alpha 2 3 2 0 102 |
| 545 | put g_tmp_pay 0 170 |
| 546 | t_chk eq rx_path_add_constraint pid 3 1 0 103 |
| 547 | t_chk eq rx_path_add_constraint pid 1 0 0 104 |
| 548 | t_simple_step 257 80 |
| 549 | put g_ts_meta 2 1 |
| 550 | t_mkid_in 0 64 |
| 551 | put g_ts_meta 3 1 |
| 552 | t_mkid_out 0 96 |
| 553 | put g_ts_meta 4 2 |
| 554 | put g_ts_param 0 1 |
| 555 | put g_ts_param 1 2 |
| 556 | t_chk eq rx_path_append pid 0 105 |
| 557 | t_simple_step 516 81 |
| 558 | t_chk eq rx_path_append pid 0 106 |
| 559 | end |
| 560 | |
| 561 | fn set_base_realization to void |
| 562 | t_mkid_real 0 112 |
| 563 | t_mkid_real 32 113 |
| 564 | t_mkid_real 64 114 |
| 565 | put g_real_sched 0 1 |
| 566 | t_mkid_real 96 115 |
| 567 | end |
| 568 | |
| 569 | fn test_known_answer to void |
| 570 | rx_path_arena_init |
| 571 | build_kat_bytes |
| 572 | build_kat_path 0 |
| 573 | n = rx_path_encode 0 65600 |
| 574 | katn = get g_koff 0 |
| 575 | t_chk eq n long katn 110 |
| 576 | eqb = true |
| 577 | i = ulong 0 |
| 578 | while lt i katn |
| 579 | if ne get g_wire i get g_kat i |
| 580 | eqb = false |
| 581 | break |
| 582 | end |
| 583 | i = add i 1 |
| 584 | end |
| 585 | t_chk eqb 111 |
| 586 | t_chk eq get g_wire 6 0 112 |
| 587 | t_chk eq get g_wire 7 2 112 |
| 588 | t_chk eq get g_wire 104 0 112 |
| 589 | t_chk eq get g_wire 105 2 112 |
| 590 | t_chk eq get g_koff 1 104 113 |
| 591 | t_chk eq rx_path_semantic_id 0 0 114 |
| 592 | f_tagged_sha_kat t_rxp_sem_tag false katn |
| 593 | t_chk t_same_out_fdig 115 |
| 594 | t_copy_out_to 0 |
| 595 | t_out_s t_m_ksem |
| 596 | t_out_hex false |
| 597 | t_out_c 10 |
| 598 | t_chk t_hex_eq_id false t_kat_sem 116 |
| 599 | set_base_realization |
| 600 | t_chk eq rx_path_realization_id 0 0 117 |
| 601 | note independent realization hash |
| 602 | i = ulong 0 |
| 603 | while lt i 32 |
| 604 | put g_buf2 i get g_id_a i |
| 605 | put g_buf2 add 32 i get g_real_ids i |
| 606 | put g_buf2 add 64 i get g_real_ids add 32 i |
| 607 | put g_buf2 add 96 i get g_real_ids add 64 i |
| 608 | put g_buf2 add 130 i get g_real_ids add 96 i |
| 609 | i = add i 1 |
| 610 | end |
| 611 | put g_buf2 128 0 |
| 612 | put g_buf2 129 1 |
| 613 | f_tagged_sha_kat t_rxp_real_tag true 162 |
| 614 | t_chk t_same_out_fdig 118 |
| 615 | t_out_s t_m_kreal |
| 616 | t_out_hex false |
| 617 | t_out_c 10 |
| 618 | t_chk t_hex_eq_id false t_kat_real 119 |
| 619 | t_out_flush 1 |
| 620 | end |
| 621 | |
| 622 | note ---- Randomized 1000 paths ---- |
| 623 | fn t_rnd bnd ulong to ulong |
| 624 | x = get g_tc 2 |
| 625 | x = xor x shl x 13 |
| 626 | x = xor x shr x 7 |
| 627 | x = xor x shl x 17 |
| 628 | put g_tc 2 x |
| 629 | ret rem x bnd |
| 630 | end |
| 631 | |
| 632 | fn t_fam_roles f ulong to ulong |
| 633 | if eq f 1 |
| 634 | ret 4 |
| 635 | end |
| 636 | if eq f 2 |
| 637 | ret 4 |
| 638 | end |
| 639 | if eq f 3 |
| 640 | ret 7 |
| 641 | end |
| 642 | if eq f 4 |
| 643 | ret 7 |
| 644 | end |
| 645 | ret 6 |
| 646 | end |
| 647 | |
| 648 | fn gen_random_step i ulong to void |
| 649 | f = add 1 t_rnd 5 |
| 650 | put g_sp_fam i f |
| 651 | put g_sp_role i or shl f 8 add 1 t_rnd t_fam_roles f |
| 652 | lim = t_rnd 9 |
| 653 | put g_sp_nin i lim |
| 654 | off = mul i 256 |
| 655 | lim = mul lim 32 |
| 656 | k = ulong 0 |
| 657 | while lt k lim |
| 658 | put g_sp_in add off k uchar t_rnd 256 |
| 659 | k = add k 1 |
| 660 | end |
| 661 | off = mul i 32 |
| 662 | k = ulong 0 |
| 663 | while lt k 32 |
| 664 | put g_sp_op add off k uchar t_rnd 256 |
| 665 | k = add k 1 |
| 666 | end |
| 667 | lim = t_rnd 9 |
| 668 | put g_sp_nout i lim |
| 669 | off = mul i 256 |
| 670 | lim = mul lim 32 |
| 671 | k = ulong 0 |
| 672 | while lt k lim |
| 673 | put g_sp_out add off k uchar t_rnd 256 |
| 674 | k = add k 1 |
| 675 | end |
| 676 | lim = t_rnd 65 |
| 677 | put g_sp_plen i lim |
| 678 | off = mul i 64 |
| 679 | k = ulong 0 |
| 680 | while lt k lim |
| 681 | put g_sp_par add off k uchar t_rnd 256 |
| 682 | k = add k 1 |
| 683 | end |
| 684 | end |
| 685 | |
| 686 | fn gen_random_spec_attrs to void |
| 687 | na = t_rnd 7 |
| 688 | put g_sp_n 1 na |
| 689 | base = t_rnd 50 |
| 690 | i = ulong 0 |
| 691 | while lt i na |
| 692 | v = rem add base mul i 7 100 |
| 693 | off = mul i 8 |
| 694 | put g_sp_ak off 107 |
| 695 | put g_sp_ak add off 1 uchar add 48 div v 10 |
| 696 | put g_sp_ak add off 2 uchar add 48 rem v 10 |
| 697 | vl = t_rnd 5 |
| 698 | put g_sp_avl i vl |
| 699 | off = mul i 4 |
| 700 | k = ulong 0 |
| 701 | while lt k vl |
| 702 | put g_sp_av add off k uchar t_rnd 256 |
| 703 | k = add k 1 |
| 704 | end |
| 705 | i = add i 1 |
| 706 | end |
| 707 | end |
| 708 | |
| 709 | fn gen_random_spec_cons to void |
| 710 | nc = t_rnd 5 |
| 711 | put g_sp_n 2 nc |
| 712 | i = ulong 0 |
| 713 | while lt i nc |
| 714 | put g_sp_ck i add 1 t_rnd 9 |
| 715 | cl = add 1 t_rnd 3 |
| 716 | put g_sp_cpl i cl |
| 717 | co = mul i 3 |
| 718 | put g_sp_cp co uchar i |
| 719 | k = ulong 1 |
| 720 | while lt k cl |
| 721 | put g_sp_cp add co k uchar t_rnd 256 |
| 722 | k = add k 1 |
| 723 | end |
| 724 | i = add i 1 |
| 725 | end |
| 726 | end |
| 727 | |
| 728 | fn gen_random_spec to void |
| 729 | i = ulong 0 |
| 730 | while lt i 96 |
| 731 | put g_sp_ids i uchar t_rnd 256 |
| 732 | i = add i 1 |
| 733 | end |
| 734 | ns = t_rnd 25 |
| 735 | put g_sp_n 0 ns |
| 736 | i = ulong 0 |
| 737 | while lt i ns |
| 738 | gen_random_step i |
| 739 | i = add i 1 |
| 740 | end |
| 741 | gen_random_spec_attrs |
| 742 | gen_random_spec_cons |
| 743 | end |
| 744 | |
| 745 | fn load_spec_step i ulong to void |
| 746 | put g_ts_meta 0 get g_sp_fam i |
| 747 | put g_ts_meta 1 get g_sp_role i |
| 748 | lim = get g_sp_nin i |
| 749 | put g_ts_meta 2 lim |
| 750 | put g_ts_meta 3 get g_sp_nout i |
| 751 | put g_ts_meta 4 get g_sp_plen i |
| 752 | off = mul i 256 |
| 753 | lim = mul lim 32 |
| 754 | k = ulong 0 |
| 755 | while lt k lim |
| 756 | put g_ts_in k get g_sp_in add off k |
| 757 | k = add k 1 |
| 758 | end |
| 759 | off = mul i 32 |
| 760 | k = ulong 0 |
| 761 | while lt k 32 |
| 762 | put g_ts_op k get g_sp_op add off k |
| 763 | k = add k 1 |
| 764 | end |
| 765 | off = mul i 256 |
| 766 | lim = mul get g_sp_nout i 32 |
| 767 | k = ulong 0 |
| 768 | while lt k lim |
| 769 | put g_ts_out k get g_sp_out add off k |
| 770 | k = add k 1 |
| 771 | end |
| 772 | off = mul i 64 |
| 773 | lim = get g_sp_plen i |
| 774 | k = ulong 0 |
| 775 | while lt k lim |
| 776 | put g_ts_param k get g_sp_par add off k |
| 777 | k = add k 1 |
| 778 | end |
| 779 | end |
| 780 | |
| 781 | fn build_spec_attrs pid ulong rev bool to bool |
| 782 | ok = true |
| 783 | na = get g_sp_n 1 |
| 784 | j = ulong 0 |
| 785 | while lt j na |
| 786 | idx = j |
| 787 | if rev |
| 788 | idx = sub sub na 1 j |
| 789 | end |
| 790 | off = mul idx 8 |
| 791 | put g_tmp_key 0 get g_sp_ak off |
| 792 | put g_tmp_key 1 get g_sp_ak add off 1 |
| 793 | put g_tmp_key 2 get g_sp_ak add off 2 |
| 794 | vl = get g_sp_avl idx |
| 795 | off = mul idx 4 |
| 796 | k = ulong 0 |
| 797 | while lt k vl |
| 798 | put g_tmp_val k get g_sp_av add off k |
| 799 | k = add k 1 |
| 800 | end |
| 801 | if ne rx_path_add_attribute pid 3 vl 0 |
| 802 | ok = false |
| 803 | end |
| 804 | j = add j 1 |
| 805 | end |
| 806 | ret ok |
| 807 | end |
| 808 | |
| 809 | fn build_spec_cons pid ulong rev bool to bool |
| 810 | ok = true |
| 811 | nc = get g_sp_n 2 |
| 812 | j = ulong 0 |
| 813 | while lt j nc |
| 814 | idx = j |
| 815 | if rev |
| 816 | idx = sub sub nc 1 j |
| 817 | end |
| 818 | cl = get g_sp_cpl idx |
| 819 | co = mul idx 3 |
| 820 | k = ulong 0 |
| 821 | while lt k cl |
| 822 | put g_tmp_pay k get g_sp_cp add co k |
| 823 | k = add k 1 |
| 824 | end |
| 825 | if ne rx_path_add_constraint pid get g_sp_ck idx cl 0 |
| 826 | ok = false |
| 827 | end |
| 828 | j = add j 1 |
| 829 | end |
| 830 | ret ok |
| 831 | end |
| 832 | |
| 833 | fn build_spec_steps pid ulong swa long swb long to bool |
| 834 | ok = true |
| 835 | ns = get g_sp_n 0 |
| 836 | j = ulong 0 |
| 837 | while lt j ns |
| 838 | idx = j |
| 839 | if eq long j swa |
| 840 | idx = ulong swb |
| 841 | else |
| 842 | if eq long j swb |
| 843 | idx = ulong swa |
| 844 | end |
| 845 | end |
| 846 | load_spec_step idx |
| 847 | if ne rx_path_append pid 0 |
| 848 | ok = false |
| 849 | end |
| 850 | j = add j 1 |
| 851 | end |
| 852 | ret ok |
| 853 | end |
| 854 | |
| 855 | fn build_spec_path pid ulong rev bool swa long swb long to bool |
| 856 | i = ulong 0 |
| 857 | while lt i 96 |
| 858 | put g_tmp_ids i get g_sp_ids i |
| 859 | i = add i 1 |
| 860 | end |
| 861 | ok = eq rx_path_init pid 0 |
| 862 | if not build_spec_attrs pid rev |
| 863 | ok = false |
| 864 | end |
| 865 | if not build_spec_cons pid rev |
| 866 | ok = false |
| 867 | end |
| 868 | if not build_spec_steps pid swa swb |
| 869 | ok = false |
| 870 | end |
| 871 | ret ok |
| 872 | end |
| 873 | |
| 874 | fn spec_steps_diff x ulong y ulong to bool |
| 875 | if ne get g_sp_fam x get g_sp_fam y |
| 876 | ret true |
| 877 | end |
| 878 | if ne get g_sp_role x get g_sp_role y |
| 879 | ret true |
| 880 | end |
| 881 | if ne get g_sp_nin x get g_sp_nin y |
| 882 | ret true |
| 883 | end |
| 884 | if ne get g_sp_nout x get g_sp_nout y |
| 885 | ret true |
| 886 | end |
| 887 | if ne get g_sp_plen x get g_sp_plen y |
| 888 | ret true |
| 889 | end |
| 890 | ox = mul x 32 |
| 891 | oy = mul y 32 |
| 892 | k = ulong 0 |
| 893 | while lt k 32 |
| 894 | if ne get g_sp_op add ox k get g_sp_op add oy k |
| 895 | ret true |
| 896 | end |
| 897 | k = add k 1 |
| 898 | end |
| 899 | ret false |
| 900 | end |
| 901 | |
| 902 | fn check_roundtrip n ulong to bool |
| 903 | i = ulong 0 |
| 904 | while lt i n |
| 905 | b = get g_wire i |
| 906 | put g_dec_in i b |
| 907 | put g_buf2 i b |
| 908 | i = add i 1 |
| 909 | end |
| 910 | i = ulong 0 |
| 911 | while lt i 32 |
| 912 | put g_id_chk i get g_id_a i |
| 913 | i = add i 1 |
| 914 | end |
| 915 | if ne rx_path_decode 2 n 0 |
| 916 | ret false |
| 917 | end |
| 918 | if ne rx_path_equal 0 2 1 |
| 919 | ret false |
| 920 | end |
| 921 | if ne rx_path_semantic_id 2 0 |
| 922 | ret false |
| 923 | end |
| 924 | if not t_same_out_with 0 |
| 925 | ret false |
| 926 | end |
| 927 | n2 = rx_path_encode 2 65600 |
| 928 | if ne n2 long n |
| 929 | ret false |
| 930 | end |
| 931 | i = ulong 0 |
| 932 | while lt i n |
| 933 | if ne get g_wire i get g_buf2 i |
| 934 | ret false |
| 935 | end |
| 936 | i = add i 1 |
| 937 | end |
| 938 | ret true |
| 939 | end |
| 940 | |
| 941 | fn test_randomized to void |
| 942 | f_sha_init |
| 943 | rts = ulong 0 |
| 944 | swaps = ulong 0 |
| 945 | c_a = or shl ulong 2654435769 32 ulong 2135587861 |
| 946 | c_b = or shl ulong 3518319154 32 ulong 3516067075 |
| 947 | t = ulong 0 |
| 948 | while lt t 1000 |
| 949 | put g_tc 2 xor c_a mul add t 1 c_b |
| 950 | rx_path_arena_init |
| 951 | gen_random_spec |
| 952 | t_chk build_spec_path 0 false neg long 1 neg long 1 200 |
| 953 | t_chk build_spec_path 1 true neg long 1 neg long 1 201 |
| 954 | t_chk eq rx_path_semantic_id 0 0 202 |
| 955 | t_copy_out_to 0 |
| 956 | t_chk eq rx_path_semantic_id 0 0 203 |
| 957 | t_chk t_same_out_with 0 204 |
| 958 | t_chk eq rx_path_semantic_id 1 0 205 |
| 959 | t_chk t_same_out_with 0 206 |
| 960 | n = rx_path_encode 0 65600 |
| 961 | t_chk ge n 0 207 |
| 962 | if ge n 0 |
| 963 | if check_roundtrip ulong n |
| 964 | rts = add rts 1 |
| 965 | end |
| 966 | end |
| 967 | ns = get g_sp_n 0 |
| 968 | if ge ns 2 |
| 969 | x = t_rnd ns |
| 970 | y = t_rnd ns |
| 971 | if and ne x y spec_steps_diff x y |
| 972 | t_chk build_spec_path 3 false long x long y 208 |
| 973 | t_chk eq rx_path_semantic_id 3 0 209 |
| 974 | t_chk not t_same_out_with 0 210 |
| 975 | swaps = add swaps 1 |
| 976 | end |
| 977 | end |
| 978 | k = ulong 0 |
| 979 | while lt k 32 |
| 980 | f_sha_byte get g_id_a k |
| 981 | k = add k 1 |
| 982 | end |
| 983 | t = add t 1 |
| 984 | end |
| 985 | t_chk eq rts 1000 211 |
| 986 | t_chk gt swaps 800 212 |
| 987 | f_sha_final |
| 988 | t_out_s t_m_r1 |
| 989 | t_out_hex true |
| 990 | t_out_s t_m_r2 |
| 991 | t_out_u64 rts |
| 992 | t_out_s t_m_r3 |
| 993 | t_out_u64 swaps |
| 994 | t_out_s t_m_r4 |
| 995 | t_out_flush 1 |
| 996 | t_chk t_hex_eq_id true t_rnd_fold 213 |
| 997 | end |
| 998 | |
| 999 | note ---- Order sensitivity & Realization separation ---- |
| 1000 | fn test_order_and_realization to void |
| 1001 | rx_path_arena_init |
| 1002 | t_chk eq t_init_mk 0 1 2 3 0 300 |
| 1003 | t_simple_step 514 10 |
| 1004 | t_chk eq rx_path_append 0 0 301 |
| 1005 | t_simple_step 515 11 |
| 1006 | t_chk eq rx_path_append 0 0 302 |
| 1007 | t_chk eq t_init_mk 1 1 2 3 0 303 |
| 1008 | t_simple_step 515 11 |
| 1009 | t_chk eq rx_path_append 1 0 304 |
| 1010 | t_simple_step 514 10 |
| 1011 | t_chk eq rx_path_append 1 0 305 |
| 1012 | t_chk eq rx_path_semantic_id 0 0 306 |
| 1013 | t_copy_out_to 0 |
| 1014 | t_chk eq rx_path_semantic_id 1 0 307 |
| 1015 | t_chk not t_same_out_with 0 308 |
| 1016 | |
| 1017 | rx_path_arena_init |
| 1018 | build_kat_path 0 |
| 1019 | set_base_realization |
| 1020 | t_chk eq rx_path_semantic_id 0 0 310 |
| 1021 | t_copy_out_to 0 |
| 1022 | t_chk eq rx_path_realization_id 0 0 311 |
| 1023 | t_copy_out_to 1 |
| 1024 | fld = ulong 0 |
| 1025 | while lt fld 5 |
| 1026 | set_base_realization |
| 1027 | if eq fld 0 |
| 1028 | t_mkid_real 0 144 |
| 1029 | end |
| 1030 | if eq fld 1 |
| 1031 | t_mkid_real 32 145 |
| 1032 | end |
| 1033 | if eq fld 2 |
| 1034 | t_mkid_real 64 146 |
| 1035 | end |
| 1036 | if eq fld 3 |
| 1037 | put g_real_sched 0 2 |
| 1038 | end |
| 1039 | if eq fld 4 |
| 1040 | t_mkid_real 96 147 |
| 1041 | end |
| 1042 | t_chk eq rx_path_realization_id 0 0 312 |
| 1043 | t_chk not t_same_out_with 1 313 |
| 1044 | t_chk eq rx_path_semantic_id 0 0 314 |
| 1045 | t_chk t_same_out_with 0 315 |
| 1046 | fld = add fld 1 |
| 1047 | end |
| 1048 | set_base_realization |
| 1049 | t_chk eq rx_path_realization_id 0 0 316 |
| 1050 | t_chk t_same_out_with 1 317 |
| 1051 | t_mkid_tmp 0 35 |
| 1052 | t_chk eq rx_path_set_end_anchor 0 0 318 |
| 1053 | t_chk eq rx_path_semantic_id 0 0 319 |
| 1054 | t_chk not t_same_out_with 0 320 |
| 1055 | t_chk eq rx_path_realization_id 0 0 321 |
| 1056 | t_chk not t_same_out_with 1 322 |
| 1057 | end |
| 1058 | |
| 1059 | note ---- Tamper & canonical ---- |
| 1060 | fn dec_rc_chk n ulong to long |
| 1061 | bef = get g_arena_used 0 |
| 1062 | rc = rx_path_decode 2 n |
| 1063 | if ne rc 0 |
| 1064 | t_chk and eq get g_arena_used 0 bef eq rx_path_step_count 2 0 400 |
| 1065 | end |
| 1066 | ret rc |
| 1067 | end |
| 1068 | |
| 1069 | fn patched_rc_1 at_ ulong b0 uchar to long |
| 1070 | katn = get g_koff 0 |
| 1071 | i = ulong 0 |
| 1072 | while lt i katn |
| 1073 | put g_buf2 i get g_kat i |
| 1074 | i = add i 1 |
| 1075 | end |
| 1076 | put g_buf2 at_ b0 |
| 1077 | i = ulong 0 |
| 1078 | while lt i katn |
| 1079 | put g_dec_in i get g_buf2 i |
| 1080 | i = add i 1 |
| 1081 | end |
| 1082 | f_tagged_sha_kat t_rxp_sem_tag true katn |
| 1083 | i = ulong 0 |
| 1084 | while lt i 32 |
| 1085 | put g_id_chk i get g_fdig i |
| 1086 | i = add i 1 |
| 1087 | end |
| 1088 | ret dec_rc_chk katn |
| 1089 | end |
| 1090 | |
| 1091 | fn patched_rc_2 at_ ulong b0 uchar b1 uchar to long |
| 1092 | katn = get g_koff 0 |
| 1093 | i = ulong 0 |
| 1094 | while lt i katn |
| 1095 | put g_buf2 i get g_kat i |
| 1096 | i = add i 1 |
| 1097 | end |
| 1098 | put g_buf2 at_ b0 |
| 1099 | put g_buf2 add at_ 1 b1 |
| 1100 | i = ulong 0 |
| 1101 | while lt i katn |
| 1102 | put g_dec_in i get g_buf2 i |
| 1103 | i = add i 1 |
| 1104 | end |
| 1105 | f_tagged_sha_kat t_rxp_sem_tag true katn |
| 1106 | i = ulong 0 |
| 1107 | while lt i 32 |
| 1108 | put g_id_chk i get g_fdig i |
| 1109 | i = add i 1 |
| 1110 | end |
| 1111 | ret dec_rc_chk katn |
| 1112 | end |
| 1113 | |
| 1114 | fn patched_rc_4 at_ ulong b0 uchar b1 uchar b2 uchar b3 uchar to long |
| 1115 | katn = get g_koff 0 |
| 1116 | i = ulong 0 |
| 1117 | while lt i katn |
| 1118 | put g_buf2 i get g_kat i |
| 1119 | i = add i 1 |
| 1120 | end |
| 1121 | put g_buf2 at_ b0 |
| 1122 | put g_buf2 add at_ 1 b1 |
| 1123 | put g_buf2 add at_ 2 b2 |
| 1124 | put g_buf2 add at_ 3 b3 |
| 1125 | i = ulong 0 |
| 1126 | while lt i katn |
| 1127 | put g_dec_in i get g_buf2 i |
| 1128 | i = add i 1 |
| 1129 | end |
| 1130 | f_tagged_sha_kat t_rxp_sem_tag true katn |
| 1131 | i = ulong 0 |
| 1132 | while lt i 32 |
| 1133 | put g_id_chk i get g_fdig i |
| 1134 | i = add i 1 |
| 1135 | end |
| 1136 | ret dec_rc_chk katn |
| 1137 | end |
| 1138 | |
| 1139 | fn test_tamper_noncanon_a to void |
| 1140 | katn = get g_koff 0 |
| 1141 | oa0 = get g_koff 2 |
| 1142 | oa1 = get g_koff 3 |
| 1143 | note swapped attrs |
| 1144 | i = ulong 0 |
| 1145 | while lt i katn |
| 1146 | put g_buf2 i get g_kat i |
| 1147 | i = add i 1 |
| 1148 | end |
| 1149 | i = ulong 0 |
| 1150 | while lt i 8 |
| 1151 | put g_buf2 add oa0 i get g_kat add oa1 i |
| 1152 | i = add i 1 |
| 1153 | end |
| 1154 | i = ulong 0 |
| 1155 | while lt i 10 |
| 1156 | put g_buf2 add add oa0 8 i get g_kat add oa0 i |
| 1157 | i = add i 1 |
| 1158 | end |
| 1159 | i = ulong 0 |
| 1160 | while lt i katn |
| 1161 | put g_dec_in i get g_buf2 i |
| 1162 | i = add i 1 |
| 1163 | end |
| 1164 | f_tagged_sha_kat t_rxp_sem_tag true katn |
| 1165 | i = ulong 0 |
| 1166 | while lt i 32 |
| 1167 | put g_id_chk i get g_fdig i |
| 1168 | i = add i 1 |
| 1169 | end |
| 1170 | t_chk eq dec_rc_chk katn RX_PATH_ERR_MALFORMED 410 |
| 1171 | note dup attrs |
| 1172 | i = ulong 0 |
| 1173 | while lt i 8 |
| 1174 | put g_buf2 add oa0 i get g_kat add oa1 i |
| 1175 | put g_buf2 add add oa0 8 i get g_kat add oa1 i |
| 1176 | i = add i 1 |
| 1177 | end |
| 1178 | put g_buf2 add oa0 16 120 |
| 1179 | put g_buf2 add oa0 17 120 |
| 1180 | i = ulong 0 |
| 1181 | while lt i katn |
| 1182 | put g_dec_in i get g_buf2 i |
| 1183 | i = add i 1 |
| 1184 | end |
| 1185 | f_tagged_sha_kat t_rxp_sem_tag true katn |
| 1186 | i = ulong 0 |
| 1187 | while lt i 32 |
| 1188 | put g_id_chk i get g_fdig i |
| 1189 | i = add i 1 |
| 1190 | end |
| 1191 | t_chk eq dec_rc_chk katn RX_PATH_ERR_MALFORMED 411 |
| 1192 | end |
| 1193 | |
| 1194 | fn test_tamper_noncanon to void |
| 1195 | test_tamper_noncanon_a |
| 1196 | katn = get g_koff 0 |
| 1197 | occ = get g_koff 4 |
| 1198 | osl = get g_koff 5 |
| 1199 | os1 = get g_koff 7 |
| 1200 | note swapped constraints |
| 1201 | i = ulong 0 |
| 1202 | while lt i katn |
| 1203 | put g_buf2 i get g_kat i |
| 1204 | i = add i 1 |
| 1205 | end |
| 1206 | c0 = add occ 2 |
| 1207 | put g_buf2 c0 0 |
| 1208 | put g_buf2 add c0 1 3 |
| 1209 | put g_buf2 add c0 2 0 |
| 1210 | put g_buf2 add c0 3 1 |
| 1211 | put g_buf2 add c0 4 170 |
| 1212 | put g_buf2 add c0 5 0 |
| 1213 | put g_buf2 add c0 6 1 |
| 1214 | put g_buf2 add c0 7 0 |
| 1215 | put g_buf2 add c0 8 0 |
| 1216 | i = ulong 0 |
| 1217 | while lt i katn |
| 1218 | put g_dec_in i get g_buf2 i |
| 1219 | i = add i 1 |
| 1220 | end |
| 1221 | f_tagged_sha_kat t_rxp_sem_tag true katn |
| 1222 | i = ulong 0 |
| 1223 | while lt i 32 |
| 1224 | put g_id_chk i get g_fdig i |
| 1225 | i = add i 1 |
| 1226 | end |
| 1227 | t_chk eq dec_rc_chk katn RX_PATH_ERR_MALFORMED 412 |
| 1228 | t_chk eq patched_rc_2 os1 0 5 RX_PATH_ERR_MALFORMED 413 |
| 1229 | t_chk eq patched_rc_2 add os1 4 2 5 RX_PATH_ERR_MALFORMED 414 |
| 1230 | t_chk eq patched_rc_2 add os1 4 3 1 RX_PATH_ERR_MALFORMED 415 |
| 1231 | t_chk eq patched_rc_4 osl 0 0 0 157 RX_PATH_ERR_MALFORMED 416 |
| 1232 | note trailing byte with raised steps_len |
| 1233 | i = ulong 0 |
| 1234 | while lt i katn |
| 1235 | put g_buf2 i get g_kat i |
| 1236 | i = add i 1 |
| 1237 | end |
| 1238 | put g_buf2 add osl 3 159 |
| 1239 | put g_buf2 katn 0 |
| 1240 | i = ulong 0 |
| 1241 | while lt i add katn 1 |
| 1242 | put g_dec_in i get g_buf2 i |
| 1243 | i = add i 1 |
| 1244 | end |
| 1245 | f_tagged_sha_kat t_rxp_sem_tag true add katn 1 |
| 1246 | i = ulong 0 |
| 1247 | while lt i 32 |
| 1248 | put g_id_chk i get g_fdig i |
| 1249 | i = add i 1 |
| 1250 | end |
| 1251 | t_chk eq dec_rc_chk add katn 1 RX_PATH_ERR_MALFORMED 417 |
| 1252 | t_chk eq patched_rc_1 3 49 RX_PATH_ERR_MALFORMED 418 |
| 1253 | t_chk eq patched_rc_1 4 2 RX_PATH_ERR_MALFORMED 419 |
| 1254 | t_chk eq patched_rc_1 5 11 RX_PATH_ERR_MALFORMED 420 |
| 1255 | t_chk eq patched_rc_2 6 2 1 RX_PATH_ERR_STEP_LIMIT 421 |
| 1256 | t_chk eq patched_rc_2 get g_koff 1 0 33 RX_PATH_ERR_ATTR_LIMIT 422 |
| 1257 | t_chk eq patched_rc_2 occ 0 17 RX_PATH_ERR_CONST_LIMIT 423 |
| 1258 | t_chk eq patched_rc_2 add os1 6 0 9 RX_PATH_ERR_INPUT_LIMIT 424 |
| 1259 | t_chk eq patched_rc_2 add os1 40 0 9 RX_PATH_ERR_OUTPUT_LIMIT 425 |
| 1260 | t_chk eq patched_rc_4 add os1 42 0 0 4 1 RX_PATH_ERR_PARAM_LIMIT 426 |
| 1261 | t_chk eq dec_rc_chk add RX_PATH_MAX_TOTAL_SERIALIZATION 1 RX_PATH_ERR_BUFFER_OVERFLOW 427 |
| 1262 | end |
| 1263 | |
| 1264 | fn test_tamper_and_canonical to void |
| 1265 | rx_path_arena_init |
| 1266 | build_kat_bytes |
| 1267 | build_kat_path 0 |
| 1268 | katn = get g_koff 0 |
| 1269 | t_chk eq rx_path_semantic_id 0 0 401 |
| 1270 | t_copy_out_to 0 |
| 1271 | t_copy_out_to 5 |
| 1272 | i = ulong 0 |
| 1273 | while lt i katn |
| 1274 | put g_dec_in i get g_kat i |
| 1275 | i = add i 1 |
| 1276 | end |
| 1277 | t_chk eq dec_rc_chk katn 0 402 |
| 1278 | ref = ulong 0 |
| 1279 | tot = mul katn 8 |
| 1280 | bit = ulong 0 |
| 1281 | while lt bit tot |
| 1282 | i = ulong 0 |
| 1283 | while lt i katn |
| 1284 | put g_dec_in i get g_kat i |
| 1285 | i = add i 1 |
| 1286 | end |
| 1287 | bo = div bit 8 |
| 1288 | mask = uchar shl ulong 1 rem bit 8 |
| 1289 | put g_dec_in bo xor get g_dec_in bo mask |
| 1290 | i = ulong 0 |
| 1291 | while lt i 32 |
| 1292 | put g_id_chk i get g_id_a i |
| 1293 | i = add i 1 |
| 1294 | end |
| 1295 | if ne dec_rc_chk katn 0 |
| 1296 | ref = add ref 1 |
| 1297 | end |
| 1298 | bit = add bit 1 |
| 1299 | end |
| 1300 | t_out_s t_m_bf1 |
| 1301 | t_out_u64 ref |
| 1302 | t_out_s t_m_bf2 |
| 1303 | t_out_u64 tot |
| 1304 | t_out_s t_m_bf3 |
| 1305 | t_out_flush 1 |
| 1306 | t_chk eq ref tot 403 |
| 1307 | trunc = ulong 0 |
| 1308 | n = ulong 0 |
| 1309 | while lt n katn |
| 1310 | i = ulong 0 |
| 1311 | while lt i n |
| 1312 | put g_dec_in i get g_kat i |
| 1313 | i = add i 1 |
| 1314 | end |
| 1315 | i = ulong 0 |
| 1316 | while lt i 32 |
| 1317 | put g_id_chk i get g_id_a i |
| 1318 | i = add i 1 |
| 1319 | end |
| 1320 | if ne dec_rc_chk n 0 |
| 1321 | trunc = add trunc 1 |
| 1322 | end |
| 1323 | n = add n 1 |
| 1324 | end |
| 1325 | t_chk eq trunc katn 404 |
| 1326 | i = ulong 0 |
| 1327 | while lt i katn |
| 1328 | put g_dec_in i get g_kat i |
| 1329 | i = add i 1 |
| 1330 | end |
| 1331 | put g_dec_in katn 0 |
| 1332 | t_chk ne dec_rc_chk add katn 1 0 405 |
| 1333 | i = ulong 0 |
| 1334 | while lt i 32 |
| 1335 | put g_id_chk i uchar and add 35 i 255 |
| 1336 | i = add i 1 |
| 1337 | end |
| 1338 | t_chk eq dec_rc_chk katn RX_PATH_ERR_ID_MISMATCH 406 |
| 1339 | test_tamper_noncanon |
| 1340 | end |
| 1341 | |
| 1342 | note ---- Limits ---- |
| 1343 | fn test_limits to void |
| 1344 | rx_path_arena_init |
| 1345 | t_chk eq t_init_mk 0 1 2 3 0 500 |
| 1346 | t_simple_step 772 9 |
| 1347 | ok = ulong 0 |
| 1348 | i = ulong 0 |
| 1349 | while lt i 512 |
| 1350 | if eq rx_path_append 0 0 |
| 1351 | ok = add ok 1 |
| 1352 | end |
| 1353 | i = add i 1 |
| 1354 | end |
| 1355 | t_chk and eq ok 512 eq rx_path_step_count 0 512 501 |
| 1356 | t_chk eq rx_path_semantic_id 0 0 502 |
| 1357 | t_copy_out_to 0 |
| 1358 | u = get g_arena_used 0 |
| 1359 | t_chk eq rx_path_append 0 RX_PATH_ERR_STEP_LIMIT 503 |
| 1360 | t_chk and eq rx_path_step_count 0 512 eq get g_arena_used 0 u 504 |
| 1361 | t_chk eq rx_path_semantic_id 0 0 505 |
| 1362 | t_chk t_same_out_with 0 506 |
| 1363 | n = rx_path_encode 0 65600 |
| 1364 | t_chk ge n 0 507 |
| 1365 | if ge n 0 |
| 1366 | i = ulong 0 |
| 1367 | while lt i ulong n |
| 1368 | put g_dec_in i get g_wire i |
| 1369 | i = add i 1 |
| 1370 | end |
| 1371 | i = ulong 0 |
| 1372 | while lt i 32 |
| 1373 | put g_id_chk i get g_id_a i |
| 1374 | i = add i 1 |
| 1375 | end |
| 1376 | t_chk and eq dec_rc_chk ulong n 0 eq rx_path_step_count 2 512 508 |
| 1377 | end |
| 1378 | |
| 1379 | rx_path_arena_init |
| 1380 | t_chk eq t_init_mk 0 1 2 3 0 510 |
| 1381 | t_simple_step 513 1 |
| 1382 | put g_ts_meta 2 9 |
| 1383 | t_chk eq rx_path_append 0 RX_PATH_ERR_INPUT_LIMIT 511 |
| 1384 | put g_ts_meta 2 8 |
| 1385 | put g_ts_meta 3 9 |
| 1386 | t_chk eq rx_path_append 0 RX_PATH_ERR_OUTPUT_LIMIT 512 |
| 1387 | put g_ts_meta 3 8 |
| 1388 | put g_ts_meta 4 1025 |
| 1389 | t_chk eq rx_path_append 0 RX_PATH_ERR_PARAM_LIMIT 513 |
| 1390 | put g_ts_meta 4 1024 |
| 1391 | put g_ts_meta 1 517 |
| 1392 | t_chk eq rx_path_append 0 RX_PATH_ERR_MALFORMED 514 |
| 1393 | put g_ts_meta 0 6 |
| 1394 | put g_ts_meta 1 1537 |
| 1395 | t_chk eq rx_path_append 0 RX_PATH_ERR_MALFORMED 515 |
| 1396 | put g_ts_meta 0 2 |
| 1397 | put g_ts_meta 1 513 |
| 1398 | t_chk and eq rx_path_step_count 0 0 eq get g_arena_used 0 0 516 |
| 1399 | bigc = ulong 0 |
| 1400 | rc = long 0 |
| 1401 | while eq rc 0 |
| 1402 | rc = rx_path_append 0 |
| 1403 | if eq rc 0 |
| 1404 | bigc = add bigc 1 |
| 1405 | end |
| 1406 | end |
| 1407 | t_chk and eq rc RX_PATH_ERR_BUFFER_OVERFLOW and gt bigc 0 lt bigc 512 517 |
| 1408 | sz = rx_path_encoded_size 0 |
| 1409 | t_chk and ge sz 0 le ulong sz RX_PATH_MAX_TOTAL_SERIALIZATION 518 |
| 1410 | t_chk eq rx_path_encode 0 16 RX_PATH_ERR_BUFFER_OVERFLOW 519 |
| 1411 | |
| 1412 | rx_path_arena_init |
| 1413 | t_chk eq t_init_mk 0 1 2 3 0 520 |
| 1414 | put g_tmp_val 0 1 |
| 1415 | i = ulong 0 |
| 1416 | while lt i 32 |
| 1417 | put g_tmp_key 0 97 |
| 1418 | put g_tmp_key 1 uchar add 48 div i 10 |
| 1419 | put g_tmp_key 2 uchar add 48 rem i 10 |
| 1420 | t_chk eq rx_path_add_attribute 0 3 1 0 521 |
| 1421 | i = add i 1 |
| 1422 | end |
| 1423 | put g_tmp_key 0 122 |
| 1424 | put g_tmp_key 1 122 |
| 1425 | t_chk eq rx_path_add_attribute 0 2 1 RX_PATH_ERR_ATTR_LIMIT 522 |
| 1426 | t_chk eq t_init_mk 0 1 2 3 0 523 |
| 1427 | put g_tmp_key 0 107 |
| 1428 | t_chk eq rx_path_add_attribute 0 1 1 0 524 |
| 1429 | t_chk eq rx_path_add_attribute 0 1 1 RX_PATH_ERR_MALFORMED 525 |
| 1430 | i = ulong 0 |
| 1431 | while lt i 16 |
| 1432 | put g_tmp_pay 0 uchar i |
| 1433 | t_chk eq rx_path_add_constraint 0 1 1 0 526 |
| 1434 | i = add i 1 |
| 1435 | end |
| 1436 | put g_tmp_pay 0 1 |
| 1437 | t_chk eq rx_path_add_constraint 0 2 1 RX_PATH_ERR_CONST_LIMIT 527 |
| 1438 | end |
| 1439 | |
| 1440 | note ---- Fork prefix, No authority, Review regressions ---- |
| 1441 | fn t_numbered i ulong to void |
| 1442 | t_simple_step 772 add 200 i |
| 1443 | put g_ts_meta 2 1 |
| 1444 | t_mkid_in 0 add 300 i |
| 1445 | end |
| 1446 | |
| 1447 | fn test_fork_prefix to void |
| 1448 | rx_path_arena_init |
| 1449 | t_chk eq t_init_mk 0 1 2 3 0 600 |
| 1450 | i = ulong 0 |
| 1451 | while lt i 10 |
| 1452 | t_numbered i |
| 1453 | t_chk eq rx_path_append 0 0 601 |
| 1454 | i = add i 1 |
| 1455 | end |
| 1456 | t_chk eq rx_path_semantic_id 0 0 602 |
| 1457 | t_copy_out_to 0 |
| 1458 | t_chk eq rx_path_fork 0 0 3 RX_PATH_ERR_ARG 603 |
| 1459 | t_chk eq rx_path_fork 1 0 11 RX_PATH_ERR_ARG 604 |
| 1460 | t_chk eq get g_p_frozen 0 0 605 |
| 1461 | t_chk eq rx_path_fork 1 0 6 0 606 |
| 1462 | t_chk eq t_init_mk 5 1 2 3 0 607 |
| 1463 | i = ulong 0 |
| 1464 | while lt i 6 |
| 1465 | t_numbered i |
| 1466 | t_chk eq rx_path_append 5 0 608 |
| 1467 | i = add i 1 |
| 1468 | end |
| 1469 | t_chk eq rx_path_semantic_id 1 0 609 |
| 1470 | t_copy_out_to 1 |
| 1471 | t_chk eq rx_path_semantic_id 5 0 610 |
| 1472 | t_chk t_same_out_with 1 611 |
| 1473 | u = get g_arena_used 0 |
| 1474 | i = ulong 50 |
| 1475 | while lt i 53 |
| 1476 | t_numbered i |
| 1477 | t_chk eq rx_path_append 1 0 612 |
| 1478 | i = add i 1 |
| 1479 | end |
| 1480 | t_chk eq get g_arena_used 0 add u 3 613 |
| 1481 | t_chk and eq get g_p_tcnt 1 3 eq rx_path_step_count 1 9 614 |
| 1482 | i = ulong 50 |
| 1483 | while lt i 53 |
| 1484 | t_numbered i |
| 1485 | t_chk eq rx_path_append 5 0 615 |
| 1486 | i = add i 1 |
| 1487 | end |
| 1488 | t_chk eq rx_path_semantic_id 1 0 616 |
| 1489 | t_copy_out_to 1 |
| 1490 | t_chk eq rx_path_semantic_id 5 0 617 |
| 1491 | t_chk t_same_out_with 1 618 |
| 1492 | n1 = rx_path_encode 1 65600 |
| 1493 | i = ulong 0 |
| 1494 | while lt i ulong n1 |
| 1495 | put g_buf2 i get g_wire i |
| 1496 | i = add i 1 |
| 1497 | end |
| 1498 | n2 = rx_path_encode 5 65600 |
| 1499 | t_chk eq n1 n2 619 |
| 1500 | eqb = true |
| 1501 | i = ulong 0 |
| 1502 | while lt i ulong n1 |
| 1503 | if ne get g_wire i get g_buf2 i |
| 1504 | eqb = false |
| 1505 | break |
| 1506 | end |
| 1507 | i = add i 1 |
| 1508 | end |
| 1509 | t_chk eqb 620 |
| 1510 | t_chk eq rx_path_equal 1 5 1 621 |
| 1511 | t_chk eq get g_p_frozen 0 1 622 |
| 1512 | t_numbered 99 |
| 1513 | t_chk eq rx_path_append 0 RX_PATH_ERR_FROZEN 623 |
| 1514 | put g_tmp_key 0 120 |
| 1515 | put g_tmp_val 0 1 |
| 1516 | t_chk eq rx_path_add_attribute 0 1 1 RX_PATH_ERR_FROZEN 624 |
| 1517 | put g_tmp_pay 0 1 |
| 1518 | t_chk eq rx_path_add_constraint 0 1 1 RX_PATH_ERR_FROZEN 625 |
| 1519 | t_mkid_tmp 0 9 |
| 1520 | t_chk eq rx_path_set_end_anchor 0 RX_PATH_ERR_FROZEN 626 |
| 1521 | t_chk eq rx_path_semantic_id 0 0 627 |
| 1522 | t_chk and t_same_out_with 0 eq rx_path_step_count 0 10 628 |
| 1523 | t_chk eq rx_path_fork 3 0 6 0 629 |
| 1524 | t_numbered 77 |
| 1525 | t_chk eq rx_path_append 3 0 630 |
| 1526 | t_chk eq rx_path_semantic_id 3 0 631 |
| 1527 | t_chk not t_same_out_with 1 632 |
| 1528 | t_chk eq rx_path_semantic_id 1 0 633 |
| 1529 | t_chk t_same_out_with 1 634 |
| 1530 | t_chk eq rx_path_fork 4 1 8 0 635 |
| 1531 | t_chk eq rx_path_append 1 RX_PATH_ERR_FROZEN 636 |
| 1532 | t_chk eq rx_path_append 4 0 637 |
| 1533 | t_chk eq t_init_mk 5 1 2 3 0 638 |
| 1534 | i = ulong 0 |
| 1535 | while lt i 6 |
| 1536 | t_numbered i |
| 1537 | t_chk eq rx_path_append 5 0 639 |
| 1538 | i = add i 1 |
| 1539 | end |
| 1540 | i = ulong 50 |
| 1541 | while lt i 52 |
| 1542 | t_numbered i |
| 1543 | t_chk eq rx_path_append 5 0 640 |
| 1544 | i = add i 1 |
| 1545 | end |
| 1546 | t_numbered 77 |
| 1547 | t_chk eq rx_path_append 5 0 641 |
| 1548 | t_chk eq rx_path_semantic_id 4 0 642 |
| 1549 | t_copy_out_to 4 |
| 1550 | t_chk eq rx_path_semantic_id 5 0 643 |
| 1551 | t_chk t_same_out_with 4 644 |
| 1552 | keep = get g_p_tail 0 |
| 1553 | put g_p_tail 0 get g_p_tail 1 |
| 1554 | t_chk eq rx_path_semantic_id 1 RX_PATH_ERR_ID_MISMATCH 645 |
| 1555 | t_chk eq rx_path_semantic_id 4 RX_PATH_ERR_ID_MISMATCH 646 |
| 1556 | put g_p_tail 0 keep |
| 1557 | t_chk eq rx_path_semantic_id 4 0 647 |
| 1558 | t_chk t_same_out_with 4 648 |
| 1559 | end |
| 1560 | |
| 1561 | fn test_no_authority_and_regressions to void |
| 1562 | rx_path_arena_init |
| 1563 | t_chk eq t_init_mk 0 1 2 3 0 700 |
| 1564 | r = ulong 1025 |
| 1565 | while le r 1031 |
| 1566 | t_simple_step r r |
| 1567 | t_chk eq rx_path_append 0 0 701 |
| 1568 | r = add r 1 |
| 1569 | end |
| 1570 | t_simple_step 775 1 |
| 1571 | t_chk eq rx_path_append 0 0 702 |
| 1572 | t_chk eq rx_path_semantic_id 0 0 703 |
| 1573 | t_chk ge rx_path_encode 0 65600 0 704 |
| 1574 | t_chk and eq get g_p_frozen 0 0 eq rx_path_step_count 0 8 705 |
| 1575 | |
| 1576 | rx_path_arena_init |
| 1577 | t_chk eq t_init_mk 0 1 2 3 0 800 |
| 1578 | t_simple_step 772 5 |
| 1579 | t_chk eq rx_path_append 0 0 801 |
| 1580 | s0 = get g_p_tail 0 |
| 1581 | put g_st_nin s0 9 |
| 1582 | t_chk eq rx_path_encoded_size 0 RX_PATH_ERR_INPUT_LIMIT 802 |
| 1583 | t_chk eq rx_path_encode 0 65600 RX_PATH_ERR_INPUT_LIMIT 803 |
| 1584 | t_chk eq rx_path_semantic_id 0 RX_PATH_ERR_INPUT_LIMIT 804 |
| 1585 | t_chk eq rx_path_equal 0 0 RX_PATH_ERR_INPUT_LIMIT 805 |
| 1586 | put g_st_nin s0 0 |
| 1587 | put g_st_plen s0 4294967280 |
| 1588 | t_chk eq rx_path_encode 0 65600 RX_PATH_ERR_PARAM_LIMIT 806 |
| 1589 | put g_st_plen s0 0 |
| 1590 | put g_p_acnt 0 add RX_PATH_MAX_ATTR_COUNT 1 |
| 1591 | t_chk eq rx_path_encode 0 65600 RX_PATH_ERR_ATTR_LIMIT 807 |
| 1592 | put g_p_acnt 0 0 |
| 1593 | put g_p_ccnt 0 add RX_PATH_MAX_CONSTRAINT_COUNT 1 |
| 1594 | t_chk eq rx_path_encode 0 65600 RX_PATH_ERR_CONST_LIMIT 808 |
| 1595 | put g_p_ccnt 0 0 |
| 1596 | t_chk eq rx_path_semantic_id 0 0 809 |
| 1597 | t_copy_out_to 0 |
| 1598 | |
| 1599 | t_chk eq rx_path_fork 1 0 1 0 810 |
| 1600 | t_chk eq rx_path_fork 0 1 1 RX_PATH_ERR_ARG 811 |
| 1601 | t_chk and eq get g_p_frozen 0 1 and eq get g_p_parent 0 neg long 1 eq rx_path_step_count 0 1 812 |
| 1602 | t_chk eq rx_path_semantic_id 0 0 813 |
| 1603 | t_chk t_same_out_with 0 814 |
| 1604 | t_chk eq rx_path_fork 2 1 1 0 815 |
| 1605 | t_chk eq rx_path_fork 0 2 0 RX_PATH_ERR_ARG 816 |
| 1606 | t_chk eq rx_path_semantic_id 0 0 817 |
| 1607 | t_chk t_same_out_with 0 818 |
| 1608 | |
| 1609 | t_chk ge rx_path_encode 1 65600 0 819 |
| 1610 | i = ulong 0 |
| 1611 | while lt i 32 |
| 1612 | put g_p_start i uchar and add mul ulong 77 7 i 255 |
| 1613 | i = add i 1 |
| 1614 | end |
| 1615 | t_chk eq rx_path_encode 1 65600 RX_PATH_ERR_ID_MISMATCH 820 |
| 1616 | t_chk eq rx_path_encode 2 65600 RX_PATH_ERR_ID_MISMATCH 821 |
| 1617 | i = ulong 0 |
| 1618 | while lt i 32 |
| 1619 | put g_p_start i uchar and add 7 i 255 |
| 1620 | i = add i 1 |
| 1621 | end |
| 1622 | t_chk ge rx_path_encode 2 65600 0 822 |
| 1623 | |
| 1624 | t_chk eq t_init_mk 3 1 2 3 0 823 |
| 1625 | put g_tmp_pay 0 2 |
| 1626 | t_chk eq rx_path_add_constraint 3 4 1 0 824 |
| 1627 | put g_tmp_pay 0 1 |
| 1628 | t_chk eq rx_path_add_constraint 3 4 1 0 825 |
| 1629 | put g_tmp_pay 0 2 |
| 1630 | t_chk eq rx_path_add_constraint 3 4 1 0 826 |
| 1631 | c3 = ulong 48 |
| 1632 | t_chk eq get g_p_ccnt 3 3 827 |
| 1633 | t_chk eq get g_c_pay mul c3 128 1 827 |
| 1634 | t_chk eq get g_c_pay mul add c3 1 128 2 827 |
| 1635 | t_chk eq get g_c_pay mul add c3 2 128 2 827 |
| 1636 | t_chk eq t_init_mk 4 1 2 3 0 828 |
| 1637 | put g_tmp_pay 0 2 |
| 1638 | t_chk eq rx_path_add_constraint 4 4 1 0 829 |
| 1639 | t_chk eq rx_path_add_constraint 4 4 1 0 830 |
| 1640 | put g_tmp_pay 0 1 |
| 1641 | t_chk eq rx_path_add_constraint 4 4 1 0 831 |
| 1642 | t_chk eq rx_path_semantic_id 3 0 832 |
| 1643 | t_copy_out_to 0 |
| 1644 | t_copy_out_to 5 |
| 1645 | t_chk eq rx_path_semantic_id 4 0 833 |
| 1646 | t_chk t_same_out_with 0 834 |
| 1647 | n = rx_path_encode 3 65600 |
| 1648 | t_chk ge n 0 835 |
| 1649 | i = ulong 0 |
| 1650 | while lt i ulong n |
| 1651 | put g_dec_in i get g_wire i |
| 1652 | i = add i 1 |
| 1653 | end |
| 1654 | t_chk and eq dec_rc_chk ulong n 0 eq get g_p_ccnt 2 3 836 |
| 1655 | t_chk eq rx_path_equal 2 3 1 837 |
| 1656 | t_chk eq t_init_mk 5 1 2 3 0 838 |
| 1657 | put g_tmp_pay 0 1 |
| 1658 | t_chk eq rx_path_add_constraint 5 4 1 0 839 |
| 1659 | put g_tmp_pay 0 2 |
| 1660 | t_chk eq rx_path_add_constraint 5 4 1 0 840 |
| 1661 | t_chk eq rx_path_semantic_id 5 0 841 |
| 1662 | t_chk not t_same_out_with 0 842 |
| 1663 | end |
| 1664 | |
| 1665 | fn main to int |
| 1666 | test_known_answer |
| 1667 | test_randomized |
| 1668 | test_order_and_realization |
| 1669 | test_tamper_and_canonical |
| 1670 | test_limits |
| 1671 | test_fork_prefix |
| 1672 | test_no_authority_and_regressions |
| 1673 | if ne get g_tc 1 0 |
| 1674 | t_out_s t_m_fail1 |
| 1675 | t_out_u64 get g_tc 1 |
| 1676 | t_out_s t_m_fail2 |
| 1677 | t_out_u64 get g_tc 0 |
| 1678 | t_out_s t_m_fail3 |
| 1679 | t_out_flush 1 |
| 1680 | ret 1 |
| 1681 | end |
| 1682 | t_out_s t_m_pass1 |
| 1683 | t_out_u64 get g_tc 0 |
| 1684 | t_out_s t_m_pass2 |
| 1685 | t_out_flush 1 |
| 1686 | ret 0 |
| 1687 | end |