{"id":49010919,"url":"https://github.com/paragonie/ext-pqcrypto","last_synced_at":"2026-05-25T14:09:30.810Z","repository":{"id":349821238,"uuid":"1203564876","full_name":"paragonie/ext-pqcrypto","owner":"paragonie","description":"Post-Quantum Cryptography for PHP","archived":false,"fork":false,"pushed_at":"2026-04-28T18:36:51.000Z","size":34,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-28T19:25:05.486Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paragonie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-07T06:43:44.000Z","updated_at":"2026-04-28T18:27:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/paragonie/ext-pqcrypto","commit_stats":null,"previous_names":["paragonie/ext-pqcrypto"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/paragonie/ext-pqcrypto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fext-pqcrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fext-pqcrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fext-pqcrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fext-pqcrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paragonie","download_url":"https://codeload.github.com/paragonie/ext-pqcrypto/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fext-pqcrypto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32633438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"online","status_checked_at":"2026-05-05T02:00:06.033Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-18T23:00:39.844Z","updated_at":"2026-05-05T03:00:58.253Z","avatar_url":"https://github.com/paragonie.png","language":"Rust","funding_links":[],"categories":["Cryptography \u0026 Security"],"sub_categories":[],"readme":"# ext-pqcrypto: Post-Quantum Cryptography for PHP\n\n[![CI](https://github.com/paragonie/ext-pqcrypto/actions/workflows/ci.yml/badge.svg)](https://github.com/paragonie/ext-pqcrypto/actions/workflows/ci.yml)\n[![Latest Stable Version](https://poser.pugx.org/paragonie/ext-pqcrypto/v/stable)](https://packagist.org/packages/paragonie/ext-pqcrypto)\n[![License](https://poser.pugx.org/paragonie/ext-pqcrypto/license)](https://packagist.org/packages/paragonie/ext-pqcrypto)\n[![Downloads](https://img.shields.io/packagist/dt/paragonie/ext-pqcrypto.svg)](https://packagist.org/packages/paragonie/ext-pqcrypto)\n[![crates.io](https://img.shields.io/crates/v/php-ext-pqcrypto.svg?logo=rust)](https://crates.io/crates/php-ext-pqcrypto)\n\nA PHP extension (written in Rust) that exposes post-quantum cryptography algorithms from the \n[RustCrypto](https://github.com/RustCrypto) project.\n\nImplements [FIPS 203](https://csrc.nist.gov/pubs/fips/203/final) (ML-KEM), [FIPS 204](https://csrc.nist.gov/pubs/fips/204/final)\n(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/)\n(hybrid X25519 + ML-KEM-768).\n\n## Requirements\n\n* PHP \u003e= 8.1\n* Rust toolchain (rustc \u003e= 1.85, **nightly**)\n* `php-config` in PATH (for ext-php-rs build)\n\n## Building\n\n```shell\nmake build   # cargo build --release\nmake test    # run PHP test suite\nmake install # copy to PHP extension dir\n```\n\nAfter installing, add `extension=pqcrypto` to your `php.ini`, then run:\n\n```php\nvar_dump(extension_loaded('pqcrypto')); // bool(true)\n```\n\n## Usage\n\n### X-Wing (Hybrid KEM: X25519 + ML-KEM-768)\n\n\u003e [!TIP]\n\u003e\n\u003e X-Wing is the recommend hybrid post-quantum KEM.\n\n```php\n[$sk, $pk] = PQCrypto\\XWing::generateKeypair();\n\n[$sharedSecret, $ciphertext] = $pk-\u003eencapsulate();\n$recipientSecret = $sk-\u003edecapsulate($ciphertext);\n\nassert(hash_equals($recipientSecret, $sharedSecret));\n```\n\n### ML-KEM (Key Encapsulation)\n\n\u003e [!TIP]\n\u003e\n\u003e We do not recommend ML-KEM-512, but include it for completeness.\n\u003e ML-KEM-768 or ML-KEM-1024 should be used if X-Wing is not acceptable.\n\n```php\n// ML-KEM-768 (also: MLKem512, MLKem1024)\n[$sk, $pk] = PQCrypto\\MLKem768::generateKeypair();\n\n[$sharedSecret, $ciphertext] = $pk-\u003eencapsulate();\n$recipientSecret = $sk-\u003edecapsulate($ciphertext);\n\nassert(hash_equals($recipientSecret, $sharedSecret));\n\n// Serialize / restore\n$skBytes = $sk-\u003ebytes();  // 64-byte seed\n$sk2 = PQCrypto\\MLKem768\\DecapsulationKey::fromBytes($skBytes);\n```\n\n### ML-DSA (Digital Signatures)\n\n\u003e [!TIP]\n\u003e\n\u003e ML-DSA-44 is fine. The larger parameter sets should only be used if you specifically need them for compliance reasons\n\u003e (i.e., CNSA 2.0).\n\n```php\n// ML-DSA-44 (also: MLDSA65, MLDSA87)\n[$signingKey, $verifyingKey] = PQCrypto\\MLDSA44::generateKeypair();\n\n$signature = $signingKey-\u003esign('message');\n$valid = $verifyingKey-\u003everify($signature, 'message'); // true\n$invalid = $verifyingKey-\u003everify($signature, 'wrong');  // false\n\n// Serialize / restore\n$seed = $signingKey-\u003ebytes(); // 32-byte seed\n$sk2 = PQCrypto\\MLDSA44\\SigningKey::fromBytes($seed);\n```\n\n### SLH-DSA (Stateless Hash-Based Signatures)\n\n```php\n// Parameters: hash function + speed\n// Hash: 'shake128', 'shake192', 'shake256',\n//       'sha2-128', 'sha2-192', 'sha2-256'\n// Speed: 'fast' (larger sigs) or 'small' (smaller sigs)\n$slh = new PQCrypto\\SLHDSA('shake256', 'fast');\n\n[$signingKey, $verifyingKey] = $slh-\u003egenerateKeypair();\n\n$signature = $signingKey-\u003esign('message');\n$valid = $verifyingKey-\u003everify($signature, 'message');\n\n// Import keys\n$sk2 = $slh-\u003eimportSigningKey($signingKey-\u003ebytes());\n$vk2 = $slh-\u003eimportVerifyingKey($verifyingKey-\u003ebytes());\n```\n\n## Key Sizes\n\n### KEM\n\n| Algorithm   | Seed  | Public Key | Ciphertext | Shared Secret |\n|-------------|-------|------------|------------|---------------|\n| ML-KEM-512  | 64    | 800        | 768        | 32            |\n| ML-KEM-768  | 64    | 1184       | 1088       | 32            |\n| ML-KEM-1024 | 64    | 1568       | 1568       | 32            |\n| X-Wing      | 32    | 1216       | 1120       | 32            |\n\n### Signatures\n\n| Algorithm        | Seed | Public Key | Signature |\n|------------------|------|------------|-----------|\n| ML-DSA-44        | 32   | 1312       | 2420      |\n| ML-DSA-65        | 32   | 1952       | 3309      |\n| ML-DSA-87        | 32   | 2592       | 4627      |\n| SLH-DSA-*-128s   | 64   | 32         | 7856      |\n| SLH-DSA-*-128f   | 64   | 32         | 17088     |\n| SLH-DSA-*-192s   | 96   | 48         | 16224     |\n| SLH-DSA-*-192f   | 96   | 48         | 35664     |\n| SLH-DSA-*-256s   | 128  | 64         | 29792     |\n| SLH-DSA-*-256f   | 128  | 64         | 49856     |\n\nAll sizes above are measured in bytes. \n\nSecret keys are stored as seeds, never semi-expanded secrets. This is a \n[deliberate design choice](https://words.filippo.io/ml-kem-seeds/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparagonie%2Fext-pqcrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparagonie%2Fext-pqcrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparagonie%2Fext-pqcrypto/lists"}