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/omega-mv/blob/main/src/fabric/fab_core.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / fabric / fab_core.om` 94 lines ยท 2057 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Pure seeded OM-2 core logic backing src/fabric/ (fab_hmac.c, fabric.c, 3 note fab_dispatch.c): constant-time equality, HMAC XOR pads, canonical LE 4 note 16/32/64 codecs, message body sizing, and non-zero digest matching. 5 om2 6 7 export fn fab_om_ct_equal a view uchar * b view uchar * n ulong to ulong 8 acc = ulong 0 9 for i ulong n bound `9223372036854775807` 10 acc = or acc xor ulong get a i ulong get b i 11 end 12 if eq acc 0 13 ret 1 14 end 15 ret 0 16 end 17 18 export fn fab_om_hmac_xor_pad k view uchar 64 pad edit uchar 64 xbyte ulong to void 19 for i ulong 64 20 put pad i uchar xor ulong get k i xbyte 21 end 22 end 23 24 export fn fab_om_put_u16 dst edit uchar * pos ulong v ulong to void 25 put dst pos uchar and v 255 26 put dst add pos 1 uchar and shr v 8 255 27 end 28 29 export fn fab_om_put_u32 dst edit uchar * pos ulong v ulong to void 30 for i ulong 4 31 put dst add pos i uchar and shr v mul i 8 255 32 end 33 end 34 35 export fn fab_om_put_u64 dst edit uchar * pos ulong v ulong to void 36 for i ulong 8 37 put dst add pos i uchar and shr v mul i 8 255 38 end 39 end 40 41 export fn fab_om_get_u16 src view uchar * pos ulong to ulong 42 b0 = ulong get src pos 43 b1 = ulong get src add pos 1 44 ret or b0 shl b1 8 45 end 46 47 export fn fab_om_get_u32 src view uchar * pos ulong to ulong 48 v = ulong 0 49 for i ulong 4 50 b = ulong get src add pos i 51 v = or v shl b mul i 8 52 end 53 ret v 54 end 55 56 export fn fab_om_get_u64 src view uchar * pos ulong to ulong 57 v = ulong 0 58 for i ulong 8 59 b = ulong get src add pos i 60 v = or v shl b mul i 8 61 end 62 ret v 63 end 64 65 export fn fab_om_body_size kind ulong to ulong 66 if eq kind 1 67 ret 40 68 end 69 if eq kind 2 70 ret 8 71 end 72 if eq kind 3 73 ret 188 74 end 75 if eq kind 4 76 ret 0 77 end 78 ret 0xffffffffffffffff 79 end 80 81 export fn fab_om_digest_nonzero_eq a view uchar 32 b view uchar 32 to ulong 82 any = ulong 0 83 diff = ulong 0 84 for i ulong 32 85 ai = ulong get a i 86 bi = ulong get b i 87 any = or any bi 88 diff = or diff xor ai bi 89 end 90 if and ne any 0 eq diff 0 91 ret 1 92 end 93 ret 0 94 end