Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ecc Laravel Package

mdanter/ecc

Pure-PHP elliptic curve cryptography for ECDSA signatures and Diffie-Hellman key exchange. Supports common NIST and secp curves (including secp256k1), deterministic HMAC-based k generation, and constant-time scalar multiplication. Requires GMP.

View on GitHub
Deep Wiki
Context7

Pure PHP Elliptic Curve Cryptography Library

Frequently asked questions about Ecc
How do I integrate mdanter/ecc into a Laravel application for ECDSA signing?
Create a service provider to bind the ECC library to Laravel’s container, then expose methods like `Ecc::sign()` and `Ecc::verify()` via a facade. For example, register the service in `config/app.php` and use it in controllers or middleware. Store private keys securely in Laravel’s encrypted storage or a dedicated secrets manager.
Which Laravel versions are compatible with mdanter/ecc?
The package itself requires PHP 7.0+ or 8.0+, so it works with Laravel 5.8+ (PHP 7.2+) and Laravel 9/10 (PHP 8.0+). Test thoroughly in your target Laravel version, as some cryptographic edge cases may vary. Avoid PHP 7.1 or older due to GMP extension limitations.
Can I use secp256k1 for Bitcoin-like signatures in Laravel?
Yes, mdanter/ecc supports secp256k1 out of the box. Use it for custom blockchain-like workflows, but validate signatures against Bitcoin’s strict rules (e.g., low-S values). For production, benchmark performance—pure PHP ECC is slower than OpenSSL, so cache keys where possible or use it only for non-critical paths.
How do I handle key generation securely in Laravel?
Use Laravel’s `random_bytes()` or `Str::random()` for deterministic HMAC-k generation to avoid key reuse attacks. Store private keys in Laravel’s encrypted filesystem disk or a dedicated vault like Hashicorp Vault. For ephemeral keys (e.g., ECDH), implement a rotation policy via Laravel’s scheduled tasks or event listeners.
What’s the performance impact of using pure PHP ECC vs. OpenSSL in Laravel?
Pure PHP ECC operations (e.g., ECDSA signing) are 10–100x slower than OpenSSL. Benchmark critical paths in your Laravel app—aim for <50ms latency for 99% of requests. Use OpenSSL as a fallback (via `config/ecc.php`) for production workloads, or pre-compute keys during off-peak hours to cache results.
How do I store ECC public/private keys in Laravel’s database?
Use Laravel’s `binary` column type for keys (e.g., `public_key` as 33-byte hex for secp256k1, `private_key` as 32-byte binary). Example migration: `$table->binary('public_key')->nullable();`. For JSON storage, encode keys as hex strings. Never store raw keys in plaintext—always encrypt with Laravel’s `Crypt` facade.
Is mdanter/ecc suitable for FIPS 140-2 compliance in Laravel?
No, pure PHP implementations like mdanter/ecc are not FIPS 140-2 validated. For compliance, use OpenSSL’s FIPS module or a hardware security module (HSM) like AWS KMS. mdanter/ecc can serve as a fallback for non-compliant environments, but audit trails and logging must document this exception.
How do I add ECDSA signing to a Laravel API endpoint?
Create a route like `/api/signature` with middleware to validate requests. Use the ECC facade to sign data: `return Ecc::sign($message, $privateKey)`. Rate-limit the endpoint to prevent abuse. For JWT signing, integrate with `firebase/php-jwt` or Laravel Sanctum, replacing RSA with ECDSA.
What are the alternatives to mdanter/ecc for Laravel?
For OpenSSL-based ECC, use Laravel’s built-in `Hash` facade or `openssl_ec_sign()`. For pure PHP, consider `libsecp256k1` (C bindings) or `web3/php` (for Ethereum). If you need deterministic ECDSA, mdanter/ecc is the only PHP-native option with HMAC-k support. For HSM-backed keys, use AWS KMS or GCP KMS via Laravel’s `encryption` config.
How do I test ECC functionality in Laravel’s test suite?
Mock the ECC service in PHPUnit tests using Laravel’s `Mockery` or `createMock()`. Test edge cases like malformed signatures, key reuse, and deterministic HMAC-k generation. Use `Artisan::call()` to simulate CLI key generation (e.g., `php artisan ecc:generate-key`). Validate outputs against known test vectors from NIST or Bitcoin’s secp256k1 specs.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit