I used an AI agent to build a Post-Quantum Crypto compiler A developer released PQC-Sweep v0.3, an early-preview Python tool that traces pandas encryption lineage to specific database columns, generates idempotent SQL column widenings for larger post-quantum ciphertexts, and rewrites RSA encrypt/decrypt calls to a hybrid X25519 + ML-KEM-768 (X-Wing) envelope with RSA dual-read fallback. The tool, tested in CI and on 10 public repositories, emits CycloneDX 1.6 CBOMs and is positioned as complementary to broad scanners such as IBM CBOMkit and OWASP cdxgen, but its author states it has not been independently audited. The release targets Harvest Now, Decrypt Later risk ahead of NIST IR 8547 (final, October 2026), which deprecates 112-bit-security parameters such as RSA-2048 after 2030 and disallows quantum-vulnerable public-key algorithms at any key size after 2035. The last mile of post-quantum migration for data engineering. Finding RSA in your code is the easy part. The hard part is the encrypted column in your warehouse: which table it lands in, whether the bigger post-quantum ciphertext still fits, and how to switch over without breaking every reader of the rows already written. PQC-Sweep does that part, deterministically, on your machine: 1. Traces pandas lineage. It follows df 'email' .apply encrypt fn across files, through renames and helpers, to the exact table.column it's written to to sql , SQLAlchemy ORM . 2. Generates idempotent SQL column widenings. A migration for each affected column, safe to run twice, that skips columns already wide enough and refuses to touch types it can't safely convert. 3. Injects a dual-read fallback envelope. RSA encrypt/decrypt calls are rewritten to a hybrid X25519 + ML-KEM-768 envelope X-Wing . Rows written before the migration keep decrypting with the original RSA key and padding. Status: early preview v0.3 . Tested in CI and on 10 public repositories validation report https://github.com/baldersonjames6-lang/pqc-sweep/blob/main/docs/real-world-validation.md . The envelope uses standard primitives and is checked against the X-Wing draft's test vectors, but it has not been independently audited. Read Scope and limits scope-and-limits before using it on production code. While tools like IBM CBOMkit handle broad language detection, pqc-sweep is purpose-built for the last mile of data engineering: tracing pandas lineage, generating idempotent SQL column widenings, and injecting dual-read fallback envelopes. | | Broad crypto scanners e.g. IBM CBOMkit / sonar-cryptography https://github.com/cbomkit/sonar-cryptography , OWASP cdxgen https://github.com/cdxgen/cdxgen | PQC-Sweep | |---|---|---| | Languages | Java, Python, Go and more | Python only | | CycloneDX CBOM | Yes | Yes 1.6, schema-validated | | Encrypted value → database column | Not their focus | Yes: pandas lineage to to sql / ORM table and column | | Schema migration for larger ciphertexts | No | Yes: idempotent PostgreSQL DO blocks; MySQL, SQL Server, SQLite | | Code rewrite | No inventory | Yes: RSA encrypt/decrypt → hybrid envelope with RSA dual-read | Use them together: a broad scanner for the estate-wide inventory, PQC-Sweep for the Python pipelines that write encrypted data into databases. Comparison based on each project's public documentation as of December 2026. Encrypted data that leaves your perimeter today can be recorded and stored. An attacker doesn't need to break RSA now. They only need to keep the ciphertext until a cryptographically relevant quantum computer can. This is Harvest Now, Decrypt Later HNDL . Data with a long confidentiality life is exposed today, even though the decryption happens later. That includes client PII, KYC records, account data and anything regulated for years or decades. Data pipelines are where this risk concentrates. They encrypt PII column by column, write the ciphertext into warehouses and keep it for years. The deadline is now published. NIST IR 8547, Transition to Post-Quantum Cryptography Standards final, October 2026 , sets the schedule for quantum-vulnerable public-key algorithms RSA, ECDSA, EdDSA, DH, ECDH : - Deprecated after 2030. This covers 112-bit-security parameters such as RSA-2048. - Disallowed under NIST standards and guidelines after 2035 , at any key size. The report supports Executive Order 14412 and OMB Memorandum M-26-15, which direct US federal agencies to prioritise moving their most sensitive systems to post-quantum cryptography. The replacement for RSA key establishment is ML-KEM FIPS 203 . Sources: NIST IR 8547 CSRC https://csrc.nist.gov/pubs/ir/8547/final · full text https://doi.org/10.6028/NIST.IR.8547 ML-KEM is new. X25519 is well studied but quantum-vulnerable. A hybrid KEM combines both, so stored data stays confidential unless both are broken. That is the transition pattern most of the industry has adopted. PQC-Sweep uses X-Wing draft-connolly-cfrg-xwing-kem-11 https://datatracker.ietf.org/doc/html/draft-connolly-cfrg-xwing-kem-11 , a concrete X25519 + ML-KEM-768 hybrid KEM with a SHA3-256 combiner. The implementation reproduces the draft's published test vectors for key generation and decapsulation. Its shared secret goes through HKDF-SHA256 into AES-256-GCM. Asking an LLM to "upgrade our crypto" is the wrong tool for this job: - Output is probabilistic. The same prompt can yield different code. A rewrite that looks right can still pick the wrong padding, drop a key path or invent an API, and in cryptography a plausible-looking mistake is a silent vulnerability. - There's no audit trail you can defend. A generated diff can't prove why each change was made or that nothing was missed. - Your code and data leave the building. Sending proprietary ETL, schemas and sample data to a hosted model widens the very exposure you're trying to close. PQC-Sweep applies fixed rules to the program's syntax tree: - It finds RSA wherever the key comes from. The cryptography RSA API always takes an explicit padding object OAEP , PKCS1v15 , PSS . PQC-Sweep matches on that padding, so it finds RSA encryption, decryption and signing whether the key is generated locally, loaded from PEM, passed in as a parameter or held on self . - Narrow, reversible rewrites. Only RSA encrypt / decrypt call sites change. Key-generation code, signatures and ECC are reported, never rewritten. Developer comments and formatting are kept libcst . - Nothing is guessed. A dynamic table name is reported as UNRESOLVED , never invented, and --strict fails the CI run when that happens. Encrypt sites whose recipient key comes from elsewhere are flagged for human review. - It runs entirely on your machine. No network calls, no model, and no data leave your machine. python def encrypt pii data string : This is the cryptographic sink our engine needs to find - private key = rsa.generate private key public exponent=65537, key size=2048 - public key = private key.public key RSA-OAEP encrypt the value and store it as base64 text - ciphertext = public key.encrypt - data string.encode , - padding.OAEP mgf=padding.MGF1 algorithm=hashes.SHA256 , algorithm=hashes.SHA256 , label=None , - + ciphertext = QuantumSafeHybridEnvelope .encrypt bytes data string.encode , load pqc public key return base64.b64encode ciphertext .decode def decrypt pii token, private key : Downstream readers decrypt with the RSA private key - plaintext = private key.decrypt - base64.b64decode token , - padding.OAEP mgf=padding.MGF1 algorithm=hashes.SHA256 , algorithm=hashes.SHA256 , label=None , - + plaintext = QuantumSafeHybridEnvelope .decrypt base64.b64decode token , {'pqc': load pqc private key, 'rsa': private key}, legacy padding=padding.OAEP mgf=padding.MGF1 algorithm=hashes.SHA256 , algorithm=hashes.SHA256 , label=None return plaintext.decode - Encrypt calls become encrypt bytes ... , which still returns bytes , so code that base64-encodes or stores the result keeps working. - Decrypt calls keep the original RSA key and padding as a fallback. Rows written before the migration still decrypt, and the post-quantum private key is only loaded when a post-quantum value is read. - Key generation that is no longer used is removed. Imports are tidied, and comments stay. 1. migration.sql : DDL that widens every ciphertext column PQC-Sweep traced to fit the hybrid envelope about 2k characters, against about 344 for RSA-2048 in base64 . On PostgreSQL each change is an idempotent DO block : - TEXT and wide-enough VARCHAR columns are skipped; - short VARCHAR / CHAR columns are widened; - incompatible types such as BYTEA stop the migration rather than corrupting data. MySQL, SQL Server and SQLite are also supported. 2. pqc envelope.py : the runtime that gets injected. X-Wing X25519 + ML-KEM-768 → HKDF-SHA256 → AES-256-GCM via cryptography , in a binary format encrypt bytes and a text format pqc:v2:xwing:... . It reads legacy RSA ciphertext with the caller's original padding, and ML-KEM-only values written by pqc-sweep 0.2. If ML-KEM is unavailable it refuses to run rather than producing insecure output. 3. Rewritten source : originals are backed up to .pqc sweep/backup/ . --dry-run shows the plan without touching anything. 4. cbom.json : a CycloneDX 1.6 Cryptographic Bill of Materials. Every RSA/ECC asset key generation, encryption, decryption, signatures, and PyCryptodome usage is tagged nistQuantumSecurityLevel: 0 , with the source location, the taint flow, the database table it lands in and a remediation note. It is validated against the official schema in the test suite, and literal values from source are redacted so PII never reaches the report. pip install pqc-sweep Python 3.9+; installs the pqc-sweep command pqc-sweep --repo path/to/your/etl --dry-run --strict report and plan only: CBOM + DDL + what would be rewritten pqc-sweep --repo path/to/your/etl full sweep originals backed up to .pqc sweep/backup/ The rewritten code needs cryptography with ML-KEM support in the target project: pip install "pqc-sweep runtime " or add cryptography =46 to its requirements. From source to run the tests or the bundled demo : git clone https://github.com/baldersonjames6-lang/pqc-sweep && cd pqc-sweep python3 -m venv .venv && .venv/bin/pip install --upgrade pip editable installs need pip = 21.3 macOS system Python ships 21.2 .venv/bin/pip install -e '. dev ' add ,pg-embedded to run the live PostgreSQL tests locally .venv/bin/pqc-sweep --repo examples/demo pipeline 🔍 Initializing config-time PQC Sweep... scanned 2 module s ; 3 quantum-vulnerable asset s ; 1 taint flow s PQC-001 main pipeline.py:13 df 'client email' - crypto utils.encrypt pii data string - df 'secure email' DB SINK client secure vault.secure email <- main pipeline.py:17 pandas.to sql CBOM - examples/demo pipeline/cbom.json CycloneDX 1.6, 2 component s DDL - examples/demo pipeline/migration.sql postgresql, 1 ALTER statement s guarded by idempotent DO block s , VARCHAR 2048 ALTER TABLE "client secure vault" ALTER COLUMN "secure email" TYPE VARCHAR 2048 ; RUNTIME - examples/demo pipeline/pqc envelope.py MUTATED crypto utils.py: encrypt pii encrypt x1 , decrypt pii decrypt x1 libcst, comments preserved ✅ Transpilation complete. CBOM, SQL DDL, and Quantum-Safe Code generated. Running the rewritten code: - Set PQC XWING PUBLIC KEY to the X-Wing public key file 1216 raw bytes where data is encrypted, and PQC XWING PRIVATE KEY to the 32-byte private seed where post-quantum values are decrypted. - pqc envelope.generate keypair dir creates a test pair. Keep real keys in your KMS or secret store. - Upgrading from 0.2: values written by 0.2 pqc:v1:mlkem768 still decrypt if you pass the old ML-KEM key as 'mlkem' e.g. {'pqc': load pqc private key, 'mlkem': load mlkem private key, 'rsa': key} . Call sites rewritten by 0.2 keep working but write non-hybrid values with a DeprecationWarning , so re-run the sweep or update them to load pqc public key . The generated PostgreSQL migration excerpt : bash DO $pqc$ DECLARE v type text; v len integer; BEGIN SELECT data type, character maximum length INTO v type, v len FROM information schema.columns WHERE table schema = current schema AND table name = 'client secure vault' AND column name = 'secure email'; IF NOT FOUND THEN RAISE WARNING 'pqc-sweep: % not found, nothing altered', 'client secure vault.secure email'; ELSIF v type = 'text' OR v type = 'character varying' AND v len IS NULL OR v len = 2048 THEN RAISE NOTICE 'pqc-sweep: % already holds % chars % , skipped', 'client secure vault.secure email', 2048, v type; ELSIF v type IN 'character varying', 'character' THEN ALTER TABLE "client secure vault" ALTER COLUMN "secure email" TYPE VARCHAR 2048 ; RAISE NOTICE 'pqc-sweep: % widened to VARCHAR 2048 ', 'client secure vault.secure email'; ELSE RAISE EXCEPTION 'pqc-sweep: % is %, which needs a manual data migration', 'client secure vault.secure email', v type; END IF; END $pqc$; The CBOM entry excerpt from examples/demo pipeline/cbom.json : { "type": "cryptographic-asset", "name": "RSA-2048", "cryptoProperties": { "assetType": "algorithm", "algorithmProperties": { "primitive": "pke", "parameterSetIdentifier": "2048", "cryptoFunctions": "encrypt", "keygen" , "classicalSecurityLevel": 112, "nistQuantumSecurityLevel": 0 }, "oid": "1.2.840.113549.1.1.1" }, "properties": { "name": "pqc-sweep:taint-flow", "value": "PQC-001 main pipeline.py:13 df 'client email' - crypto utils.encrypt pii data string - df 'secure email' " }, { "name": "pqc-sweep:taint-origin", "value": "PQC-001 pd.DataFrame {'client email': '