Repository navigation
REFACTOR: Add RepeatingKeyCipherConverter base; add Beaufort/Gronsfeld/Porta - #4457
Draft
Roman Lutz (romanlutz) wants to merge 2 commits into
Draft
Roman Lutz (romanlutz) wants to merge 2 commits into
Roman Lutz (romanlutz) wants to merge 2 commits into
Conversation
…d/Porta Introduces a shared RepeatingKeyCipherConverter base owning the repeating key-stream loop, migrates the existing Vigenere onto it, and adds Beaufort, Gronsfeld and Porta (registered as ALL-only garak Encoding techniques). 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
The decoding prompts omit required cipher keys, forcing the target to guess and risking failures that reflect missing information rather than resistance to decoding harmful content.
1 open issue
What changed in this PR
This PR adds Beaufort, Gronsfeld, and Porta text converters to PyRIT, sharing repeating-key cipher logic with the existing Vigenere converter.
Changes:
- Extracts shared repeating-key transformation and optional cipher-description helpers.
- Exports the new converters and adds them as non-default Garak Encoding techniques.
- Adds cipher tests, registry/backend test support, and Python documentation examples.
| File | Description |
|---|---|
tests/unit/scenario/garak/test_encoding.py |
Updates technique counts and non-default membership. |
tests/unit/registry/converter_identifier_samples.py |
Adds numeric Gronsfeld key samples. |
tests/unit/converter/test_porta_converter.py |
Tests Porta vectors, reciprocity, and validation. |
tests/unit/converter/test_gronsfeld_converter.py |
Tests numeric keys, shifts, and validation. |
tests/unit/converter/test_beaufort_converter.py |
Tests Beaufort formulas, reciprocity, and validation. |
tests/unit/backend/test_converter_service.py |
Supplies valid keys for converter construction tests. |
pyrit/scenario/scenarios/garak/encoding.py |
Registers the three new encoding techniques. |
pyrit/converter/vigenere_converter.py |
Refactors Vigenere onto shared helpers. |
pyrit/converter/porta_converter.py |
Implements the reciprocal Porta cipher. |
pyrit/converter/gronsfeld_converter.py |
Implements numeric-key Gronsfeld encoding. |
pyrit/converter/beaufort_converter.py |
Implements the reciprocal Beaufort cipher. |
pyrit/converter/_repeating_key_cipher.py |
Centralizes key iteration and character handling. |
pyrit/converter/_cipher_description.py |
Extracts optional description-template rendering. |
pyrit/converter/__init__.py |
Adds lazy exports for the new converters. |
doc/code/converters/1_text_to_text_converters.py |
Adds usage examples for all three ciphers. |
Review effort: Balanced
Comment on lines
+323
to
+325
| ([PortaConverter(key="pyrit")], "porta", "porta"), | ||
| ([GronsfeldConverter()], "gronsfeld", "gronsfeld"), | ||
| ([BeaufortConverter(key="pyrit")], "beaufort", "beaufort"), |
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):