{"id":48844041,"url":"https://github.com/paragonie/pqcrypto_compat","last_synced_at":"2026-04-15T04:01:37.997Z","repository":{"id":349835003,"uuid":"1203565390","full_name":"paragonie/pqcrypto_compat","owner":"paragonie","description":"Pure-PHP implementation of Post-Quantum Cryptography Algorithms","archived":false,"fork":false,"pushed_at":"2026-04-07T18:18:06.000Z","size":44,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-07T20:18:57.598Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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:44:28.000Z","updated_at":"2026-04-07T19:50:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/paragonie/pqcrypto_compat","commit_stats":null,"previous_names":["paragonie/pqcrypto_compat"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/paragonie/pqcrypto_compat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpqcrypto_compat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpqcrypto_compat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpqcrypto_compat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpqcrypto_compat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paragonie","download_url":"https://codeload.github.com/paragonie/pqcrypto_compat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paragonie%2Fpqcrypto_compat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31825515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"online","status_checked_at":"2026-04-15T02:00:06.175Z","response_time":63,"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-15T04:01:35.585Z","updated_at":"2026-04-15T04:01:37.989Z","avatar_url":"https://github.com/paragonie.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pqcrypto_compat\n\n[![Build Status](https://github.com/paragonie/pqcrypto_compat/actions/workflows/ci.yml/badge.svg)](https://github.com/paragonie/pqcrypto_compat/actions)\n[![Latest Stable Version](https://poser.pugx.org/paragonie/pqcrypto_compat/v/stable)](https://packagist.org/packages/paragonie/pqcrypto_compat)\n[![License](https://poser.pugx.org/paragonie/pqcrypto_compat/license)](https://packagist.org/packages/paragonie/pqcrypto_compat)\n[![Downloads](https://img.shields.io/packagist/dt/paragonie/pqcrypto_compat.svg)](https://packagist.org/packages/paragonie/pqcrypto_compat)\n\npqcrypto_compat defers to [the pqcrypto extension](https://github.com/paragonie/ext-pqcrypto) if it's available, and\nprovides a polyfill for environments where it is not available, ensuring the PHP ecosystem can effectively migrate to\nuse post-quantum secure cryptographic algorithms.\n\n\u003e [!WARNING]\n\u003e \n\u003e This code has never been independently audited. Use at your own risk.\n\n## Installing\n\n```shell\ncomposer require paragonie/pqcrypto_compat\n```\n\nOptional, but recommended: Install [the pqcrypto extension](https://github.com/paragonie/ext-pqcrypto).\n\n## Usage\n\nThe recommended way to use this polyfill library is the Compat class.\n\n### X-Wing Example\n\nX-Wing is a hybrid KEM combining X25519 and ML-KEM-768. The X25519 implementation is provided by \n[sodium_compat](https://github.com/paragonie/sodium_compat).\n\n```php\n\u003c?php\ndeclare(strict_types=1);\nuse ParagonIE\\PQCrypto\\Compat;\n\n// Key generation\n[$decapsKey, $encapsKey] = Compat::xwing_keygen();\n\n// Encapsulation\n['sharedKey' =\u003e $ss, 'ciphertext' =\u003e $ct] = Compat::xwing_encaps($encapsKey);\n\n// Decapsulation\n$sharedKey = Compat::xwing_decaps($decapsKey, $ct);\nvar_dump(hash_equals($ss, $sharedKey)); // bool(true)\n```\n\n### ML-KEM-768 Example\n\n```php\n\u003c?php\ndeclare(strict_types=1);\nuse ParagonIE\\PQCrypto\\Compat;\n\n// Key generation\n[$decapsKey, $encapsKey] = Compat::mlkem768_keygen();\n$decapsKeyBytes = $decapsKey-\u003ebytes();\n$encapsKeyBytes = $encapsKey-\u003ebytes();\n\n// Encapsulation\n['sharedKey' =\u003e $ss, 'ciphertext' =\u003e $ct] = Compat::mlkem768_encaps($encapsKey);\n// Send $ct to recipient that possesses $decapsKey\n\n$sharedKey = Compat::mlkem768_decaps($decapsKey, $ct);\nvar_dump(hash_equals($ss, $sharedKey)); // bool(true)\n```\n\n### ML-KEM-1024 Example\n\n```php\n\u003c?php\ndeclare(strict_types=1);\nuse ParagonIE\\PQCrypto\\Compat;\n\n// Key generation\n[$decapsKey, $encapsKey] = Compat::mlkem1024_keygen();\n$decapsKeyBytes = $decapsKey-\u003ebytes();\n$encapsKeyBytes = $encapsKey-\u003ebytes();\n\n// Encapsulation\n['sharedKey' =\u003e $ss, 'ciphertext' =\u003e $ct] = Compat::mlkem1024_encaps($encapsKey);\n// Send $ct to recipient that possesses $decapsKey\n\n$sharedKey = Compat::mlkem768_decaps($decapsKey, $ct);\nvar_dump(hash_equals($ss, $sharedKey)); // bool(true)\n```\n\n### ML-DSA-44 Example\n\n```php\n\u003c?php\ndeclare(strict_types=1);\nuse ParagonIE\\PQCrypto\\Compat;\n\n// Key generation\n['signingKey' =\u003e $sk, 'verificationKey' =\u003e $vk] = Compat::mldsa44_keygen();\n\n// Signing\n$message = 'message';\n$signature = Compat::mldsa44_sign($sk, $message);\n$valid = Compat::mldsa44_verify($vk, $signature, $message);\nvar_dump($valid); // bool(true)\n```\n\n### ML-DSA-65 Example\n\n```php\n\u003c?php\ndeclare(strict_types=1);\nuse ParagonIE\\PQCrypto\\Compat;\n\n// Key generation\n['signingKey' =\u003e $sk, 'verificationKey' =\u003e $vk] = Compat::mldsa65_keygen();\n\n// Signing\n$message = 'message';\n$signature = Compat::mldsa65_sign($sk, $message);\n$valid = Compat::mldsa65_verify($vk, $signature, $message);\nvar_dump($valid); // bool(true)\n```\n\n### ML-DSA-87 Example\n\n```php\n\u003c?php\ndeclare(strict_types=1);\nuse ParagonIE\\PQCrypto\\Compat;\n\n// Key generation\n['signingKey' =\u003e $sk, 'verificationKey' =\u003e $vk] = Compat::mldsa87_keygen();\n\n// Signing\n$message = 'message';\n$signature = Compat::mldsa87_sign($sk, $message);\n$valid = Compat::mldsa87_verify($vk, $signature, $message);\nvar_dump($valid); // bool(true)\n```\n\n### Other Algorithms\n\nWe also include ML-KEM-512 for completeness, but do not recommend its usage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparagonie%2Fpqcrypto_compat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparagonie%2Fpqcrypto_compat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparagonie%2Fpqcrypto_compat/lists"}