m8b/ethbnd-keystore

具有 JSON Keystore 实现的库,由于依赖于 scrypt 而独立于主库

v1.0.0-beta 2023-09-26 15:20 UTC

This package is auto-updated.

Last update: 2024-09-26 17:23:29 UTC


README

由于扩展依赖,此库与 Ether Binder 库插件分离

此库需要 PECL 扩展 scrypt。要安装扩展

pecl install scrypt

安装

composer require m8b/ethbnd-keystore

用法

要读取现有的 json keystore,获取 json 和密码,并将其放入 loadFromKeystore 函数

$keystore = file_get_contents("path/to/key.json");
$wallet   = \M8B\EtherBinder\Wallet\JSONKeystoreWallet::loadFromKeystore($keystore, "password"); 

要加密现有的密钥

$key = \M8B\EtherBinder\Crypto\Key::fromHex("0x....");
$wallet = \M8B\EtherBinder\Wallet\JSONKeystoreWallet::wrap($key);
file_put_contents($wallet->export("password"));

要生成新的密钥并将其立即用 json keystore 包装

$wallet = \M8B\EtherBinder\Wallet\JSONKeystoreWallet::generate();

许可

Mozilla 公共许可证 2.0