@quantumchat/pqchat-node
v0.1.0
Published
QuantumChat native core bindings for Node.js
Readme
@quantumchat/pqchat-node
Node.js binding for pqchat-core using napi-rs. This package provides high-performance Native bindings to QuantumChat's post-quantum cryptographic core.
Installation
npm install @quantumchat/pqchat-nodeNote: Prebuilt binaries are provided for macOS (arm64, x64) and Linux (arm64, x64). You do not need a Rust compiler to install this package on supported platforms.
Usage
Low-Level Buffer API (N-API)
The standard interface provides zero-copy Buffer methods for maximum performance:
const {
PqchatClient,
mldsaKeygen,
mldsaSign,
mlkemKeygen,
hkdfExpand
} = require('@quantumchat/pqchat-node');
// 1. Stateless Crypto
const mlkemKeys = mlkemKeygen();
console.log('Public Key:', mlkemKeys.publicKey);
// 2. Stateful Client
const client = PqchatClient.generateIdentity("alice");
const bundle = client.exportPrekeyBundle();
console.log('Identity MLDSA Public Key:', bundle.identityMldsaPublic);High-Level JSON/Base64 Wrapper (Compat)
A compatibility wrapper is provided that matches the NativeCryptoBridge interface used in the QuantumChat mobile clients. It accepts and returns JSON and Base64-encoded strings instead of raw Buffers.
const PqchatNative = require('@quantumchat/pqchat-node/compat');
const alicePrekeyJson = PqchatNative.generateIdentity("alice");
const alicePrekey = JSON.parse(alicePrekeyJson);
console.log('Base64 ML-DSA Public Key:', alicePrekey.identity_mldsa_public);
const mnemonic = PqchatNative.exportMnemonic();
console.log('Mnemonic:', mnemonic);Development
Native .node binaries are build artifacts and must not be committed to the repo. For local development, build the platform addon before running tests:
bun install
bun run build:debug
bun testTo run the full smoke test (simulating an npm pack and install cycle):
bun run test:smoke