Skip to content

spec(port): port the ratchet tree extension tampering guard (Refs #8887) - #9868

Merged
1 commit merged into
Trinity-S-AI-DNA:masterfrom
dmitrii-f-t27:port/cr-chat-07-ae
Oct 17, 2026
Merged

1 commit merged into
Trinity-S-AI-DNA:masterfrom
dmitrii-f-t27:port/cr-chat-07-ae

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Contributor

The thirtieth CR-CHAT-07 ring target (W2, R-CHAT-12, tracker #8887): port of crates/trios-chat/rings/CR-CHAT-07/src/ratchet_tree_extension_tampering.rs.

RFC 9420 12.4.3.3 lets a Welcome message carry a ratchet_tree extension so the joiner rebuilds the tree without a directory fetch. Five tamperings must reject before any key is derived, in the original's order:

  1. present-but-empty extension (a malformed downgrade),
  2. leaf-count pre-pass: the minimum-leaf floor, then counted leaves vs the welcomer's expected_leaf_count,
  3. per node: index range over node_count = 2*leaves-1, duplicate-index probe, leaf signature probe; blanks hold no index claim and skip.

Carried as the D5 verdict — all five original error variants carry no payload, so the code is the whole verdict (burst precedent).

Adaptations (t27 conventions): enum-with-payload tree nodes → kind enum + one record form; Vec<u8> signature blob → fixed [64]u8 + sig_len; welcomer's view struct → expected_leaf_count parameter; BTreeSet of seen indices → visited-scan helper that skips blanks; the saturating node count saturates only past two billion leaves — the saturated edge is spelled explicitly; the crate-Result convenience adapter stays with the crate.

All 10 original RTX tests transcribed with exact asserts, plus helper tests (count_leaves, index_seen_before — the blank deliberately carries an unread index to prove blanks hold no claim) and a rule-order test (13 total): the empty extension answers even under a zero leaf claim; the leaf-count pre-pass answers before any index arithmetic (an over-range index never reaches its rule while the count is wrong); the index range answers before the duplicate and signature probes on the same leaf; the duplicate probe answers before the signature probe.

Checks (conventions 0-14): t27b test 13 passed 0 failed, 0 blockers; t27c test-report 13/13, 0 vacuous; gen-rust output compiles under rustc (0 'static str, 0 Vec<const); coverage Untested 0; ASCII only; seal saved, all hashes MATCH; ledger row added to docs/reports/t27b_expectations.json.

Refs #8887

…nity-S-AI-DNA#8887)

The thirtieth CR-CHAT-07 ring target (W2, R-CHAT-12, RFC 9420
12.4.3.3): the Welcome ratchet_tree extension rules - the
present-but-empty extension probe (a downgrade), the leaf-count
pre-pass (the minimum-leaf floor, then the counted leaves
against the welcomer's claim), then per node the index range
over the derived node count, the duplicate-index probe and the
leaf signature probe; blanks hold no index claim and skip -
as the D5 verdict (all five original variants carry no
payload, so the code is the whole verdict), the original's
rule order, and all ten RTX tests transcribed plus helper and
rule-order tests.

The original's enum-with-payload tree nodes become a kind enum
plus one record form; the Vec<u8> signature blob becomes the
fixed [64]u8 capacity plus its length; the welcomer's view
struct becomes the expected-leaf-count parameter; the BTreeSet
of seen indices becomes a scan over the visited nodes that
skips blanks. The original's saturating node count saturates
only past two billion leaves - the port spells the saturated
edge explicitly. The crate-Result convenience adapter stays
with the crate; the core validator is what ports.

Checks (conventions 0-14): t27b test 13 passed 0 failed; t27c
test-report 13/13, 0 vacuous; gen-rust output compiles under rustc;
coverage Untested 0; ASCII only; seal saved, all hashes MATCH;
@dmitrii-f-t27

Copy link
Copy Markdown
Contributor Author

All required checks green (validate, check-linked-issue, parse-ratchet, t27b-native-linux, t27b-native-macos); cli-tri / duplicate-bodies / t27b-native-ratchet are the known non-required reds. Steward READY. Requesting owner merge when convenient — 30 of ~34 CR-CHAT-07 targets delivered, Refs #8887.

This was referenced Oct 17, 2026
@gHashTag
gHashTag enabled auto-merge (squash) October 17, 2026 18:13
@gHashTag
gHashTag disabled auto-merge October 17, 2026 18:42
@gHashTag gHashTag closed this pull request by merging all changes into Trinity-S-AI-DNA:master in 12f5af8 Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants