Skip to content

fix(core): G1 round 1 fixes for tablepro-keys vectors and hardening - #4568

Merged
datlechin merged 6 commits into
mainfrom
fix/core-keys-g1
Nov 26, 2026
Merged

datlechin merged 6 commits into
mainfrom
fix/core-keys-g1

Conversation

@datlechin

@datlechin datlechin commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Ed25519: forgeries the library takes under each of the eight small-order points and the two x = 0 sign-bit encodings, which verify refuses. A unit test fails if the small-order check goes.
  • Wycheproof Ed25519 acceptable cases are checked: tcIds 152-159 expect keys.signature, 160-180 verify.
  • flows.json exports every fixture device's DEK and DSK, and P from C.
  • The flows checker parses every key object in a scenario's steps and given and checks each signature its verify names. It opens every wrap, ring, recovery blob and envelope through the recipient's own path, and checks request commitments and reveals against real SAS values.
  • A record whose verify has error must fail with exactly that code.
  • sas_words_differ compares other_words, history_entry compares the opened entry, and the ring walk verifies each version record and gives every ring's frame.
  • Each case and scenario step that answers a row of 0056's negative table names its clause and its server code. The coverage test fails on a missing clause.
  • New negative variants:
    • row 473: a genesis, a rotation, an approval, a reset activation and a team rotation, each from the state it needs and with one object signed under a wrong key. The approval's account wrap is keys.not_compared (0059).
    • rows 517 and 520: real trust wraps at 1,043,426 and 1,048,888 bytes in the new limits.json, the second too_large;
    • row 466: the cancel after words_differ;
    • row 458: the history case;
    • row 439: truncated blob ct and nonce;
    • row 443: the retired IK's certificate on an older version record;
    • row 467: a trust wrap under another DSK.
  • json.rs:
    • the duplicate-name check keeps hashes, not copies, of member names;
    • a name is wiped if its value fails;
    • push_string writes \u00XX without format!.
  • TrustPlaintext::encode writes into a buffer sized by a counting pass, and seal_trust keeps it in Zeroizing. parse holds its tree in Zeroizing.
  • JsonValue::encoded_len and string_len use that counting pass.
  • EnvelopeId::parse checks the id's length first. new checks the parent id and a plugin or AI key name before copying either.
  • check_record_id stops counting past 255 UTF-16 units.
  • Ring::seal_with_nonce, RecoveryKey::seal_blob_with_nonce, seal_envelope_plaintext and seal_history_plaintext are pub(crate). The rest of the public surface is unchanged.
  • Generated trust plaintexts are built from every declared member. trust.json and limits.json state the account-id step.
  • encoding.json says how the 65,535 and 65,536 byte LP cases expand.
  • KeysError's comment cites 0059's amended Errors table.
  • Security pass lows:
    • L1: vectors and unit tests where a replace endorsement or an approval wrap carries S + L or a non-canonical R, which must answer keys.signature. Dropping either form check fails them.
    • L2: the identity-R cases carry S = k·a mod L, so only the R check refuses them. library_takes_it is now aws_lc_rs_takes_it, given only for the canonical points of small order, since AWS-LC's Windows build also takes the x = 0 sign-bit encodings.
    • L3: a unit test seals through Wrap::seal_trust and opens the result.
    • L4: trust encoding writes no unwiped temporaries, and TrustPlaintext::encode() returns Zeroizing<String>. JsonValue's zeroize wipes booleans. The trust types' Debug prints no account, IK or digest.
    • L5: Comparison::new_device and Comparison::approver draw r_N and r_A themselves, and Comparison::nonce() gives r_A. The explicit forms and dpop::proof_with_jti are pub(crate).
    • L6: key object, envelope and history fields past 1 MiB are refused before parsing. limits.json gains read.
    • L7: 10 scenario steps carry checks the checker runs through the crate: 7 keys.stale, 2 keys.conflict, 1 keys.session. The checker's base64 length and sas_words_differ codes come from decode_exact and Comparison::words_differ. keys.not_holder, keys.retired_ik, keys.restart_held, the own-device-pin keys.not_compared and the replace-during-session keys.session are the flows' to decide, with no crate function.
    • L8: fit_record walks the pins once.
  • ADR 0064:
    • KeysError::RestartHeld, keys.restart_held.
    • X, an account the server made up, joins the flows world.
    • Two restart scenarios answer 0064's three vectors. The coverage test reads them from 0064.
  • Windows: the forgery unit test and the vectors no longer assert AWS-LC's platform-dependent answer for the sign-bit encodings, which failed the Windows key tests.
  • A kind 1 key.account body with no replace_sig is a malformed body under 0051's body rule: keys.encoding, server bad_statement. Its case now sits under the encoding row. Row 442 keeps the well-formed wrong-endorser case, keys.unendorsed. 0059's "or that has none" gets its wording fix in the next amendment.

Test plan

  • cargo test -p tablepro-keys: 76 pass, including every_negative_row_of_adr_0056_has_a_case, the_vectors_are_what_the_generator_writes and every_committed_case_holds. The vectors were generated twice, byte for byte the same.
  • Mutation checks:
    • with small_order removed from verify, the forgery test fails;
    • with the signature form checks removed from ik_change and open_checked, two unit tests and every_committed_case_holds fail.
  • cargo clippy -p tablepro-keys --all-targets -D warnings and cargo fmt --check are clean.
  • verify.sh --platform linux --jobs 4 test tablepro-keys on df000be: PASS, 76 of 76.
  • Codex review, round 1: 2 medium and 3 low, fixed in 52c1722. Round 2: none.
  • Security pass, Claude (fresh agent): no high or medium; the 8 lows, fixed in df000be.
  • Vectors: 161 known answers, 155 negative, 9 row-taken and 68 scenarios with 96 steps. On main: 162, 139, 5 and 61 with 83 steps.

@datlechin
datlechin enabled auto-merge (squash) November 26, 2026 01:59
@datlechin
datlechin merged commit 3968cbd into main Nov 26, 2026
34 of 35 checks passed
datlechin added a commit that referenced this pull request Nov 26, 2026
datlechin added a commit that referenced this pull request Nov 26, 2026
…l the reveal, and a restart before it ends the session

K5 draws r_N and r_A inside Comparison, so the row keeps a step's values only once the step is taken. A session read back without its comparison before the reveal ends with this side's cancel, and N asks again. The approval vectors read the keys crate's flows.json now that #4568 is merged.
@datlechin
datlechin deleted the fix/core-keys-g1 branch November 27, 2026 16:37
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.

1 participant