sandermuller/solana-pubkey 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sandermuller/solana-pubkey

Composer 安装命令:

composer require sandermuller/solana-pubkey

包简介

Tiny, framework-agnostic PHP library for Solana public keys and Ed25519 signature verification.

README 文档

README

Latest Version on Packagist run-tests PHPStan Total Downloads License

Tiny, framework-agnostic PHP library for Solana public keys and Ed25519 signature verification.

Built for Sign-In With Solana flows where you need to validate a wallet address and verify a detached signature — without pulling in a full Solana SDK.

Installation

composer require sandermuller/solana-pubkey

Requires PHP 8.3+ and ext-sodium. No other runtime dependencies.

Usage

Verify a Solana wallet signature

use SanderMuller\SolanaPubkey\Base58;
use SanderMuller\SolanaPubkey\PublicKey;

$pubkey    = PublicKey::from($walletAddressBase58);
$signature = Base58::decode($signatureBase58);

if ($pubkey->verify($message, $signature)) {
    // signature is valid for $message under $pubkey
}

Construct from raw bytes

use SanderMuller\SolanaPubkey\PublicKey;

$keypair = sodium_crypto_sign_keypair();
$pubkey  = PublicKey::fromBytes(sodium_crypto_sign_publickey($keypair));

echo $pubkey->toBase58();

Base58 encoding

use SanderMuller\SolanaPubkey\Base58;

$encoded = Base58::encode($binary);   // throws nothing
$decoded = Base58::decode($base58);   // throws InvalidBase58Exception on bad input

API surface

See PUBLIC_API.md for the SemVer-governed surface. Anything not listed there is @internal and may change in any release.

Exceptions

All thrown exceptions extend SanderMuller\SolanaPubkey\Exceptions\SolanaPubkeyException (which extends RuntimeException):

Exception Thrown by
InvalidPublicKeyException PublicKey::from(), PublicKey::fromBytes() — wrong length or invalid base58
InvalidBase58Exception Base58::decode() — non-alphabet character
InvalidSignatureException PublicKey::verify() — signature is not exactly 64 bytes

PublicKey::verify() returns false (does not throw) for wrong-but-well-formed signatures and tampered messages.

Why this exists

The collectiq/solana-php-sdk is a full Solana SDK (RPC, transactions, Borsh, programs, DID). For SIWS-style auth flows, you only need three primitives: base58 codec, Ed25519 verify, and pubkey validation. This package ships exactly those, with no framework dependencies and no proprietary-license upstream.

Development

composer install
composer test      # Pest
composer qa        # Rector + Pint + PHPStan + lean-package-validator + tests

License

MIT — see LICENSE.

统计信息

  • 总下载量: 214
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固