import { Injectable } from "@nestjs/common"; import { ml_kem768 } from "@noble/post-quantum/ml-kem.js"; @Injectable() export class PostQuantumService { generatePostQuantumKeyPair() { const seed = new Uint8Array(64); crypto.getRandomValues(seed); const { publicKey, secretKey } = ml_kem768.keygen(seed); return { publicKey, secretKey }; } encapsulate(publicKey: Uint8Array) { return ml_kem768.encapsulate(publicKey); } decapsulate(cipherText: Uint8Array, secretKey: Uint8Array) { return ml_kem768.decapsulate(cipherText, secretKey); } }