Skip to content

Make signature.py and skill.py pass ub's own gate - #12

Merged
0xjgv merged 2 commits into
mainfrom
ub-cli-self-gate
Nov 17, 2026
Merged

0xjgv merged 2 commits into
mainfrom
ub-cli-self-gate

Conversation

@0xjgv

@0xjgv 0xjgv commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Makes src/ub_cli/signature.py and src/ub_cli/skill.py pass ub's own gate (round-3 dogfood findings).

Changes

  • signature.verify (CC 12): split key parsing into _public_key and signature parsing into _signature_parts. Checks run in the same order with the same errors.
  • skill.install (CC 14): split the check pass into _pending and the atomic write into _publish. No behavior change.
  • tests/test_update.py: new tests kill every surviving or uncovered signature mutant:
    • point_equal on scaled projective points, and on points with only x or only y negated (kills the * -> / and and -> or mutants on line 37).
    • recover_x(1, 0) == 0, recover_x(1, 1) is None, an off-curve y = -2, and non-canonical y = p. These kill the >= -> > mutant at line 41, the 0 -> 1 mutants at lines 44 and 45, and * -> / at line 49. Line 49 needs a large y: with a small y the float mutant gives the same answer.
    • ed25519_verify with a 65-byte signature (line 71 or -> and, line 72 uncovered). Also s = q against the identity key and R, where s = 0 does verify, so only the range check rejects it (line 75 >= -> >).
    • verify tamper cases now assert the error message. New cases cover base64 with an inserted ! in the key, blob and global signature (lines 83/89/90 validate=True -> False), a wrong key prefix (line 84 or -> and), a too-long blob and global signature (line 91 or -> and), a wrong key id, and an unsupported algorithm.

Signature behavior is unchanged

Before and after the refactor, a scratch script ran verify on 1012 cases. It crosses 4 messages (current and legacy, each also tampered), 11 key variants and 23 signature variants: CRLF, line count, comment, base64, lengths, algorithm, key id, and bit flips in each signature. The script recorded the return value, or the exception type and message, for each case. The before and after outputs are byte-identical (cmp clean): 8 accepted and 1004 rejected, with the same messages.

Verification (Python 3.11, this branch)

$ make test
Ran 77 tests in 14.054s
OK

$ COV ...; ub crap --use-existing-coverage src/ub_cli/signature.py src/ub_cli/skill.py
CRAP: 0 of 14 functions >= 10

$ ub mutate src/ub_cli/signature.py src/ub_cli/skill.py --use-existing-coverage --mutate-all --test-command "$TEST"
Mutation: 132 killed, 0 survived, 0 uncovered in 14 functions, score 100.0%.

Baseline on main: CRAP: 2 of 10 functions >= 10, Mutation: 115 killed, 15 survived, 2 uncovered.

No equivalent mutants remain to justify.

Not run: a full ub check -s src; only these two files were measured.

…ving signature mutants

verify now parses the key and the signature in helpers; install plans and
publishes files in helpers. Accept/reject results are unchanged: a 1012-case
corpus of valid and tampered inputs gives identical outcomes before and after.

New tests pin point_equal on projective points, non-canonical and off-curve
encodings, wrong lengths, s = q, and each verify error by message.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T16:52:56.927858Z e687928 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@0xjgv
0xjgv merged commit aa2c305 into main Nov 17, 2026
1 check passed
@0xjgv
0xjgv deleted the ub-cli-self-gate branch November 17, 2026 19:06
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