m8b / ethbnd-keystore
Library with JSON Keystore implementation, separate from main library due to dependency on scrypt
v1.0.0-beta
2023-09-26 15:20 UTC
Requires
- ext-openssl: *
- ext-scrypt: ^2.0.1
- m8b/ether-binder: ^v0.0.5-alpha
This package is auto-updated.
Last update: 2024-10-26 17:29:54 UTC
README
This is separated from Ether Binder library addon, due to extension dependency.
This library requires PECL extension scrypt
. To install extension:
pecl install scrypt
Installing:
composer require m8b/ethbnd-keystore
Usage
To read the existing json keystore, get the json and password, and drop it to loadFromKeystore
function
$keystore = file_get_contents("path/to/key.json"); $wallet = \M8B\EtherBinder\Wallet\JSONKeystoreWallet::loadFromKeystore($keystore, "password");
To encrypt existing key
$key = \M8B\EtherBinder\Crypto\Key::fromHex("0x...."); $wallet = \M8B\EtherBinder\Wallet\JSONKeystoreWallet::wrap($key); file_put_contents($wallet->export("password"));
To generate new key and immediately wrap it with json keystore
$wallet = \M8B\EtherBinder\Wallet\JSONKeystoreWallet::generate();
License
Mozilla public license 2.0