Repository navigation
FEAT: Add ColumnarTranspositionConverter (classical transposition cipher) - #4327
Merged
Roman Lutz (romanlutz) merged 7 commits intoNov 19, 2026
Conversation
…her) Implements the standard incomplete-columns columnar transposition cipher as a PyRIT converter: plaintext is written row-wise under a keyword and columns are read out in the alphabetical order of the keyword's letters. Pure permutation over all characters, no padding. Registered as an encoding technique in the garak Encoding scenario. Stdlib only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new technique breaks aggregate test expectations, and its decoding prompts omit the keyword and incomplete-column convention needed for reliable decoding.
2 open issues
What changed in this PR
Adds a configurable columnar transposition cipher to PyRIT’s converter catalog and integrates it into the Garak encoding scenario.
Changes:
- Implements case-insensitive keyword ordering and padding-free transposition that preserves all input characters.
- Adds a lazy public export and an ALL-only encoding technique using
ZEBRAS. - Adds 13 unit tests covering known output, edge cases, identifiers, and validation.
| File | Description |
|---|---|
tests/unit/converter/test_columnar_transposition_converter.py |
Tests cipher behavior and input validation. |
pyrit/scenario/scenarios/garak/encoding.py |
Registers the ALL-only technique and converter variant. |
pyrit/converter/columnar_transposition_converter.py |
Implements the keyword-based transposition converter. |
pyrit/converter/__init__.py |
Exposes the converter through lazy imports. |
Review effort: Balanced
varunj-msft
approved these changes
Nov 16, 2026
varunj-msft
left a comment
Contributor
There was a problem hiding this comment.
Looks like the new converter still needs a mention in the converter notebooks and the 0_converters modality table (test_all_converters_are_documented fails), and the "(17 encodings)" list in doc/scanner/garak.py might want a refresh too.
…rter - test_converter_service: add key override so the auto-instantiation test passes an alphabetic key (mirrors VigenereConverter). - test_encoding: bump ALL-aggregate count to 18 and add columnar_transposition to the ALL-only (non-default) set. - doc notebook: document ColumnarTranspositionConverter in the text-to-text converters notebook so the documentation test passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ansposition-ebba96
… prompts A keyed transposition cannot be reversed from the encoding name alone, so decode prompts that only name the scheme make decoding failures ambiguous. ColumnarTranspositionConverter now exposes a decode_prompt_description built from its key, and the Encoding scenario feeds that description into the decode templates (AskToDecodeConverter) while leaving the raw variant, technique slug, selection, and display grouping unchanged. Addresses PR review feedback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ansposition-ebba96 # Conflicts: # doc/code/converters/1_text_to_text_converters.py # pyrit/scenario/scenarios/garak/encoding.py # tests/unit/scenario/garak/test_encoding.py
…bba96' into claude/g1-columnar-transposition-ebba96
Roman Lutz (romanlutz)
deleted the
claude/g1-columnar-transposition-ebba96
branch
November 19, 2026 22:59
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.


Description
Adds
ColumnarTranspositionConverter— the classical columnar transposition cipher — to PyRIT's converter catalog, filling a gap in the classical-cipher converters (joiningCaesarConverterandVigenereConverter).Plaintext is written row-wise into a grid whose number of columns equals the length of a keyword; the ciphertext is produced by reading the columns out in the alphabetical order of the keyword's letters. This is the standard incomplete-columns variant: the final row may be partially filled, columns can be of unequal length, and no padding characters are added. It is a pure permutation over all characters (spaces, digits, and punctuation included), so it is fully reversible given the keyword and message length.
Worked example (canonical Wikipedia vector): with
key="ZEBRAS",WEAREDISCOVEREDFLEEATONCE→EVLNACDTESEAROFODEECWIREE.Changes
pyrit/converter/columnar_transposition_converter.py— new converter with a configurablekey(validated non-empty, ASCII-alphabetic; ordering case-insensitive, repeated letters broken by original left-to-right position via a stable sort)._build_identifierexposeskey.pyrit/converter/__init__.py— lazy export registration.pyrit/scenario/scenarios/garak/encoding.py— registered as an ALL-only encoding technique (columnar_transposition) with a_converter_variants()row usingkey="ZEBRAS".tests/unit/converter/test_columnar_transposition_converter.py— 13 unit tests, including the known Wikipedia vector, case-insensitivity, repeated-key-letter stability, permutation invariance, space/punctuation preservation, degenerate cases, identifier params, and input/key validation guards.Notes
Tests
pytest tests/unit/converter/test_columnar_transposition_converter.py— 13/13 passing._asyncsuffix, public-import).🤖 Generated with Claude Code