deemru/curve25519

Curve25519 签名/验证

1.0.9 2023-04-10 15:47 UTC

This package is auto-updated.

Last update: 2024-09-10 19:01:07 UTC


README

packagist php-v GitHub codacy license

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 );

需求

推荐

安装

通过 Composer 需求

{
    "require": {
        "deemru/curve25519": "1.0.*"
    }
}

注意