PHPackages                             paragonie/ext-pqcrypto - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. paragonie/ext-pqcrypto

ActivePhp-ext[Security](/categories/security)

paragonie/ext-pqcrypto
======================

PHP extension for post-quantum cryptography (ML-KEM, X-Wing, ML-DSA, SLH-DSA)

v0.3.0(1mo ago)101ISCRustPHP &gt;=8.1CI passing

Since Apr 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/paragonie/ext-pqcrypto)[ Packagist](https://packagist.org/packages/paragonie/ext-pqcrypto)[ Docs](https://github.com/paragonie/ext-pqcrypto)[ RSS](/packages/paragonie-ext-pqcrypto/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (1)Versions (13)Used By (0)

ext-pqcrypto: Post-Quantum Cryptography for PHP
===============================================

[](#ext-pqcrypto-post-quantum-cryptography-for-php)

[![CI](https://github.com/paragonie/ext-pqcrypto/actions/workflows/ci.yml/badge.svg)](https://github.com/paragonie/ext-pqcrypto/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/da968a9c484d1b37d44babd4253a89a805d0d98a7c280219c6733930c1ae5238/68747470733a2f2f706f7365722e707567782e6f72672f70617261676f6e69652f6578742d707163727970746f2f762f737461626c65)](https://packagist.org/packages/paragonie/ext-pqcrypto)[![License](https://camo.githubusercontent.com/043e7196f6e300bd115e3e9cfeed1430dc7a0cb0f45c55e1dc0d52c64af0faaa/68747470733a2f2f706f7365722e707567782e6f72672f70617261676f6e69652f6578742d707163727970746f2f6c6963656e7365)](https://packagist.org/packages/paragonie/ext-pqcrypto)[![Downloads](https://camo.githubusercontent.com/b97c166c7cff7c758991661bd87d9735d39bc07bbe1a2f89fd12c81302135261/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70617261676f6e69652f6578742d707163727970746f2e737667)](https://packagist.org/packages/paragonie/ext-pqcrypto)[![crates.io](https://camo.githubusercontent.com/891287003d5b90f9c0a3824ea5ca9e3096bd2680aae1f772dde999ebe2991ae7/68747470733a2f2f696d672e736869656c64732e696f2f6372617465732f762f7068702d6578742d707163727970746f2e7376673f6c6f676f3d72757374)](https://crates.io/crates/php-ext-pqcrypto)

A PHP extension (written in Rust) that exposes post-quantum cryptography algorithms from the [RustCrypto](https://github.com/RustCrypto) project.

Implements [FIPS 203](https://csrc.nist.gov/pubs/fips/203/final) (ML-KEM), [FIPS 204](https://csrc.nist.gov/pubs/fips/204/final)(ML-DSA), [FIPS 205](https://csrc.nist.gov/pubs/fips/205/final) (SLH-DSA), and [X-Wing](https://datatracker.ietf.org/doc/draft-connolly-cfrg-xwing-kem/)(hybrid X25519 + ML-KEM-768).

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Rust toolchain (rustc &gt;= 1.85, **nightly**)
- `php-config` in PATH (for ext-php-rs build)

Building
--------

[](#building)

```
make build   # cargo build --release
make test    # run PHP test suite
make install # copy to PHP extension dir
```

After installing, add `extension=pqcrypto` to your `php.ini`, then run:

```
var_dump(extension_loaded('pqcrypto')); // bool(true)
```

Usage
-----

[](#usage)

### X-Wing (Hybrid KEM: X25519 + ML-KEM-768)

[](#x-wing-hybrid-kem-x25519--ml-kem-768)

Tip

X-Wing is the recommend hybrid post-quantum KEM.

```
[$sk, $pk] = PQCrypto\XWing::generateKeypair();

[$sharedSecret, $ciphertext] = $pk->encapsulate();
$recipientSecret = $sk->decapsulate($ciphertext);

assert(hash_equals($recipientSecret, $sharedSecret));
```

### ML-KEM (Key Encapsulation)

[](#ml-kem-key-encapsulation)

Tip

We do not recommend ML-KEM-512, but include it for completeness. ML-KEM-768 or ML-KEM-1024 should be used if X-Wing is not acceptable.

```
// ML-KEM-768 (also: MLKem512, MLKem1024)
[$sk, $pk] = PQCrypto\MLKem768::generateKeypair();

[$sharedSecret, $ciphertext] = $pk->encapsulate();
$recipientSecret = $sk->decapsulate($ciphertext);

assert(hash_equals($recipientSecret, $sharedSecret));

// Serialize / restore
$skBytes = $sk->bytes();  // 64-byte seed
$sk2 = PQCrypto\MLKem768\DecapsulationKey::fromBytes($skBytes);
```

### ML-DSA (Digital Signatures)

[](#ml-dsa-digital-signatures)

Tip

ML-DSA-44 is fine. The larger parameter sets should only be used if you specifically need them for compliance reasons (i.e., CNSA 2.0).

```
// ML-DSA-44 (also: MLDSA65, MLDSA87)
[$signingKey, $verifyingKey] = PQCrypto\MLDSA44::generateKeypair();

$signature = $signingKey->sign('message');
$valid = $verifyingKey->verify($signature, 'message'); // true
$invalid = $verifyingKey->verify($signature, 'wrong');  // false

// Serialize / restore
$seed = $signingKey->bytes(); // 32-byte seed
$sk2 = PQCrypto\MLDSA44\SigningKey::fromBytes($seed);
```

### SLH-DSA (Stateless Hash-Based Signatures)

[](#slh-dsa-stateless-hash-based-signatures)

```
// Parameters: hash function + speed
// Hash: 'shake128', 'shake192', 'shake256',
//       'sha2-128', 'sha2-192', 'sha2-256'
// Speed: 'fast' (larger sigs) or 'small' (smaller sigs)
$slh = new PQCrypto\SLHDSA('shake256', 'fast');

[$signingKey, $verifyingKey] = $slh->generateKeypair();

$signature = $signingKey->sign('message');
$valid = $verifyingKey->verify($signature, 'message');

// Import keys
$sk2 = $slh->importSigningKey($signingKey->bytes());
$vk2 = $slh->importVerifyingKey($verifyingKey->bytes());
```

Key Sizes
---------

[](#key-sizes)

### KEM

[](#kem)

AlgorithmSeedPublic KeyCiphertextShared SecretML-KEM-5126480076832ML-KEM-768641184108832ML-KEM-1024641568156832X-Wing321216112032### Signatures

[](#signatures)

AlgorithmSeedPublic KeySignatureML-DSA-443213122420ML-DSA-653219523309ML-DSA-873225924627SLH-DSA-\*-128s64327856SLH-DSA-\*-128f643217088SLH-DSA-\*-192s964816224SLH-DSA-\*-192f964835664SLH-DSA-\*-256s1286429792SLH-DSA-\*-256f1286449856All sizes above are measured in bytes.

Secret keys are stored as seeds, never semi-expanded secrets. This is a [deliberate design choice](https://words.filippo.io/ml-kem-seeds/).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance91

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

12

Last Release

42d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05d241256cda885139a5697d3bb536b5cec3b430c1adb9c524bf92a37a55758d?d=identicon)[paragonie-scott](/maintainers/paragonie-scott)

---

Top Contributors

[![paragonie-security](https://avatars.githubusercontent.com/u/15914520?v=4)](https://github.com/paragonie-security "paragonie-security (25 commits)")

---

Tags

cryptographypost-quantumml-kemml-dsaslh-dsax-wingpqc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/paragonie-ext-pqcrypto/health.svg)

```
[![Health](https://phpackages.com/badges/paragonie-ext-pqcrypto/health.svg)](https://phpackages.com/packages/paragonie-ext-pqcrypto)
```

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k455.2M1.4k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k170.7M239](/packages/defuse-php-encryption)[paragonie/ciphersweet

Searchable field-level encryption library for relational databases

4661.3M22](/packages/paragonie-ciphersweet)[simplito/elliptic-php

Fast elliptic curve cryptography

2302.4M266](/packages/simplito-elliptic-php)[rych/phpass

PHP Password Library: Easy, secure password management for PHP

252837.5k4](/packages/rych-phpass)[vlucas/pikirasa

PKI public/private RSA key encryption using the OpenSSL extension

104104.1k1](/packages/vlucas-pikirasa)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
