interplane.Get Omega
Read in your language

omnet

aien-dev/omnet

Brought by drakestapleton

branch main Branches Tags History

omnet / om / tkasig / README.md

103 lines · 6189 bytes Raw Blame History Rendered
1# Node-key signatures (`tkasig`)
2
3Production 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)
5and `Authority.NodeKeyAuthorizedWithDetails` in `tka/tka.go`, fetched 2026-10-25.
6The independent trusted-key interface has no dependency on the authority-model unit.
7
8## API
9
10Concatenate `blake2s.om`, `sha512.om`, `ed25519.om`, `cbor.om`, then `tkasig.om`.
11All functions carry the `nks` prefix. The library contains no globals or main.
12
13Allocate 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
34Tables are caller-owned workspace, not a public mutable object format. Each
358-word model row holds kind, Pubkey token, KeyID token, Signature token, Nested
36presence, WrappingPubkey token, and two reserved words. `m[128]` is row count;
37129..131 are serialization scratch. Up to sixteen rows are supported, matching
38the upstream CBOR nesting limit. Only the helpers above are consumer APIs.
39Input/output buffers must not alias. Invalid attacker bytes return rejection,
40not a trap; forged tables and mismatched buffers violate the caller contract.
41Canonical data can grow slightly when an absent mandatory kind is reconstructed;
42output over 65536 is explicitly rejected rather than truncated.
43
44## Semantics
45
46Typed maps accept unsigned integer or UTF-8 text field names (`1` or `"1"`).
47Unknown fields are discarded, and skipped values are only CBOR-wellformedness
48checked. Duplicate decoded fields (including integer/text aliases), duplicate
49unknown keys, invalid field types, and overflowing uint8 kinds are rejected.
50Non-shortest CBOR and unsorted maps are accepted. Byte slices accept byte
51strings, arrays of uint8-compatible elements, null and undefined; null/undefined
52array elements become zero. As in fxamacker, unsigned integers and CBOR simple
53values 0..19 or 32..255 fill SigKind and byte-array elements. Booleans and floats
54are not numeric substitutes. Null/undefined structs decode to zero values.
55Serialization reconstructs the six typed fields in CTAP2 order, omitting empty
56slices and nil Nested. Hashes never use raw received CBOR.
57
58Direct signatures bind the `np`-prefixed binary node key and use ZIP-215 under
59a trusted authority key. Rotations bind the outer node key, use **strict** Go
60Ed25519 rules under the nested wrapping key, and verify the nested chain.
61Wrapping keys inherit across intermediate rotations only when their own value
62is empty. Credential signatures use ZIP-215 and certify an indirection key;
63they cannot authorize a node alone. Direct/credential signatures cannot nest.
64As in the public upstream authorization API, nonempty nested credential Pubkey
65must also be a valid binary node key (the rotation-details check).
66
67## Tests
68
69```sh
70OMC=$(tools/omc.sh)
71sh om/tkasig/test/run.sh "$OMC"
72# Regenerate the committed deterministic corpus with Go >=1.26.5:
73REGEN=1 GO=/path/to/go1.26.8 sh om/tkasig/test/run.sh "$OMC"
74```
75
76Tests 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`.
79Deterministic private keys are public test fixtures, not deployment secrets.
80The corpus covers direct/credential/rotations, inherited wrapping keys, depth
81bounds, ZIP-215 versus strict witnesses, validly signed wrong bindings, revoked
82or untrusted identity, per-byte mutations, truncations, typed adversarial CBOR,
83and large fields. Each driver must exit normally and return exactly one complete
84framed result per input. A source mutant counts only on a completed result
85mismatch; traps and incomplete output are harness failures. A dedicated trap
86probe proves this distinction. No runtime Go is used by the library.
87
88Qualification on 2026-10-25: the focused suite with `REGEN=1` and Go 1.26.8
89returned 0 with `PASS tkasig differential 1135 cases`, nine completed-result
90source mutant detections, and rejection of the trapping probe. This includes
91all 256 simple-value numbers in both SigKind and byte-array positions, plus
92validly signed re-encodings whose kinds or byte fields use simple values.
93The corpus uses the pinned module. Startup boundary checks additionally exercised oversized input length,
94out-of-range serialization row, oversized/empty trusted-key tables, and
95canonical-output overflow (including the sighash rejection path). These are
96host-only results, not deployment or constant-time qualification.
97
98### Third-party material and notices
99
100Verification and typed-model semantics are adapted from Tailscale v1.102.0,
101Copyright (c) Tailscale Inc & contributors, BSD-3-Clause. The complete upstream
102license is included as `test/tailscale.LICENSE`. The Go oracle imports the pinned
103upstream module and does not substitute a synthetic verifier.