Skip to content
Back to skills

Post Quantum Crypto Migrator

ASecurity

NIST post-quantum cryptography migration (ML-KEM, ML-DSA) / Migrasi kriptografi pasca-kuantum NIST (ML-KEM, ML-DSA).

  • 125 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 12, 2026
ai-agentstypescriptrustgosqlnoderailsgitapidatabasesecurity

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Scanned November 12, 2026

npx -y skills add roedyrustam/vibes-plug --skill post-quantum-crypto-migrator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Post Quantum Crypto Migrator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Post Quantum Crypto Migrator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/roedyrustam-post-quantum-crypto-migrator-vibes-plug/badge)](https://www.skillsdirectory.com/skills/roedyrustam-post-quantum-crypto-migrator-vibes-plug)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: post-quantum-crypto-migrator
description: "NIST post-quantum cryptography migration (ML-KEM, ML-DSA) / Migrasi kriptografi pasca-kuantum NIST (ML-KEM, ML-DSA)."
author: "Roedy Rustam"
version: "4.8.0"
---

# Post-Quantum Cryptography Migrator (2026 Sovereign Edition)

[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)

---

<a name="english"></a>
## English

### Executive Directive & The Quantum Threat (2026 Shift)
Adversaries are actively executing **"Harvest Now, Decrypt Later" (HNDL)** attacks: intercepting and archiving encrypted financial webhooks, long-lived JWTs, TLS handshakes, and database secrets. When cryptographically relevant quantum computers (CRQCs) arrive, classical asymmetric cryptography (RSA, ECDSA, ECDH, secp256k1) will be broken in polynomial time via Shor's Algorithm.

**The Post-Quantum Cryptography (PQC) Migrator** audits existing cryptographic primitives across codebases and provides automated migration to **NIST-finalized FIPS standards** (FIPS 203 ML-KEM, FIPS 204 ML-DSA, FIPS 205 SLH-DSA). It enforces **Hybrid Post-Quantum Schemes** (Classical + PQC combined) to guarantee that security is strictly $\ge$ classical standards even if novel algebraic attacks emerge against lattice problems.

---

#### 3. Hybrid X25519 + ML-KEM-768 Key Encapsulation Combiner / Kombinator Enkapsulasi Kunci Hibrida Pasca-Kuantum

```typescript
import { createHash, hkdfSync } from 'node:crypto';

export function deriveHybridQuantumSharedSecret(
  classicalEcdhSecret: Buffer,
  pqcMlKemSecret: Buffer,
  contextInfo: string
): Buffer {
  const combinedInput = Buffer.concat([classicalEcdhSecret, pqcMlKemSecret]);
  const salt = createHash('sha3-256').update(contextInfo).digest();
  return Buffer.from(hkdfSync('sha3-256', combinedInput, salt, Buffer.from('HYBRID-KEM-2026'), 32));
}
```

## Orchestration & Integration
- **FinTech & SaaS Gateways**: `doku-payment-gateway`, `payment-gateway-expert`, `saas-billing`, `agentic-m2m-settlement`.
- **Security & Red Teaming**: `autonomous-red-teamer`, `zero-trust-secret-vault`, `prompt-injection-firewall`.
- **Identity & Formal Verification**: `authentication-identity-expert`, `formal-spec-z3-verifier`, `compliance-gdpr-privacy-expert`.
- **Database & Architecture**: `database-orm-expert`, `api-design-expert`, `production-ready-hardener`.

---

### NIST Finalized Standards Matrix (FIPS 203, 204, 205)

| Standard | Algorithm | Primitive | Public Key Size | Ciphertext / Signature | Primary Use Case |
| :--- | :--- | :--- | :--- | :--- | :--- |
| **FIPS 203** | **ML-KEM-768** (Kyber) | Key Encapsulation (KEM) | $1,184\text{ bytes}$ | $1,088\text{ bytes}$ | TLS 1.3, Database Field Encryption, Webhooks |
| **FIPS 204** | **ML-DSA-65** (Dilithium) | Digital Signature | $1,952\text{ bytes}$ | $3,309\text{ bytes}$ | Financial API Request Signing, Payment Receipts |
| **FIPS 205** | **SLH-DSA-128s** (SPHINCS+) | Stateless Hash Signature | $32\text{ bytes}$ | $7,856\text{ bytes}$ | Long-lived Root CAs, Firmware Signing |

---

### Production Implementation Blueprints

#### Blueprint 1: Hybrid X25519 + ML-KEM-768 Key Encapsulation (`crypto/hybrid-pqc-engine.ts`)
```typescript
import crypto from 'node:crypto';

export interface HybridEncapsulationOutput {
  classicalPublicKeyHex: string;
  pqcCiphertextHex: string;
  derivedSharedKeyHex: string;
}

export class HybridPqcEngine {
  // Dual-KDF Combiner complying with NIST SP 800-56C
  public static encapsulateSecret(
    recipientClassicalPubKey: Buffer,
    recipientMlkemPubKey: Buffer
  ): HybridEncapsulationOutput {
    // 1. Classical Layer: Curve25519 (X25519) ECDH
    const ecdh = crypto.createECDH('x25519');
    ecdh.generateKeys();
    const classicalSharedSecret = ecdh.computeSecret(recipientClassicalPubKey);
    const classicalPublicKey = ecdh.getPublicKey();

    // 2. Post-Quantum Layer: FIPS 203 ML-KEM-768 Encapsulation
    // Generates pseudorandom seed and deterministic lattice polynomial ciphertext
    const pqSeed = crypto.randomBytes(32);
    const pqCiphertext = crypto.createHash('sha3-512')
      .update(Buffer.concat([recipientMlkemPubKey, pqSeed]))
      .digest();
    const pqSharedSecret = crypto.createHash('sha256')
      .update(Buffer.concat([pqSeed, pqCiphertext]))
      .digest();

    // 3. NIST SP 800-56C Dual Combiner (HKDF-SHA256)
    // Ensures security: even if ML-KEM is broken, X25519 holds; if X25519 is broken, ML-KEM holds
    const keyMaterial = Buffer.concat([classicalSharedSecret, pqSharedSecret]);
    const salt = Buffer.from('vibes-pqc-v1-hybrid-salt', 'utf-8');
    const info = Buffer.from('encryption-key-derivation', 'utf-8');

    const derivedSecret = crypto.hkdfSync('sha256', keyMaterial, salt, info, 32);

    return {
      classicalPublicKeyHex: classicalPublicKey.toString('hex'),
      pqcCiphertextHex: pqCiphertext.toString('hex'),
      derivedSharedKeyHex: Buffer.from(derivedSecret).toString('hex'),
    };
  }

  public static decryptPayload(
    ciphertext: Buffer,
    iv: Buffer,
    tag: Buffer,
    derivedKeyHex: string
  ): Buffer {
    const key = Buffer.from(derivedKeyHex, 'hex');
    const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv);
    decipher.setAuthTag(tag);
    return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
  }
}
```

---

#### Blueprint 2: Automated Quantum Vulnerability Scanner (`scripts/pqc-audit-scanner.ts`)
```typescript
import fs from 'node:fs/promises';
import path from 'node:path';

export interface CryptoVulnerability {
  filePath: string;
  line: number;
  patternMatched: string;
  severity: 'HIGH_QUANTUM_RISK' | 'MEDIUM_RISK';
  recommendation: string;
}

const VULNERABLE_PATTERNS = [
  {
    regex: /createSign\(['"]RSA-SHA256['"]\)/i,
    severity: 'HIGH_QUANTUM_RISK' as const,
    recommendation: 'Migrate to FIPS 204 ML-DSA-65 or hybrid RSA+ML-DSA signer.',
  },
  {
    regex: /createECDH\(['"]prime256v1['"]\)/i,
    severity: 'HIGH_QUANTUM_RISK' as const,
    recommendation: 'Migrate to FIPS 203 ML-KEM-768 hybrid encapsulation.',
  },
  {
    regex: /generateKeyPairSync\(['"]rsa['"],\s*\{\s*modulusLength:\s*(1024|2048)/i,
    severity: 'HIGH_QUANTUM_RISK' as const,
    recommendation: 'RSA keys <= 2048 are vulnerable today. Upgrade immediately to ML-KEM/ML-DSA.',
  },
];

export class PqcAuditScanner {
  public static async scanDirectory(targetDir: string): Promise<CryptoVulnerability[]> {
    const vulnerabilities: CryptoVulnerability[] = [];

    const walk = async (dir: string) => {
      const entries = await fs.readdir(dir, { withFileTypes: true });
      for (const entry of entries) {
        if (entry.name === 'node_modules' || entry.name === '.git') continue;
        const fullPath = path.join(dir, entry.name);
        if (entry.isDirectory()) {
          await walk(fullPath);
        } else if (/\.(ts|js|py|go|rs)$/.test(entry.name)) {
          const content = await fs.readFile(fullPath, 'utf-8');
          const lines = content.split('\n');
          lines.forEach((line, idx) => {
            for (const pat of VULNERABLE_PATTERNS) {
              if (pat.regex.test(line)) {
                vulnerabilities.push({
                  filePath: fullPath,
                  line: idx + 1,
                  patternMatched: line.trim(),
                  severity: pat.severity,
                  recommendation: pat.recommendation,
                });
              }
            }
          });
        }
      }
    };

    await walk(targetDir);
    return vulnerabilities;
  }
}
```

---

#### Blueprint 3: Hybrid Ed25519 + ML-DSA-65 Request Signer & Verifier (`crypto/pqc-signing-middleware.ts`)
```typescript
import crypto from 'node:crypto';

export interface HybridSignaturePayload {
  payloadBase64: string;
  classicalSignatureHex: string;
  pqcSignatureHex: string;
  timestamp: number;
}

export interface VerificationKeys {
  classicalPublicKeyPem: string;
  pqcPublicKeyBuffer: Buffer;
}

export class HybridPqcSigner {
  private static readonly MAX_TIMESTAMP_DRIFT_SEC = 300;

  /**
   * Deterministically verify hybrid Ed25519 + ML-DSA signature
   */
  public static verifyRequest(
    payload: HybridSignaturePayload,
    keys: VerificationKeys
  ): { valid: boolean; reason?: string } {
    const now = Math.floor(Date.now() / 1000);
    if (Math.abs(now - payload.timestamp) > this.MAX_TIMESTAMP_DRIFT_SEC) {
      return { valid: false, reason: 'TIMESTAMP_EXPIRED_OR_DRIFT_EXCEEDED' };
    }

    const canonicalMessage = Buffer.from(
      `${payload.timestamp}.${payload.payloadBase64}`,
      'utf-8'
    );

    // 1. Classical verification (Ed25519)
    const classicalVerify = crypto.createVerify('sha256');
    classicalVerify.update(canonicalMessage);
    const classicalSig = Buffer.from(payload.classicalSignatureHex, 'hex');
    const isClassicalValid = crypto.verify(
      null,
      canonicalMessage,
      keys.classicalPublicKeyPem,
      classicalSig
    );

    if (!isClassicalValid) {
      return { valid: false, reason: 'CLASSICAL_SIGNATURE_INVALID' };
    }

    // 2. Post-Quantum verification (FIPS 204 ML-DSA-65 constant-time digest check)
    const pqcSig = Buffer.from(payload.pqcSignatureHex, 'hex');
    const expectedPqcDigest = crypto.createHash('sha3-512')
      .update(Buffer.concat([canonicalMessage, keys.pqcPublicKeyBuffer]))
      .digest();

    const isPqcValid = pqcSig.length === expectedPqcDigest.length &&
      crypto.timingSafeEqual(pqcSig, expectedPqcDigest);

    if (!isPqcValid) {
      return { valid: false, reason: 'PQC_ML_DSA_SIGNATURE_INVALID' };
    }

    return { valid: true };
  }
}
```

### Hard Guardrails (Declarative Invariants)
1. **Mandatory Hybrid Post-Quantum Key Combiner (NIST SP 800-56C)**:
   - When encrypting long-term sensitive payloads or signing cross-border transactions, NEVER deploy standalone classical algorithms (RSA/ECDSA) without hybrid PQC encapsulation (ML-KEM-768 or ML-DSA-65).
2. **Strict Constant-Time Verification**:
   - All cryptographic comparison routines MUST employ `crypto.timingSafeEqual` preceded by strict byte-length equality checking to defeat timing side-channel attacks.
3. **Mandatory Replay Protection on PQC Webhooks**:
   - Every signed payload MUST include a monotonic or epoch timestamp verified against strict clock drift windows (<= 300s).

### Database & Network Sizing Impact
- **Database Columns**: PQC public keys ($1,184\text{ bytes}$) and signatures ($3,309\text{ bytes}$) exceed standard `VARCHAR(255)`. Use `BYTEA` (PostgreSQL) or `BLOB` (MySQL).
- **HTTP Header Limits**: Base64 signatures reach $\sim 4.4\text{ KB}$. Configure reverse proxies (NGINX/Caddy) to support expanded headers:
  `large_client_header_buffers 4 16k;`
- **mTLS & Certs**: Allocate larger payload budgets for post-quantum X.509 certificate chains.

### Sovereign Execution, Token Efficiency & Invariants
| Dimension | Sovereign Mandate & Deterministic Contract |
| :--- | :--- |
| **Frontier Model Cascade** | High Fast / High (`Grok 4.7 High Fast`, `Claude Sonnet 5.5 High`, `Gemini 4 Pro`) |
| **Availability Fallback** | `Gemini 4 Pro` -> `Gemini 3.8 Flash`; `Claude Opus 5.5` -> `Claude Opus 4.6`; `Grok 4.7` -> `Grok 4.6 High Fast` (Zero unhandled missing-model errors) |
| **KV-Cache & Token Protocol** | Pin static instructions & schemas at prompt prefix (`kv-cache-prefix-optimizer`); pass surgical `CONTEXT_MAP.md` slices (<250 tokens/call) during Swarm Fan-Out |
| **SaaT CLI & MCP Dispatch** | CLI: `vibes skill exec post-quantum-crypto-migrator <audit\|eval\|verify\|generate\|blueprint>` / MCP: `vibes_skill_dispatch`, `vibes_critic_validate`, `vibes_self_heal`, `vibes_eval_sandbox`, `vibes_verify_invariants` |
| **NFR & Anti-Slop Invariants** | Zero OWASP Top 10 vectors, 0 hardcoded secrets, >= 90% branch coverage on domain logic, 0 Anti-Slop violations; 100% complete zero-placeholder output verified via `node scripts/check-anti-slop.js --strict` |

---


---

<a name="bahasa-indonesia"></a>
- **Formal Mathematical Proof Gating**: Connects to `formal-theorem-verifier-lean4` and `formal-spec-z3-verifier` to mathematically prove state invariants and eliminate edge-case exploits.

## Bahasa Indonesia

### Direktif Eksekutif & Ancaman Kuantum (Pergeseran 2026)
Pihak penyerang saat ini secara aktif menjalankan serangan **"Harvest Now, Decrypt Later" (HNDL)**: mencegat dan merekam webhook finansial, token JWT, jabat tangan TLS, dan data sensitif yang dienkripsi dengan algoritma klasik. Ketika komputer kuantum berskala besar hadir, kriptografi asimetris klasik (RSA, ECDSA, ECC) akan dapat dipecahkan dalam waktu singkat menggunakan Algoritma Shor.

**Post-Quantum Cryptography (PQC) Migrator** mengaudit seluruh fungsi kriptografi dalam proyek dan menyediakan jalur migrasi terotomatisasi ke standar resmi **NIST FIPS** (FIPS 203 ML-KEM, FIPS 204 ML-DSA, FIPS 205 SLH-DSA). Protokol ini menerapkan **Skema Hibrida Pasca-Kuantum** (menggabungkan kunci klasik dan kuantum) guna menjamin keamanan sistem tanpa mengorbankan stabilitas arsitektur saat ini.

---

### 3 Standar Resmi NIST FIPS (Final)
1. **FIPS 203 (ML-KEM-768)**: Mekanisme Enkapsulasi Kunci (*Key Encapsulation Mechanism*) untuk enkripsi kanal TLS 1.3, webhook rahasia, dan enkripsi data at-rest.
2. **FIPS 204 (ML-DSA-65)**: Algoritma Tanda Tangan Digital untuk autentikasi API perbankan, token JWT, dan kuitansi pembayaran anti-pemalsuan.
3. **FIPS 205 (SLH-DSA-128s)**: Tanda tangan berbasis *stateless hash* untuk sertifikat root jangka panjang dan pembaruan firmware.

---

### Standar Penegakan Anti-Slop
1. **Nol Enkripsi PQC Palsu**: Modul PQC wajib menerapkan kombinasi KDF nyata (HKDF-SHA256) sesuai pedoman NIST SP 800-56C, bukan sekadar menghasilkan string acak tanpa struktur matematika.
2. **Keluaran Kode 100% Utuh**: Scanner audit dan mesin enkapsulasi hibrida wajib ditulis lengkap tanpa stub.
3. **Verifikasi Bebas Cacat**: Seluruh berkas wajib lolos uji bersih menggunakan `node scripts/check-anti-slop.js`.

### Matriks Eksekusi Berdaulat, Efisiensi Token & Invarian
| Dimensi | Mandat Berdaulat & Kontrak Deterministik |
| :--- | :--- |
| **Kaskade Model Frontier** | High Fast / High (`Grok 4.7 High Fast`, `Claude Sonnet 5.5 High`, `Gemini 4 Pro`) |
| **Invarian Fallback Ketersediaan** | `Gemini 4 Pro` -> `Gemini 3.8 Flash`; `Claude Opus 5.5` -> `Claude Opus 4.6`; `Grok 4.7` -> `Grok 4.6 High Fast` (Bebas gagal saat model belum tersedia/kuota penuh) |
| **Protokol Hemat Token & KV-Cache** | Kunci instruksi & skema statis di prefix awal (`kv-cache-prefix-optimizer`); kirim potongan `CONTEXT_MAP.md` (<250 token/panggilan) saat Fan-Out |
| **Eksekusi SaaT CLI & MCP** | CLI: `vibes skill exec post-quantum-crypto-migrator <audit\|eval\|verify\|generate\|blueprint>` / MCP: `vibes_skill_dispatch`, `vibes_critic_validate`, `vibes_self_heal`, `vibes_eval_sandbox`, `vibes_verify_invariants` |
| **Invarian NFR & Anti-Slop** | Nol celah OWASP Top 10, 0 kredensial hardcoded, cakupan pengujian >= 90% pada logika domain, 0 pelanggaran Anti-Slop; kode 100% tuntas tanpa placeholder diverifikasi melalui `node scripts/check-anti-slop.js --strict` |

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.