|
| 1 | +<img src="https://www.activeledger.io/wp-content/uploads/2018/09/Asset-23.png" alt="Activeledger" width="500"/> |
| 2 | + |
| 3 | +# Activeledger - PHP Key SDK |
| 4 | + |
| 5 | +The Activeledger PHP Key SDK has been built to provide an easy way to generate an ECC keypair that can be used to sign transactions to be |
| 6 | +sent to the Activeledger network. |
| 7 | + |
| 8 | +### Activeledger |
| 9 | + |
| 10 | +[Visit Activeledger.io](https://activeledger.io/) |
| 11 | + |
| 12 | +[Read Activeledgers documentation](https://github.com/activeledger/activeledger) |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +``` |
| 17 | +$ composer require activeledger/php-key ~0.0.1 |
| 18 | +$ composer install -o |
| 19 | +``` |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +The SDK currently supports the following functions: |
| 24 | +* Generate a new ECC keypair |
| 25 | +* Sign a string using the generated private key |
| 26 | + |
| 27 | +### Generate a new ECC keypair |
| 28 | + |
| 29 | +The generate method returns an array containing the public and private keys as HEX strings. |
| 30 | + |
| 31 | +```php |
| 32 | +<?php |
| 33 | +use Activeledger\ActiveECC; |
| 34 | + |
| 35 | +class MyCoolClass |
| 36 | +{ |
| 37 | + public function generateKeyPair(): array |
| 38 | + { |
| 39 | + $ecc = new ActiveECC(); |
| 40 | + $keyPair = $ecc->generate(); |
| 41 | + |
| 42 | + // Alternatively call generate as a static method |
| 43 | + $keyPair = ActiveECC::generate(); |
| 44 | + |
| 45 | + return $keyPair; |
| 46 | + } |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +### Sign a string using a private key |
| 51 | + |
| 52 | +The sign method takes two parameters: the private key as a HEX string, and the data to be signed also as a string. |
| 53 | + |
| 54 | +```php |
| 55 | +<?php |
| 56 | +use Activeledger\ActiveECC; |
| 57 | + |
| 58 | +class MyCoolClass |
| 59 | +{ |
| 60 | + public function signString(string $privateKey, string $data) |
| 61 | + { |
| 62 | + $ecc = new ActiveECC(); |
| 63 | + $signature = $ecc->sign($privateKey, $string); |
| 64 | + return $signature; |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +## License |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +This project is licensed under the [MIT](https://github.com/activeledger/activeledger/blob/master/LICENSE) License |
0 commit comments