Skip to content

REFACTOR: Add RepeatingKeyCipherConverter base; add Beaufort/Gronsfeld/Porta - #4457

Draft
Roman Lutz (romanlutz) wants to merge 2 commits into
microsoft:mainfrom
romanlutz:gap1-repeating-key
Draft

Roman Lutz (romanlutz) wants to merge 2 commits into
microsoft:mainfrom
romanlutz:gap1-repeating-key

Conversation

@romanlutz

@romanlutz Roman Lutz (romanlutz) commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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):

…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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

No deployments
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