
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
quantum-resistant-rustykey
Advanced tools
WebAssembly ML-KEM (post-quantum) key encapsulation for Node.js and web.
Note: 🚧 WORK IN PROGRESS...do not pnpm install 🚧
A WebAssembly implementation of ML-KEM (Quantum-Resistant Signatures) for both Node.js and web environments. This is an improved version of the NIST winner's standard implementation, patched to withstand side-channel attacks.
mlkem-wasm project directly into this repository (no runtime dependency on the mlkem-wasm npm package).loadMlKem768() is the fully aligned implementation path today.loadMlKem512() and loadMlKem1024() are compatibility loaders currently routed through the same hardened internals while dedicated per-parameter-set support is being completed.mlkem-wasm project:
You use this quantum-resistant RustyKey® npm package mainly for secure key exchange, specifically as a Key Encapsulation Mechanism (KEM). It's designed to securely establish a shared secret between two parties, which is then used for encryption with a symmetric algorithm like AES. While Kyber can be used for encryption, its primary function is to encapsulate and transmit a session key, not the data itself.
Here's a more detailed explanation: Key Exchange (KEM):
In essence, RustyKey® quantum-resistant npm package creates a secure handshake, establishing a shared secret key that can then be used to encrypt and decrypt data with a more efficient symmetric encryption algorithm
Wasm operates within a sandboxed environment, isolating it from the host system. This prevents malicious code within the Wasm module from directly accessing sensitive data or compromising system resources. JavaScript, while also sandboxed, has a larger attack surface due to its dynamic nature and access to a wider range of APIs.
Since Wasm modules have limited access to system resources and APIs, their attack surface is smaller than that of JavaScript. This makes it more difficult for attackers to exploit vulnerabilities.
(mostly!) as Web Assembly (WASM) implementations of algorithms offer near-native performance due to WASM's low-level of bytecode, which itself is usually orders of magnitude faster than JavaScript for computationally intensive tasks.
Wasm modules have explicit import declarations, defining the exact functions they can access from the host environment (usually JavaScript). This allows for fine-grained control over the module's capabilities. In contrast, JavaScript has more implicit access to APIs, making it harder to restrict its behavior.
Wasm's binary format allows for static analysis and code validation. This enables browsers to verify the module's structure and behavior before execution, reducing the risk of introducing vulnerabilities. JavaScript, being dynamically typed and interpreted, is more challenging to analyze statically.
Wasm code is compiled into a low-level bytecode that is validated before execution. This process helps to identify and prevent many types of vulnerabilities that are common in JavaScript, such as buffer overflows.
WASM is more complex to work with than JavaScript, and requires a build process to compile code into WASM modules and manual memory management, which is why this package exists...to make it easier for developers and end-users to incorporate the benefits of increased security and faster speed into their authentication, authorization and other encryption/decryption workflows.
WASM cannot directly manipulate the DOM. It relies on JavaScript to interact with the DOM, which adds complexity and can affect performance when frequent DOM interactions are needed.
WASM relies on JavaScript for garbage collection, which can be less efficient compared to languages with native garbage collection.
WASM has limited access to browser and Node.js APIs compared to JavaScript, requiring JavaScript to act as a bridge for these interactions.
Passing data between WASM and JavaScript can incur performance overhead due to serialization and deserialization.
Based on a suite of "Cryptographic Suite for Algebraic Lattices" (CRYSTALS) based on hard problems over module lattices, designed to withstand attacks by large quantum computers, and selected among the winners of the NIST post-quantum cryptography project
| Package | Registry | Description |
|---|---|---|
| quantum-resistant-rustykey | 🚧 WORK IN PROGRESS 🚧 |
For Node.js, you can install quantum-resistant-rustykey via pnpm, npm or yarn:
pnpm install quantum-resistant-rustykey
# or
npm install quantum-resistant-rustykey
# or
yarn add quantum-resistant-rustykey
import { loadMlKem1024, loadMlKem768, loadMlKem512 } from "quantum-resistant-rustykey";
async function main() {
try {
// Load the desired ML-KEM variant
const mlkem = await loadMlKem1024(); // Options: loadMlKem1024, loadMlKem768, loadMlKem512
// Generate key pair
const keypair = mlkem.keypair();
const publicKey = mlkem.buffer_to_string(keypair.get('public_key'));
const privateKey = mlkem.buffer_to_string(keypair.get('private_key'));
console.log("Public Key:", publicKey);
console.log("Private Key:", privateKey);
// Encrypt a message
const message = "Hello, this is a secret message!";
var encrypt = mlkem.encrypt(keypair.get('public_key'))
const sharedSecret = encrypt.get('secret')
const encryptedMessage = await mlkem.encryptMessage(message, sharedSecret)
console.log("Encrypted message: ", encryptedMessage)
// Decrypt the message
var decryptedSharedSecret = mlkem.decrypt(encrypt.get('cyphertext'), keypair.get('private_key'))
const decryptedMessage = await mlkem.decryptMessage(encryptedMessage, decryptedSharedSecret)
console.log("Decrypted message: ", decryptedMessage)
} catch (error) {
console.error("Error:", error);
}
}
main();
When using ML-KEM in a web environment, consider the following security best practices:
Key Storage:
Key Management:
Data Handling:
Performance:
git clone https://github.com/antonymott/quantum-resistant-rustykey.git
cd quantum-resistant-rustykey
git submodule update --init --recursive
pnpm i
The package supports two different environments:
sENVIRONMENT=web,worker in CMakeLists.txtsENVIRONMENT=node,worker in CMakeLists.txtpnpm pre
# Copy the WASM file to src directory
cp install/kyber_crystals_wasm_engine.wasm ./src/
The sENVIRONMENT option specifies which environments the WebAssembly module should be built for:
web: Enables running in web browsersworker: Enables running in Web Workersnode: Enables running in Node.jsFor web applications, use web,worker to support both browser and Web Worker environments.
For Node.js applications, use node,worker to support both Node.js and Worker Threads.
pnpm build
install/test.html in a live server and check the console for encryption/decryption results of the three variantsstateDiagram-v2
[*] --> install
install --> [*]
install --> kyber_crystals_wasm_engine.js
kyber_crystals_wasm_engine.js --> kyber_crystals_wasm_engine.wasm
kyber_crystals_wasm_engine.wasm --> test.html
test.html --> [*]
The package is published from the install folder. To publish a new version:
This implementation includes patches to withstand side-channel attacks. For more information about the security improvements, see: RaspberryPi recovers secret keys from NIST winner implementation...within minutes
ISC
FAQs
WebAssembly ML-KEM (post-quantum) key encapsulation for Node.js and web.
The npm package quantum-resistant-rustykey receives a total of 1 weekly downloads. As such, quantum-resistant-rustykey popularity was classified as not popular.
We found that quantum-resistant-rustykey demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.