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/open-humanity/blob/main/om/trace_receiver_main.om # open-humanity Privacy-first peer assistance network for sovereign autonomous agents 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 `open-humanity / om / trace_receiver_main.om` 160 lines ยท 3923 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note protocol/open-humanity/trace_receiver_main.om 3 note Standalone pure-Omega CLI for the Open Humanity exact-byte wire codec, consent/export, 4 note and AITR v1 trace-receiver contract. 5 note Compose with: 6 note si/directives/om2.om protocol/open-humanity/lib.om 7 note protocol/omnet/om/sha512/sha512.om protocol/omnet/om/`ed25519`/`ed25519`.om 8 note protocol/open-humanity/trace_contract.om protocol/open-humanity/trace_receiver_main.om 9 note Subcommands: 10 note version print contract version and wire framing details 11 note selfcheck execute signed OHCN v1 consent -> AITR v1 export -> OHTX v1 receive + Register verify 12 note wire-check print hex of canonical Challenge, Ack, and keyed BLAKE3 cookie for parity checks 13 14 text trm_ver "open-humanity-trace-om 1.0 (wire=0x4f-v1, consent=OHCN-v1, export=OHTX-v1, trace=AITR-v1)\n" 15 text trm_usage "usage: open-humanity-trace version|selfcheck|wire-check\n" 16 text trm_cmd_ver "version" 17 text trm_cmd_sc "selfcheck" 18 text trm_cmd_wc "wire-check" 19 text trm_ok "TRACE_RECEIVER SELFCHECK PASS bundle_bytes=" 20 text trm_seg " recv_aitr_bytes=" 21 text trm_fail "TRACE_RECEIVER SELFCHECK FAIL code=" 22 text trm_ck_lbl "COOKIE=" 23 text trm_ch_lbl "CHALLENGE=" 24 text trm_ak_lbl "ACK=" 25 text trm_rg_lbl "REGISTER=" 26 text trm_nl "\n" 27 text trm_addr "192.0.2.1:4000" 28 text trm_pay0 "sm121_ok lat=400us" 29 30 global trm_arg uchar 64 31 32 fn trm_arg_eq idx ulong lit view uchar * to bool 33 n = argread idx trm_arg 0 64 34 if lt n 0 35 ret false 36 end 37 un = ulong n 38 if ne un len lit 39 ret false 40 end 41 for i ulong un bound 64 42 if ne get trm_arg i get lit i 43 ret false 44 end 45 end 46 ret true 47 end 48 49 fn trm_write_hex buf view uchar * to void 50 n = len buf 51 out_h = new uchar 2 0 52 for i ulong n bound 512 53 bv = ulong get buf i 54 put out_h 0 get oh_hex_chars shr bv 4 55 put out_h 1 get oh_hex_chars and bv 15 56 ok = oh_write_all 1 out_h 57 if not ok 58 ret 59 end 60 end 61 end 62 63 fn trm_wire_check_reg ck view uchar 16 now ulong to bool 64 seed = new uchar 32 17 65 rg = new uchar 133 0 66 rn = ohw_encode_register seed now uchar 5 uchar 1 ck rg 67 ok = oh_write_all 1 trm_rg_lbl 68 trm_write_hex rg 69 ok = oh_write_all 1 trm_nl 70 ret eq rn 133 71 end 72 73 fn trm_wire_check to int 74 secret = new uchar 32 9 75 now = ulong `1000000` 76 ck = new uchar 16 0 77 ohw_relay_cookie secret trm_addr div now OHW_COOKIE_WINDOW ck 78 ch = new uchar 19 0 79 cn = ohw_encode_challenge ck ch 80 ak = new uchar 8 0 81 an = ohw_encode_ack uchar 3 120 ak 82 ok = oh_write_all 1 trm_ck_lbl 83 trm_write_hex ck 84 ok = oh_write_all 1 trm_nl 85 ok = oh_write_all 1 trm_ch_lbl 86 trm_write_hex ch 87 ok = oh_write_all 1 trm_nl 88 ok = oh_write_all 1 trm_ak_lbl 89 trm_write_hex ak 90 ok = oh_write_all 1 trm_nl 91 if not trm_wire_check_reg ck now 92 ret 1 93 end 94 if and eq cn 19 eq an 8 95 ret 0 96 end 97 ret 1 98 end 99 100 fn trm_selfcheck to int 101 ohtx_reset_replay 102 nseed = new uchar 32 31 103 rseed = new uchar 32 32 104 rpk = new uchar 32 0 105 ohtx_ed_pubkey rseed rpk 106 now = ulong `1700000000` 107 consent = new uchar 160 0 108 ohtx_sign_consent nseed rpk 2 add now 3600 0 consent 109 seg = new uchar 80 0 110 ohtx_aitr_write_hdr seg 111 rc = ohtx_aitr_write_rec seg 16 or ulong 1 shl ulong 0 16 trm_pay0 112 if ne rc OHTX_OK 113 ret 1 114 end 115 bid = new uchar 16 55 116 ohtx_set_bundle_id bid 117 bundle = new uchar 4408 0 118 rc = oh_trace_export nseed consent seg now bundle 119 if ne rc OHTX_OK 120 ok = oh_write_all 1 trm_fail 121 oh_write_u64 1 rc 122 ok = oh_write_all 1 trm_nl 123 ret 1 124 end 125 blen = ohtx_export_len 126 out_seg = new uchar 256 0 127 rc = oh_trace_receive part bundle 0 blen rpk now out_seg 128 if ne rc OHTX_OK 129 ok = oh_write_all 1 trm_fail 130 oh_write_u64 1 rc 131 ok = oh_write_all 1 trm_nl 132 ret 1 133 end 134 ok = oh_write_all 1 trm_ok 135 oh_write_u64 1 blen 136 ok = oh_write_all 1 trm_seg 137 oh_write_u64 1 ohtx_recv_len 138 ok = oh_write_all 1 trm_nl 139 ret 0 140 end 141 142 fn main to int 143 ac = argcnt 144 if lt ac 2 145 ok = oh_write_all 2 trm_usage 146 ret 2 147 end 148 if trm_arg_eq 1 trm_cmd_ver 149 ok = oh_write_all 1 trm_ver 150 ret 0 151 end 152 if trm_arg_eq 1 trm_cmd_sc 153 ret trm_selfcheck 154 end 155 if trm_arg_eq 1 trm_cmd_wc 156 ret trm_wire_check 157 end 158 ok = oh_write_all 2 trm_usage 159 ret 2 160 end