paragonie/easy-ecc
Easy-ECC is a hardened, easy-to-use PHP wrapper around paragonie/phpecc for elliptic-curve crypto. Generate keypairs, sign/verify messages, and perform ECDH key exchange with Curve25519 or ECDSA curves (K256, P256, P384, P521).
Strengths:
paragonie/phpecc (a hardened fork of mdanter/ecc), with constant-time algorithms to mitigate timing attacks—a critical requirement for cryptographic operations in Laravel/PHP applications.defuse/php-encryption, reducing dependency sprawl for hybrid encryption (e.g., TLS, PGP-like workflows).Fit for Laravel:
Weaknesses:
CryptoService facade).Laravel Compatibility:
config/app.php or via a service provider.Crypto facade for consistency with Laravel’s patterns.php artisan crypto:generate-keypair).Illuminate\Queue\Events\JobProcessed).Database Integration:
.env).Defuse integration).Caching:
Illuminate\Cache\Repository with a crypto tag for invalidation.Curve25519 (fastest) vs. P-521 (slowest). Offload to a queue worker for non-critical paths.phpecc (e.g., PHP 8.4+ deprecations).paragonie/easy-ecc to ^1.3 in composer.json and monitor ParagonIE’s releases.Curve25519 for auth, P-256 for compliance).config/caching.php for key expiration?libsodium.js)? Use Curve25519 for cross-language support.P-256, P-384) required for regulatory reasons (e.g., HIPAA, PCI-DSS)?phpecc (non-libsodium) mode for backward compatibility?Illuminate\Auth\GeneratesUserIds with ECDSA-signed tokens (e.g., ecc->sign($userId)).Defuse integration for request/response encryption (e.g., encrypting Illuminate\Http\Request payloads).JobProcessed events).Cache::put('user_token', $ecc->seal($token, $publicKey))).ecc->keyExchange() for key wrapping).Phase 1: Proof of Concept
paragonie/easy-ecc to composer.json.CryptoService facade with basic methods:
// app/Services/CryptoService.php
class CryptoService {
public function __construct(private EasyECC $ecc) {}
public function generateKeypair(): array {
$sk = $this->ecc->generatePrivateKey();
return [
'private' => $sk->exportPem(),
'public' => $sk->getPublicKey()->exportPem(),
];
}
public function sign(string $message, string $privateKeyPem): string {
$sk = $this->ecc->importPrivateKey($privateKeyPem);
return $this->ecc->sign($message, $sk)->toString();
}
}
AppServiceProvider:
$this->app->singleton(EasyECC::class, fn() => new EasyECC('P256'));
$this->app->singleton(CryptoService::class);
Phase 2: Core Integration
Sanctum or Passport).encrypted_email) using Defuse:
$defuse = new Defuse($this->ecc);
$encrypted = $defuse->seal($user->email, $user->publicKey);
X-ECC-Signature header for request validation.Phase 3: Scaling
KeyRotationService to cycle keys periodically.encrypt jobs).ecc->sign() calls) via Laravel Telescope.P-256 for FIPS).openssl_pkey_get()).libsodium where available (fallback to phpecc).P-521 key exchanges).How can I help you explore Laravel packages today?