Skip to content

Add base65536 and hexagram encoding injection probes#1843

Open
assinscreedFC wants to merge 1 commit into
NVIDIA:mainfrom
assinscreedFC:probe-encoding-base65536-hexagram
Open

Add base65536 and hexagram encoding injection probes#1843
assinscreedFC wants to merge 1 commit into
NVIDIA:mainfrom
assinscreedFC:probe-encoding-base65536-hexagram

Conversation

@assinscreedFC
Copy link
Copy Markdown

What

Adds two new encoding-injection probes to probes.encoding, addressing two items from the "extra encodings" wishlist in #152:

  • InjectBase65536 — encodes payloads with Base65536 (2 bytes per character).
  • InjectHexagram — encodes payloads as I Ching hexagrams (Base64 with each character mapped to a hexagram so the bits are visible).

Both follow the existing EncodingMixin pattern (primary_detector = encoding.DecodeMatch).

Dependencies

No new runtime dependency is introduced. Both encoders are clean-room ports of the MIT-licensed reference implementations, placed in resources/encodings.py with attribution comments and SPDX-FileCopyrightText lines:

  • base65536_encode/decode — ported from qntm/base65536 (MIT). Validated byte-for-byte against the reference package.
  • hexagram_encode/decode — ported from ferno/hexagram-encode (MIT). Matches the reference README vector (bytes([0x00,0x55,0xFF]) -> ䷁䷣䷄䷀).

Non-duplication

No open PR addresses these encoders (checked base65536, hexagram, and #152 references in open PRs). This PR covers only two wishlist items; #152 stays open for the rest.

Tests

New tests/resources/test_encodings.py adds roundtrip, known-vector, and invalid-input tests for both codecs. The new probes are also covered by the existing parametrized tests/probes/test_probes_encoding.py suite.

pytest tests/resources/test_encodings.py tests/probes/test_probes_encoding.py
  -> 112 passed, 1 skipped
pytest tests/test_docs.py
  -> 663 passed
black --check garak/probes/encoding.py garak/resources/encodings.py tests/resources/test_encodings.py
  -> clean

Codec ports were additionally verified with the base65536 reference package uninstalled, confirming no dependency.

AI assistance

This change was AI-assisted (Claude). The human submitter has reviewed every changed line and run the tests above.

Add InjectBase65536 and InjectHexagram to probes.encoding, addressing two
items from the "extra encodings" wishlist (issue NVIDIA#152).

Both encoders are clean-room ports of the MIT-licensed reference
implementations (qntm/base65536 and ferno/hexagram-encode) placed in
resources.encodings with attribution, so no new runtime dependency is
introduced. The base65536 port is validated byte-for-byte against the
reference; the hexagram port matches the reference README vector.

Adds roundtrip, known-vector, and invalid-input tests in
tests/resources/test_encodings.py. The new probes are also covered by the
existing parametrized probes.encoding test suite.

Signed-off-by: ANIS <119749586+assinscreedFC@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
@jmartin-tech jmartin-tech requested a review from leondz June 5, 2026 15:06
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.

1 participant