starkbank/ecdsa
Pure-PHP ECDSA implementation compatible with OpenSSL. Fast signing/verification using Jacobian coordinates and optimized scalar multiplication. Security features include RFC6979 deterministic nonces, low-S normalization, on-curve validation, and hash truncation. Supports secp256k1 and P-256; requir...
ext-openssl or system libraries. Ideal for environments where extensions are restricted (e.g., serverless, Docker, or shared hosting).openssl_sign()/openssl_verify() in Laravel’s core or third-party packages (e.g., firephp/jwt).secp256k1 (blockchain) and prime256v1 (TLS), with extensibility for custom curves. Useful for:
ellipsephp/bitcoin).ed25519 via CurveFp::add()) for research or IoT.ext-openssl in high-throughput Laravel APIs (e.g., WebSocket handlers or batch processing).EllipticCurve\Ecdsa as a singleton, enabling dependency injection (e.g., for signing middleware or console commands).Ecdsa::sign()) to mimic Laravel’s Hash or Crypt facades, reducing boilerplate.PrivateKey/PublicKey objects in Laravel’s cache store (e.g., Redis) for repeated operations.filesystem (e.g., store PEM keys in storage/app/crypto/) or use spatie/laravel-medialibrary for encrypted key storage.Encrypter to support ECDSA-signed payloads (e.g., for API authentication).openssl_sign() calls in custom code with starkbank/ecdsa.web-token/jwt-framework) to use the new library for signing/verification.ext-openssl in php.ini post-migration.ext-gmp (not enabled by default). Document this in README and composer.json under require:
"require": {
"ext-gmp": "*"
}
ext-openssl (e.g., spatie/laravel-honeypot).ext-gmp be enabled in production/development environments? If not, evaluate fallback options (e.g., BCMath, but with degraded performance).openssl_sign() calls in Laravel core or third-party packages that must be migrated?secp256k1 or prime256v1 sufficient, or are custom curves needed?ext-openssl in Laravel’s specific workload (e.g., signing 10,000 requests/sec). Use starkbank/ecdsa's benchmark script as a baseline.openssl_sign()/openssl_verify() in Laravel’s Illuminate\Support\Facades\Crypt or custom auth logic.firebase/php-jwt) or custom tokens (e.g., tylerbrinks/laravel-jwt-auth).web3p/web3.php or ellipsephp/bitcoin for transaction signing.php artisan crypto:sign).starkbank/ecdsa (MIT license, no conflicts).ext-openssl (e.g., ramsey/uuid uses OpenSSL by default; use ramsey/uuid-doctrine instead).TEXT (PEM) or VARBINARY (compressed keys) in Laravel’s Illuminate\Database tables.openssl_sign()/openssl_verify() usage.spatie/laravel-activitylog, laravel/sanctum).starkbank/ecdsa:
// app/Providers/EcdsaServiceProvider.php
namespace App\Providers;
use EllipticCurve\Ecdsa as StarkEcdsa;
use Illuminate\Support\ServiceProvider;
class EcdsaServiceProvider extends ServiceProvider {
public function register() {
$this->app->singleton('ecdsa', function () {
return new class {
public function sign(string $message, string $privateKeyPem): string {
$key = EllipticCurve\PrivateKey::fromPem($privateKeyPem);
$signature = StarkEcdsa::sign($message, $key);
return $signature->toBase64();
}
// Add verify(), key generation methods...
};
});
}
}
openssl_sign() call in a non-critical module (e.g., a custom API endpoint).config/app.php to require ext-gmp.openssl_sign() calls with the new service.openssl dgst -sha256 -sign privateKey.pem -out signatureDer.txt message.txt
php artisan crypto:verify signatureDer.txt message.txt publicKey.pem
phpunit and symfony/stopwatch.openssl ecparam -name secp256k1 -genkey -out privateKey.pem) and import into starkbank/ecdsa:
$privateKey = EllipticCurve\PrivateKey::fromPem(file_get_contents('privateKey.pem'));
starkbank/ecdsa format:
$signature = EllipticCurve\Signature::fromDer(file_get_contents('signatureDer.txt'));
Storage facade to read/write PEM keys:
$privateKeyPem = Storage::disk('local')->get('crypto/privateKey.pem');
.env:
CRYPTO_PRIVATE_KEY_PATH=storage/app/crypto/privateKey.pem
Illuminate/Encryption for key protection (e.g., encrypt PEM files at rest).How can I help you explore Laravel packages today?