You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From #3: warn the first time someone uses a Kyber* class, once per process, and change nothing else.
Any Kyber* entry point (constructor, from_keys, static encapsulate/decapsulate) warns on first use. Importing doesn't warn
One warning per process total, across all three classes
The message says Kyber and ML-KEM aren't interoperable (both sides need to switch) and links the migration guide
Test it in a subprocess: use the classes many times, count exactly one warning; golden vectors still pass
Use a quiet DeprecationWarning for now: a KyberDeprecationWarning subclass, with stacklevel set so it points at the caller's code. Python only shows it by default when it comes from __main__, and that's fine for this release. The README will say it clearly.
Done when: the subprocess test passes and output is unchanged.
Handoff for whoever picks this up (#13 is merged; dev-v2 has everything it needs).
Where the entry points are, all in python/pykyber/_kyber.py: for each of Kyber512, Kyber768 and Kyber1024, __new__, from_keys, and the static encapsulate and decapsulate. The methods on the returned Keypair come after a constructor or from_keys call that already warned, so they need nothing. Do not touch python/pykyber/_mlkem.py: ML-KEM must never warn, and there is no shared base class with the Kyber classes.
Things that will bite:
Python hides DeprecationWarning unless it is attributed to __main__, and the default per-location registry can swallow repeats. Guard "once per process" with your own module-level flag (take a lock so two threads cannot both warn) instead of relying on the filter, and in the subprocess test run with -W always::DeprecationWarning or -W default so you see what is really emitted. Also test that the warning is silent by default for an imported library and that importing pykyber alone emits nothing.
stacklevel has to land on the user's call, not on _kyber.py. The depth differs between __new__, the classmethod from_keys and the static methods if you route them through a helper; check it with a test that reads warning.filename.
The existing tests (test_kyber.py, test_legacy_vectors.py, parts of test_mlkem.py) use Kyber classes in-process and will now see the warning. Check pytest does not turn warnings into errors anywhere (CI, pyproject) and do not edit those tests to hide it. Output must stay byte-identical; the golden vectors are the proof.
Done in #38 (rebase-merged into dev-v2 as a666d76 and 6883dd8). First use of any Kyber512/768/1024 entry point emits one KyberDeprecationWarning per process; importing and ML_KEM_* never warn; Kyber output is unchanged (golden vectors pass untouched). The subprocess tests are in python/tests/test_kyber_deprecation.py.
Activity
Zikithezikit commentedon Oct 30, 2026
Handoff for whoever picks this up (#13 is merged; dev-v2 has everything it needs).
Where the entry points are, all in python/pykyber/_kyber.py: for each of Kyber512, Kyber768 and Kyber1024,
__new__,from_keys, and the staticencapsulateanddecapsulate. The methods on the returnedKeypaircome after a constructor orfrom_keyscall that already warned, so they need nothing. Do not touch python/pykyber/_mlkem.py: ML-KEM must never warn, and there is no shared base class with the Kyber classes.Things that will bite:
__main__, and the default per-location registry can swallow repeats. Guard "once per process" with your own module-level flag (take a lock so two threads cannot both warn) instead of relying on the filter, and in the subprocess test run with-W always::DeprecationWarningor-W defaultso you see what is really emitted. Also test that the warning is silent by default for an imported library and that importing pykyber alone emits nothing.__new__, the classmethodfrom_keysand the static methods if you route them through a helper; check it with a test that readswarning.filename.__all__. It is a warning, not an error, so it does not belong in _error.py; a new small module is fine.Not in scope: README and docs (that is #15), version bump, any change to the Kyber behavior.
Zikithezikit commentedon Oct 30, 2026
Done in #38 (rebase-merged into dev-v2 as a666d76 and 6883dd8). First use of any Kyber512/768/1024 entry point emits one KyberDeprecationWarning per process; importing and ML_KEM_* never warn; Kyber output is unchanged (golden vectors pass untouched). The subprocess tests are in python/tests/test_kyber_deprecation.py.
The warning message links https://github.com/Zikithezikit/pykyber/blob/main/docs/migration.md, so #15 has to create exactly docs/migration.md.