Quick start
By the end of this tutorial, you will have installed pq-oid and pq-key-encoder, looked up algorithm metadata, and round-tripped a PQ public key through DER and PEM encoding in TypeScript or Rust.
Prerequisites
| Requirement | Minimum version |
|---|---|
| Bun or Node.js | Bun 1.0+ or Node 18+ |
| Rust toolchain | 1.78+ |
Check package versions before installing.
v0.0.1means scaffolded only — no implementation. Start withpq-oidandpq-key-encoder, which are both published with real implementations.
TypeScript
1. Install
bun add pq-oid pq-key-encoder
# or
npm install pq-oid pq-key-encoder
2. Look up algorithm metadata
import { OID, Algorithm } from 'pq-oid';
const info = Algorithm.get('ML-DSA-65');
// {
// name: 'ML-DSA-65',
// oid: '2.16.840.1.101.3.4.3.18',
// type: 'sign',
// family: 'ML-DSA',
// securityLevel: 3,
// publicKeySize: 1952,
// privateKeySize: 4032,
// signatureSize: 3309
// }
3. Decode and encode a key
import { fromDER, toPEM, type KeyData } from 'pq-key-encoder';
// Decode a DER-encoded public key (auto-detects SPKI)
const key: KeyData = fromDER(derBytes);
// { alg: 'ML-DSA-65', type: 'public', bytes: Uint8Array }
// Convert to PEM
const pem = toPEM(key);
// -----BEGIN PUBLIC KEY-----
// MIIHsjALBgkr...
// -----END PUBLIC KEY-----
Works in Node 18+, Bun 1.0+, Deno, and modern browsers. Zero runtime dependencies.
Rust
1. Add dependencies
[dependencies]
pq-oid = "1.0"
pq-key-encoder = "1.0"
2. Look up algorithm metadata
use pq_oid::{MlDsa, Algorithm};
let dsa: MlDsa = "ML-DSA-65".parse().unwrap();
assert_eq!(dsa.oid(), "2.16.840.1.101.3.4.3.18");
3. Decode and encode a key
use pq_key_encoder::{PublicKey, PrivateKey};
// Decode a DER-encoded public key
let key = PublicKey::from_spki(&der_bytes)?;
assert_eq!(key.algorithm(), Algorithm::MlDsa(MlDsa::Dsa65));
// Encode to PEM
let pem = key.to_pem();
Rust crates target edition 2021 and the 1.78 toolchain. no_std is supported where applicable.
Next steps
- Full API reference for each package: Package reference
- Algorithm parameters and size tables: Supported algorithms
- ERC-4337 / ERC-7579 integration on Arbitrum: PQ Smart Account architecture