Repository navigation
FEAT: Add baconian Encoding technique via LeetspeakConverter - #4445
Open
Roman Lutz (romanlutz) wants to merge 2 commits into
Open
Roman Lutz (romanlutz) wants to merge 2 commits into
Roman Lutz (romanlutz) wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The converter permits ambiguous encodings with colliding custom symbols and alters unsupported characters instead of preserving them, compromising reversibility and multilingual payload integrity.
2 open issues
What changed in this PR
Adds Baconian cipher encoding to PyRIT’s converter library and makes it available in the Garak Encoding scenario.
Changes:
- Supports classic 24-letter and distinct 26-letter variants with configurable symbols.
- Exports the converter and registers it under
ALL, without changing the default technique set. - Adds converter tests, updates scenario expectations, and adds a Python documentation example.
| File | Description |
|---|---|
tests/unit/scenario/garak/test_encoding.py |
Updates technique counts and verifies Baconian remains outside the default set. |
tests/unit/converter/test_baconian_converter.py |
Tests cipher variants, custom symbols, input handling, and identifier creation. |
pyrit/scenario/scenarios/garak/encoding.py |
Registers the Baconian technique and converter. |
pyrit/converter/baconian_converter.py |
Implements Baconian encoding and configurable alphabets. |
pyrit/converter/__init__.py |
Adds the public lazy export and typing import. |
doc/code/converters/1_text_to_text_converters.py |
Adds a Baconian conversion example. |
Review effort: Balanced
Comment on lines
+80
to
+90
| ValueError: If ``symbol_a`` or ``symbol_b`` is empty, or if they are equal. | ||
| """ | ||
| if not symbol_a or not symbol_b: | ||
| raise ValueError("symbol_a and symbol_b must both be non-empty.") | ||
| if symbol_a == symbol_b: | ||
| raise ValueError("symbol_a and symbol_b must be different.") | ||
|
|
||
| self.distinct_letters = distinct_letters | ||
| self.symbol_a = symbol_a | ||
| self.symbol_b = symbol_b | ||
| self._mapping = self._build_mapping() |
Comment on lines
+152
to
+154
| for char in text.upper(): | ||
| if char in self._mapping: | ||
| tokens.append(self._mapping[char]) |
This was referenced Nov 20, 2026
Contributor
Author
|
Reworked per the reuse-before-adding guidance: dropped |
Roman Lutz (romanlutz)
force-pushed
the
gap1-baconian
branch
from
November 20, 2026 06:11
005fd13 to
9730d57
Compare
Per review (reuse and compose before adding): keep the baconian technique but implement it as LeetspeakConverter(custom_substitutions=<Baconian a/b table>) instead of a dedicated BaconianConverter class. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Roman Lutz (romanlutz)
force-pushed
the
gap1-baconian
branch
from
November 20, 2026 06:33
9730d57 to
b3423f5
Compare
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.

Adds the baconian Encoding technique via an existing converter (reuse before adding):
LeetspeakConverter(custom_substitutions=_BACONIAN_SUBSTITUTIONS), with the Baconian a/b table retained as that constant. Keeps the named technique and a focused test.Baconian — each letter maps to a 5-symbol a/b group. Source: Francis Bacon, 1605 (Wikipedia). Jailbreak framing: CipherChat, Yuan et al., arXiv:2308.06463.
gap-1 converter series: #4441 #4442 #4443 #4444 #4445 #4446 #4447 #4448 #4449 #4450 #4451 #4452 #4454 #4455 #4456 #4457 #4458
🤖 Generated with Claude Code