A Monero cryptography library written in modern PHP 8 by the Monero Integrations team and contributors.
This library implements/interfaces various cryptographic functions used in Monero, such as:
- Monero's base58 encoding
- Monero's mnemonic seeds
- Keccak hash function
- Cryptonote functions on the Edwards25519 curve
- Variably-sized integers (Varint)
Higher-level abstractions are additionally provided for things like generating Monero private/public keys, subaddresses, etc.
The minimum PHP version required is 8.1.0. Please make sure you also have Composer installed.
You can check your PHP version by running:
php -vThe bcmath extension is required.
It is strongly recommended to use the gmp extension for about 100x faster calculations (as opposed to BCMath).
To check what extensions are installed, run:
php -mcomposer require monero-integrations/monero-cryptogit clone https://github.com/monero-integrations/monerophp.git
cd monerophp
composer installFrom here, you can use the library in your PHP project. For example:
require 'vendor/autoload.php';
// To get a list of available mnemonic wordlists
use MoneroIntegrations\MoneroCrypto\Mnemonic;
$wordlists = Mnemonic::getWordsetList();
echo "Available wordlists: " . implode(', ', $wordlists) . PHP_EOL;Documentation is still a work-in-progress, but the library is well-documented with PHPDoc comments.
Current documentation can be found in the /docs folder.
The project uses several development tools to ensure code quality and consistency:
- PHP CodeSniffer: Used to check the code style against the PSR-12 standard.
- PHPStan: Static analysis tool to find bugs and improve code quality.
- PHPUnit: Testing framework for running unit tests.
- Laravel Pint: Code style fixer for PSR-12 compliance.
To ensure everything is working correctly, you can run the tests and code quality checks using Composer scripts:
composer lintRun linting on your code and test files:
composer test:lintcomposer test:phpstancomposer test:unitThis will run linting, PHPStan analysis, and unit tests:
composer testWe follow the PSR-12 coding standard. Please make sure your code adheres to these guidelines. You can use Laravel Pint to automatically fix code style issues.
We welcome contributions! If you have an idea or fix, please follow these steps:
- Fork the repository
- Create a branch with your changes
- Make your changes
- Submit a pull request (PR) with a clear description of the changes
Please ensure your code passes all tests and adheres to our coding standards before submitting a pull request.
For any questions or issues, feel free to reach out to the maintainers or open an issue on GitHub.
This library is licensed under the MIT License. See the LICENSE file for more information.
