deemru / curve25519
Curve25519 签名/验证
1.0.9
2023-04-10 15:47 UTC
Requires
- php: >=5.6
Requires (Dev)
- deemru/abcode: 1.0.*
Suggests
- ext-sodium: Up to ~2000x faster sign/verify
README
Curve25519 实现了在 椭圆曲线 25519 上缺失的签名/验证功能。
- 密码学兼容的签名/验证
- 内置缓存用于最后的关键字计算
- 签名函数的 Sodium 变体(约 2000 倍更快)
使用方法
$curve25519 = new Curve25519(); $msg = 'Hello, world!'; $privateKey = random_bytes( 32 ); $sig = $curve25519->sign( $msg, $privateKey ); $publicKey = $curve25519->getPublicKeyFromPrivateKey( $privateKey ); $verify = $curve25519->verify( $sig, $msg, $publicKey ); if( !$verify ) exit( 1 );
需求
- PHP >= 5.6
推荐
安装
通过 Composer 需求
{ "require": { "deemru/curve25519": "1.0.*" } }
注意
sign_sodium
通过 SHA-512 内部散列私钥- 小心使用
rseed
功能(仅限专家使用) - 考虑使用 ED25519_NO_SHA512SK sodium 构建