Repository navigation
REFACTOR: Add shared cipher-description helper; add AffineConverter - #4456
Draft
Roman Lutz (romanlutz) wants to merge 3 commits into
Draft
Roman Lutz (romanlutz) wants to merge 3 commits into
Roman Lutz (romanlutz) wants to merge 3 commits into
Conversation
Introduces a shared maybe_render_description helper (+ common worked example) and migrates Caesar, Atbash and Morse onto it; adds the new AffineConverter (registered as an ALL-only garak Encoding technique) on the same helper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Nov 20, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Synchronous YAML loading on every conversion blocks the event loop and delays concurrent conversions, while the paired notebook is missing the Affine import and example.
2 open issues
What changed in this PR
Adds an Affine cipher converter to PyRIT and shares optional cipher-description rendering across several existing converters.
Changes:
- Introduces configurable Affine encoding, a description template, and a lazy public export.
- Refactors Atbash, Caesar, and Morse to use a shared description helper.
- Adds Affine to Garak’s encoding techniques, unit tests, identifier samples, and the Python documentation example.
| File | Description |
|---|---|
tests/unit/scenario/garak/test_encoding.py |
Updates technique counts and ALL-only membership. |
tests/unit/registry/converter_identifier_samples.py |
Adds valid Affine multiplier samples. |
tests/unit/converter/test_affine_converter.py |
Tests encoding, validation, and description behavior. |
pyrit/scenario/scenarios/garak/encoding.py |
Registers the Affine encoding technique. |
pyrit/datasets/converters/affine_description.yaml |
Adds Affine instructions and example framing. |
pyrit/converter/morse_converter.py |
Uses the shared description helper. |
pyrit/converter/caesar_converter.py |
Uses the shared description helper. |
pyrit/converter/atbash_converter.py |
Uses the shared description helper. |
pyrit/converter/affine_converter.py |
Implements configurable Affine encoding. |
pyrit/converter/_cipher_description.py |
Centralizes description loading and rendering. |
pyrit/converter/__init__.py |
Lazily exports AffineConverter. |
doc/code/converters/1_text_to_text_converters.py |
Adds an Affine usage example. |
Review effort: Balanced
| """ | ||
| if not append_description: | ||
| return encoded | ||
| template = SeedPrompt.from_yaml_file(pathlib.Path(CONVERTER_SEED_PROMPT_PATH) / f"{yaml_stem}_description.yaml") |
| print("Morse:", await MorseConverter().convert_async(prompt=prompt)) # type: ignore | ||
| print("NATO:", await NatoConverter().convert_async(prompt=prompt)) # type: ignore | ||
| print("Caesar:", await CaesarConverter(caesar_offset=3).convert_async(prompt=prompt)) # type: ignore | ||
| print("Affine:", await AffineConverter().convert_async(prompt=prompt)) # type: ignore |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Part of the gap-1 converter series (splitting the esoteric cipher / encoder set into per-converter and per-base PRs). This PR introduces a shared base/helper and the converters built on it; CI-validated locally (unit + garak Encoding + identifier-contract tests).
Sibling PRs will be cross-linked once the series is open.
🤖 Generated with Claude Code
gap-1 converter series — splitting the esoteric cipher / encoder set into reviewable PRs (open each independently; they touch the same four registration files, so later ones rebase as earlier ones merge):