Skip to content

FEAT: Add baconian Encoding technique via LeetspeakConverter - #4445

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

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

Conversation

@romanlutz

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

Copy link
Copy Markdown
Contributor

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

Copilot AI balanced review requested due to automatic review settings November 19, 2026 23:35

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 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 thread pyrit/converter/baconian_converter.py Outdated
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 thread pyrit/converter/baconian_converter.py Outdated
Comment on lines +152 to +154
for char in text.upper():
if char in self._mapping:
tokens.append(self._mapping[char])
@romanlutz

Copy link
Copy Markdown
Contributor Author

Reworked per the reuse-before-adding guidance: dropped BaconianConverter; the baconian technique is now LeetspeakConverter(custom_substitutions=_BACONIAN_SUBSTITUTIONS) (the Baconian a/b table retained as that constant) + a focused test.

@romanlutz Roman Lutz (romanlutz) changed the title FEAT: Add BaconianConverter (baconian converter) FEAT: Add baconian Encoding technique via LeetspeakConverter Nov 20, 2026
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>

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