paragonie/ecc
Pure-PHP elliptic curve cryptography (ECDSA/ECDH) with an OpenSSL 3+ fast path and hardened constant-time fallbacks. Fork of phpecc/mdanter. Supports secp256k1, NIST P-256/384/521, Brainpool, plus optional insecure curves.
Security-Critical Cryptographic Infrastructure:
SchnorrSigner) for modern cryptographic protocols (e.g., Bitcoin Taproot, ZKPs).Compliance & Standards Alignment:
secp256k1, nistp384, brainpoolp512r1).Build vs. Buy:
mdanter/ecc or openssl to a unified, secure-by-default library.Use Cases:
secp256k1, nistp384, nistp521).mdanter/ecc or easy-ecc and need a drop-in replacement with hardened defaults.paragonie/easy-ecc (simpler API, built on top of phpecc).*"This is a drop-in, enterprise-grade PHP library for elliptic curve cryptography (ECC), critical for securing authentication, payments, and compliance-bound systems. It replaces risky custom implementations or outdated libraries with:
brainpoolp512r1 for German government standards).mdanter/ecc.Why now?
k values in ECDSA).Risk: Minimal—used in production by security-conscious teams (e.g., Paragon Initiative)."*
*"paragonie/ecc gives you low-level control over ECC operations while enforcing security best practices:
nistp192 blocks by default; opt-in required).secp256k1, nistp384, nistp521 (mitigates timing attacks).Key Tradeoffs:
easy-ecc; pure PHP mode is slower than OpenSSL.Integration:
composer require paragonie/ecc:^2
Example Use Case:
// ECDH Key Exchange (secure)
$alicePrivate = EccFactory::getSecgCurves()->generator256()->randomPrivateKey();
$alicePublic = $alicePrivate->getPublicKey();
$bobPrivate = EccFactory::getSecgCurves()->generator256()->randomPrivateKey();
$sharedSecret = $alicePrivate->getSharedSecret($bobPrivate->getPublicKey());
// ECDSA Signing (compliant)
$signer = new \Mdanter\Ecc\Crypto\Signature\Signer\Ecdsa\Sha256();
$signature = $signer->signWithKey($privateKey, $message);
$valid = $signer->verifyWithKey($publicKey, $message, $signature);
When to Use:
Alternatives:
easy-ecc if you prefer a simpler API.How can I help you explore Laravel packages today?