Skip to content

decipherpunk/rahuketu

Repository files navigation

rahuketu

rahuketu is a small zero-free encoding package. It combines a signed bijective number path (Rahu) with an arithmetic-coding path (Ketu), and records both as a log-space trace. Pure Python, no dependencies.

Install

pip install rahuketu

Usage

from rahuketu import Alphabet, roundtrip, trace

ab = Alphabet.lowercase()

r = roundtrip("hello", ab)
assert r["agrees"]            # encode -> decode is lossless

steps = trace("hello", ab)
last = steps[-1]
print(last.tau, last.upsilon, last.redundancy)

Components

  • Alphabet - no-zero symbol/digit mapping (digits in [1, b]).
  • Rahu - signed bijective numeration (RahuState, rahu_encode, rahu_decode).
  • Ketu - arithmetic coding as (midpoint, scale) (KetuState, ketu_encode, ketu_decode).
  • trace - records (tau, upsilon, a) over the input.
  • roundtrip - checks lossless encode/decode.

Provenance / AI assistance

Built by Ramakrishnan (ORCID 0009-0006-0905-7275). Signed and bijective numeration and arithmetic coding are classical methods. The zero-free Rahu-Ketu framing and this implementation are original. AI tools helped with tests, automation, and QA. The idea and direction are the author's.

License

Apache-2.0. See LICENSE and NOTICE.

About

No description, website, or topics provided.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages