omnet
aien-dev/omnet
Brought by drakestapleton
omnet / om / tkasig / README.md
| 1 | # Node-key signatures (`tkasig`) |
| 2 | |
| 3 | Production implementation is Omega only. Semantics follow Tailscale |
| 4 | [v1.102.0 `tka/sig.go`](https://github.com/tailscale/tailscale/blob/v1.102.0/tka/sig.go) |
| 5 | and `Authority.NodeKeyAuthorizedWithDetails` in `tka/tka.go`, fetched 2026-10-25. |
| 6 | The independent trusted-key interface has no dependency on the authority-model unit. |
| 7 | |
| 8 | ## API |
| 9 | |
| 10 | Concatenate `blake2s.om`, `sha512.om`, `ed25519.om`, `cbor.om`, then `tkasig.om`. |
| 11 | All functions carry the `nks` prefix. The library contains no globals or main. |
| 12 | |
| 13 | Allocate input `d uchar 65536`, CBOR token table `t ulong 131074`, model |
| 14 | `m ulong 132`, output `o uchar 65536`, digest `h uchar 32`, raw node key |
| 15 | `node uchar 32`, and trusted keys `keys uchar 16384`. |
| 16 | |
| 17 | * `nksdec d n t m -> ulong`: 0 means successful typed decoding; 1 means |
| 18 | rejection, including `n > 65536`. Decoding clears the model. On failure, no |
| 19 | other API may use that model. Input, token table and model must remain paired. |
| 20 | * `nksser d t m o r omit -> ulong`: canonical serialization of row `r`, normally |
| 21 | 0. `omit=1` excludes **only that row's** Signature, retaining signatures in |
| 22 | Nested. `omit=0` includes it. Returns byte count, or 65537 for invalid row or |
| 23 | output capacity exhaustion. Output may be partially written on failure. |
| 24 | * `nkshash d t m r h -> ulong`: BLAKE2s-256 of typed canonical serialization |
| 25 | with that row's signature omitted; returns 1, or 0 on output overflow. |
| 26 | * `nksauth d t m node keys count -> ulong`: 1 authorizes this raw 32-byte node |
| 27 | key, 0 rejects. `count` is 0..512, otherwise rejected. Table entry `k` is the |
| 28 | 32-byte Ed25519 public key at `keys[32*k..32*k+32)`, also its TKA KeyID. |
| 29 | The caller must export only currently trusted, valid `Key25519` authority |
| 30 | keys; no key kinds, votes, or metadata are encoded in this table. Empty |
| 31 | authority and removed keys reject. These trusted bytes are never derived |
| 32 | from the received signature. Duplicate entries are harmless. |
| 33 | |
| 34 | Tables are caller-owned workspace, not a public mutable object format. Each |
| 35 | 8-word model row holds kind, Pubkey token, KeyID token, Signature token, Nested |
| 36 | presence, WrappingPubkey token, and two reserved words. `m[128]` is row count; |
| 37 | 129..131 are serialization scratch. Up to sixteen rows are supported, matching |
| 38 | the upstream CBOR nesting limit. Only the helpers above are consumer APIs. |
| 39 | Input/output buffers must not alias. Invalid attacker bytes return rejection, |
| 40 | not a trap; forged tables and mismatched buffers violate the caller contract. |
| 41 | Canonical data can grow slightly when an absent mandatory kind is reconstructed; |
| 42 | output over 65536 is explicitly rejected rather than truncated. |
| 43 | |
| 44 | ## Semantics |
| 45 | |
| 46 | Typed maps accept unsigned integer or UTF-8 text field names (`1` or `"1"`). |
| 47 | Unknown fields are discarded, and skipped values are only CBOR-wellformedness |
| 48 | checked. Duplicate decoded fields (including integer/text aliases), duplicate |
| 49 | unknown keys, invalid field types, and overflowing uint8 kinds are rejected. |
| 50 | Non-shortest CBOR and unsorted maps are accepted. Byte slices accept byte |
| 51 | strings, arrays of uint8-compatible elements, null and undefined; null/undefined |
| 52 | array elements become zero. As in fxamacker, unsigned integers and CBOR simple |
| 53 | values 0..19 or 32..255 fill SigKind and byte-array elements. Booleans and floats |
| 54 | are not numeric substitutes. Null/undefined structs decode to zero values. |
| 55 | Serialization reconstructs the six typed fields in CTAP2 order, omitting empty |
| 56 | slices and nil Nested. Hashes never use raw received CBOR. |
| 57 | |
| 58 | Direct signatures bind the `np`-prefixed binary node key and use ZIP-215 under |
| 59 | a trusted authority key. Rotations bind the outer node key, use **strict** Go |
| 60 | Ed25519 rules under the nested wrapping key, and verify the nested chain. |
| 61 | Wrapping keys inherit across intermediate rotations only when their own value |
| 62 | is empty. Credential signatures use ZIP-215 and certify an indirection key; |
| 63 | they cannot authorize a node alone. Direct/credential signatures cannot nest. |
| 64 | As in the public upstream authorization API, nonempty nested credential Pubkey |
| 65 | must also be a valid binary node key (the rotation-details check). |
| 66 | |
| 67 | ## Tests |
| 68 | |
| 69 | ```sh |
| 70 | OMC=$(tools/omc.sh) |
| 71 | sh om/tkasig/test/run.sh "$OMC" |
| 72 | # Regenerate the committed deterministic corpus with Go >=1.26.5: |
| 73 | REGEN=1 GO=/path/to/go1.26.8 sh om/tkasig/test/run.sh "$OMC" |
| 74 | ``` |
| 75 | |
| 76 | Tests use Python 3 for framing and comparison, and Go only for regeneration. |
| 77 | `test/go.mod` and `go.sum` pin `tailscale.com` v1.102.0. The oracle calls real |
| 78 | `Unserialize`, `Serialize`, `SigHash`, and `Authority.NodeKeyAuthorized`. |
| 79 | Deterministic private keys are public test fixtures, not deployment secrets. |
| 80 | The corpus covers direct/credential/rotations, inherited wrapping keys, depth |
| 81 | bounds, ZIP-215 versus strict witnesses, validly signed wrong bindings, revoked |
| 82 | or untrusted identity, per-byte mutations, truncations, typed adversarial CBOR, |
| 83 | and large fields. Each driver must exit normally and return exactly one complete |
| 84 | framed result per input. A source mutant counts only on a completed result |
| 85 | mismatch; traps and incomplete output are harness failures. A dedicated trap |
| 86 | probe proves this distinction. No runtime Go is used by the library. |
| 87 | |
| 88 | Qualification on 2026-10-25: the focused suite with `REGEN=1` and Go 1.26.8 |
| 89 | returned 0 with `PASS tkasig differential 1135 cases`, nine completed-result |
| 90 | source mutant detections, and rejection of the trapping probe. This includes |
| 91 | all 256 simple-value numbers in both SigKind and byte-array positions, plus |
| 92 | validly signed re-encodings whose kinds or byte fields use simple values. |
| 93 | The corpus uses the pinned module. Startup boundary checks additionally exercised oversized input length, |
| 94 | out-of-range serialization row, oversized/empty trusted-key tables, and |
| 95 | canonical-output overflow (including the sighash rejection path). These are |
| 96 | host-only results, not deployment or constant-time qualification. |
| 97 | |
| 98 | ### Third-party material and notices |
| 99 | |
| 100 | Verification and typed-model semantics are adapted from Tailscale v1.102.0, |
| 101 | Copyright (c) Tailscale Inc & contributors, BSD-3-Clause. The complete upstream |
| 102 | license is included as `test/tailscale.LICENSE`. The Go oracle imports the pinned |
| 103 | upstream module and does not substitute a synthetic verifier. |